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..1074e9d 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'; @@ -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'); @@ -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?' })); }); }); 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', () => { diff --git a/package-lock.json b/package-lock.json index ea3dfb3..878f3fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15634,6 +15634,126 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.15.tgz", + "integrity": "sha512-5TGyjFcf8ampZP3e+FyCax5zFVHi+Oe7sZyaKOngsqyaNEpOgkKB3sqmymkZfowy3ufGA/tUgDPPxpQx931lHg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.15.tgz", + "integrity": "sha512-3Bwv4oc08ONiQ3FiOLKT72Q+ndEMyLNsc/D3qnLMbtUYTQAmkx9E/JRu0DBpHxNddBmNT5hxz1mYBphJ3mfrrw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.15.tgz", + "integrity": "sha512-k5xf/tg1FBv/M4CMd8S+JL3uV9BnnRmoe7F+GWC3DxkTCD9aewFRH1s5rJ1zkzDa+Do4zyN8qD0N8c84Hu96FQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.15.tgz", + "integrity": "sha512-kE6q38hbrRbKEkkVn62reLXhThLRh6/TvgSP56GkFNhU22TbIrQDEMrO7j0IcQHcew2wfykq8lZyHFabz0oBrA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.15.tgz", + "integrity": "sha512-PZ5YE9ouy/IdO7QVJeIcyLn/Rc4ml9M2G4y3kCM9MNf1YKvFY4heg3pVa/jQbMro+tP6yc4G2o9LjAz1zxD7tQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.15.tgz", + "integrity": "sha512-2raR16703kBvYEQD9HNLyb0/394yfqzmIeyp2nDzcPV4yPjqNUG3ohX6jX00WryXz6s1FXpVhsCo3i+g4RUX+g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.15.tgz", + "integrity": "sha512-fyTE8cklgkyR1p03kJa5zXEaZ9El+kDNM5A+66+8evQS5e/6v0Gk28LqA0Jet8gKSOyP+OTm/tJHzMlGdQerdQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.2.15", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.15.tgz", + "integrity": "sha512-SzqGbsLsP9OwKNUG9nekShTwhj6JSB9ZLMWQ8g1gG6hdE5gQLncbnbymrwy2yVmH9nikSLYRYxYMFu78Ggp7/g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } }