Skip to content

Commit

Permalink
fix: Update failed test case for 0-5A wallet switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Nov 28, 2024
1 parent 1ce6d78 commit 1ef8bf4
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 92 deletions.
60 changes: 60 additions & 0 deletions integration_test/lib/helpers/accessControl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { faker } from '@faker-js/faker';
import { Page } from '@playwright/test';

const customHeader = { 'X-Custom-Header': 'intersect' };

export async function deletePoll(page: Page, pollId: number) {
const res = await page.request.post('/api/archivePoll', {
headers: customHeader,
data: {
pollId: pollId,
},
});
return res;
}

export async function createPoll(page: Page) {
const body = {
name: faker.person.firstName(),
hashedText: faker.person.lastName(),
link: faker.internet.url(),
};
const res = await page.request.post('/api/newPoll', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}

export async function updateUser(page: Page, userId: string = '138') {
const body = {
userId: userId,
name: faker.person.firstName(),
email: faker.person.firstName() + '@gmail.com',
wallet_address: faker.person.lastName(),
};
const res = await page.request.post('/api/updateUser', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}

export async function updateActiveVoter(
page: Page,
workshopId: string = '63',
activeVoterId: string = '138'
) {
const body = { workshopId: workshopId, activeVoterId: activeVoterId };
const res = await page.request.post('/api/updateActiveVoter', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}
24 changes: 8 additions & 16 deletions integration_test/tests/0-common/comon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ import path = require('path');
import fs = require('fs');
import { getCSVResults } from '@helpers/file';
import PollPage from '@pages/pollPage';
import {
newDelegate1Page,
newDelegate2Page,
newDelegatePage,
newOrganizer1Page,
newOrganizerPage,
} from '@helpers/page';
import HomePage from '@pages/homePage';
import { newDelegatePage } from '@helpers/page';
import { delegateWallets, organizerWallets } from '@constants/staticWallets';
import { importWallet } from '@fixtures/importWallet';
import loadEternlExtension from '@fixtures/loadExtension';
Expand Down Expand Up @@ -474,7 +467,9 @@ test.describe('Wallet switching', () => {
await connectWalletButton.click();

// Assert representative name
await expect(page.getByTestId('disconnect-wallet')).toBeVisible();
await expect(page.getByTestId('disconnect-wallet')).toBeVisible({
timeout: 10_000,
});
const user = await page.getByTestId('representative-name').innerText();
expect(user).toEqual('Test organizer 02');

Expand All @@ -484,13 +479,10 @@ test.describe('Wallet switching', () => {
await importWallet(page, wallet);

await page.reload();
await page.getByTestId('connect-wallet-button').first().click();
await page.waitForLoadState('load');
await page.getByTestId('connect-wallet-button').first().click();

// Assert disconnection
await expect(page.getByTestId('connect-wallet-Eternl')).toBeVisible({
timeout: 10_000,
});
await expect(
page.getByTestId('connect-wallet-button').first()
).toBeVisible();
expect(page.getByRole('heading', { name: 'Are you a delegate?' }));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import HomePage from '@pages/homePage';
import { faker } from '@faker-js/faker';
import PollPage from '@pages/pollPage';
import {
createNewPageWithWallet,
newAlternatePage,
newDelegate1Page,
newDelegate2Page,
newDelegatePage,
} from '@helpers/page';
import { importWallet } from '@fixtures/importWallet';

test.beforeEach(async () => {
await setAllureEpic('1. Convention Organizers');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,79 +1,18 @@
import { organizerWallets } from '@constants/staticWallets';
import { importWallet } from '@fixtures/importWallet';
import loadEternlExtension from '@fixtures/loadExtension';
import {
newDelegatePage,
newOrganizer1Page,
newOrganizerPage,
} from '@helpers/page';
import { newOrganizer1Page } from '@helpers/page';
import { getUserPages } from '@helpers/userRoles';
import test, { BrowserContext, expect, Page } from '@playwright/test';
import { faker } from '@faker-js/faker';
import test, { expect, Page } from '@playwright/test';
import HomePage from '@pages/homePage';

const UserAuthFiles = [
'.auth/organizer1.json',
'.auth/delegate1.json',
'.auth/alternate1.json',
];

const customHeader = { 'X-Custom-Header': 'intersect' };

async function deletePoll(page: Page, pollId: number) {
const res = await page.request.post('/api/archivePoll', {
headers: customHeader,
data: {
pollId: pollId,
},
});
return res;
}

async function createPoll(page: Page) {
const body = {
name: faker.person.firstName(),
hashedText: faker.person.lastName(),
link: faker.internet.url(),
};
const res = await page.request.post('/api/newPoll', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}

async function updateUser(page: Page, userId: string = '138') {
const body = {
userId: userId,
name: faker.person.firstName(),
email: faker.person.firstName() + '@gmail.com',
wallet_address: faker.person.lastName(),
};
const res = await page.request.post('/api/updateUser', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}

async function updateActiveVoter(
page: Page,
workshopId: string = '63',
activeVoterId: string = '138'
) {
const body = { workshopId: workshopId, activeVoterId: activeVoterId };
const res = await page.request.post('/api/updateActiveVoter', {
headers: {
'X-Custom-Header': 'intersect',
},
data: body,
});
return res;
}
import { setAllureEpic } from '@helpers/allure';
import {
createPoll,
deletePoll,
updateActiveVoter,
updateUser,
} from '@helpers/accessControl';

test.beforeEach(async () => {
await setAllureEpic('5. Access Control');
});

test.describe('Access Control Test', () => {
test.describe('Poll', () => {
Expand Down
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ef8bf4

Please sign in to comment.