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 e0d14c9
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 85 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;
}
23 changes: 14 additions & 9 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 @@ -484,8 +477,20 @@ test.describe('Wallet switching', () => {
await importWallet(page, wallet);

await page.reload();

await expect(
page.getByTestId('connect-wallet-button').first()
).toBeVisible();
expect(page.getByRole('heading', { name: 'Are you a delegate?' }));

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

await expect(
page.getByTestId('connect-wallet-button').first()
).toBeVisible();
await page.getByTestId('connect-wallet-button').first().click();

// Assert disconnection
Expand Down
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

0 comments on commit e0d14c9

Please sign in to comment.