diff --git a/integration_test/lib/helpers/accessControl.ts b/integration_test/lib/helpers/accessControl.ts new file mode 100644 index 0000000..0303259 --- /dev/null +++ b/integration_test/lib/helpers/accessControl.ts @@ -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; +} diff --git a/integration_test/tests/0-common/comon.spec.ts b/integration_test/tests/0-common/comon.spec.ts index 785ad44..9b8adfd 100644 --- a/integration_test/tests/0-common/comon.spec.ts +++ b/integration_test/tests/0-common/comon.spec.ts @@ -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'; @@ -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 diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index 3c531a6..1f526d7 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts @@ -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'); diff --git a/integration_test/tests/5-access-control-testing/access-control.spec.ts b/integration_test/tests/5-access-control-testing/accessControl.spec.ts similarity index 63% rename from integration_test/tests/5-access-control-testing/access-control.spec.ts rename to integration_test/tests/5-access-control-testing/accessControl.spec.ts index 9786b88..80b45f9 100644 --- a/integration_test/tests/5-access-control-testing/access-control.spec.ts +++ b/integration_test/tests/5-access-control-testing/accessControl.spec.ts @@ -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', () => {