From 484b8c697ed02cc6856283258f5689f24de17fa5 Mon Sep 17 00:00:00 2001 From: Sudip Bhattarai Date: Fri, 15 Nov 2024 21:25:46 +0545 Subject: [PATCH] Test: Refactor test names, add vote setup --- integration_test/lib/_mock/wallets.json | 48 +++++++++++++ .../lib/constants/staticWallets.ts | 6 ++ integration_test/lib/fixtures/organizer.ts | 46 ------------ integration_test/lib/fixtures/poll.ts | 71 +++++++++++++++++++ integration_test/lib/helpers/page.ts | 35 +++++++++ integration_test/lib/pages/pollPage.ts | 4 ++ integration_test/tests/0-common/comon.spec.ts | 57 +++++++++------ .../conventionOrganizer.spec.ts | 30 ++++---- .../constitutionalDelegate.spec.ts | 12 ++-- .../communityMembers.pollStatus.spec.ts | 2 +- .../walletConnect.independent.spec.ts | 4 +- integration_test/tests/auth.setup.ts | 46 +++++------- prisma/seed.ts | 54 ++++++++++++++ src/lib/helpers/getUser.ts | 1 + src/lib/helpers/getUserVotes.ts | 1 + 15 files changed, 300 insertions(+), 117 deletions(-) delete mode 100644 integration_test/lib/fixtures/organizer.ts create mode 100644 integration_test/lib/fixtures/poll.ts diff --git a/integration_test/lib/_mock/wallets.json b/integration_test/lib/_mock/wallets.json index fc14613..17dcf1a 100644 --- a/integration_test/lib/_mock/wallets.json +++ b/integration_test/lib/_mock/wallets.json @@ -40,5 +40,53 @@ }, "dRepId": "drep1zz0swwxzmwfezqz4r4fa3cqcss7hgftdy6tsfavwhf2pu7d95jj", "address": "addr_test1qzpxc66v0hk74h6fthnavvxjjgmujp6nkskyepzdh7x76wqsnurn3skmjwgsq4ga20vwqxyy846z2mfxjuz0tr462s0qw8jepc" + }, + { + "payment": { + "private": "7094d6db1dcb756c5ca16dd78bb2b40e2a7ab44b9e0f9ba045c30c936cd91d4b", + "public": "2dcab974058989926304d0f811a207db91e8a5494fab0630c546e30672424481", + "pkh": "46db8ae386f2d8811f3be359d00a10b94a9af41e5d6266b6b35e19de" + }, + "stake": { + "private": "f0b456be73948b0336ff1873e3abd6151540e632b76532535dddf63f67d91d4b", + "public": "e82dea6fbe5c866e8ae805a7d4c0824aac54daf5bff4c4224c76491ce63d42d7", + "pkh": "0cd61dcc68470aeb3f50de1a230460ab4982d81468dbd7ee94b0c814" + } + }, + { + "payment": { + "private": "90b8338b3bd7e0069b2a3d8650706117287cc78fbc1329ad2f337fb161d91d4b", + "public": "f54d08863799fa95eab57623160aecec6e47604321ca8160f6c84b2b713555de", + "pkh": "2df75661915f3cf560f98fb0c54e2530146433f18a0b388e428947d1" + }, + "stake": { + "private": "30eed77f86480ce26172e062fae8e7702db50f246ddc23089c77008160d91d4b", + "public": "a6ed4aa51b93523234776387010faca74669e08a0168b44d2dbdc525088f1b98", + "pkh": "3eb020543f2b97ee6baf14b5ce6754211803cd2f67a35ea5bf6427e5" + } + }, + { + "payment": { + "private": "80cdcfa96c29cc5313c63b2f0c8ce647d6b8376f911239330cc23dbe65d91d4b", + "public": "6de9805440e25a1f77a32bf5b56e4b2fe38ff5a64eae0a686342aecb779265f6", + "pkh": "183ade5a8d284a9d2ee3859394e58b1c61837280cc71fcad565ceea5" + }, + "stake": { + "private": "489f6ee7b556a171b8c8b6ddeee6927646c68f435ece2a7a265c616164d91d4b", + "public": "235208acfebcc3cf731908512f9e727cfc02462e05ab61c4d32f3b2564fec611", + "pkh": "a749bc9d6300c0aa57dd11851fbeb12ea9d8101f49ca4765f10de1a4" + } + }, + { + "payment": { + "private": "b8a45789046b4671b22d52f385286c9327be57f8146d4056a985ccce63d91d4b", + "public": "e3f8be942173004d6eccef7e572b741bbbb7d08228125cb54e3ee7701b86adab", + "pkh": "89f2b776a14d1b7bb9f3a470840e3c6ebe4f231b4333e46e2333d419" + }, + "stake": { + "private": "d809a1e7675450a2d20af2a0942562f059b7da3d36157ee28f34892f66d91d4b", + "public": "6bca2b86c77a170a96cbafa51c0f305cc5f72916762aa1d3b7968ced71979b0a", + "pkh": "8f3e346ff209f583a1409862f584361c18e0d39ff684b63409a924a3" + } } ] diff --git a/integration_test/lib/constants/staticWallets.ts b/integration_test/lib/constants/staticWallets.ts index c301b3f..81b11a9 100644 --- a/integration_test/lib/constants/staticWallets.ts +++ b/integration_test/lib/constants/staticWallets.ts @@ -6,3 +6,9 @@ export const organizerWallet = staticWallets[0]; export const delegateWallet = staticWallets[1]; export const alternateWallet = staticWallets[2]; + +export const delegate2Wallet = staticWallets[3]; +export const alternate2Wallet = staticWallets[4]; + +export const delegate3Wallet = staticWallets[5]; +export const alternate3Wallet = staticWallets[6]; diff --git a/integration_test/lib/fixtures/organizer.ts b/integration_test/lib/fixtures/organizer.ts deleted file mode 100644 index 8328b59..0000000 --- a/integration_test/lib/fixtures/organizer.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { organizerWallet } from '@constants/staticWallets'; -import { test as base } from '@fixtures/walletExtension'; -import { createNewPageWithWallet } from '@helpers/page'; -import HomePage from '@pages/homePage'; -import PollPage from '@pages/pollPage'; - -type pollEnableType = 'CreatePoll' | 'CreateAndBeginPoll' | 'NoAction'; - -type TestOptions = { - pollType: pollEnableType; -}; - -export const test = base.extend({ - pollType: ['NoAction', { option: true }], - - pollId: async ({ browser, pollType }, use) => { - // setup - const organizerPage = await createNewPageWithWallet(browser, { - storageState: '.auth/organizer.json', - wallet: organizerWallet, - }); - - const homePage = new HomePage(organizerPage); - await homePage.goto(); - - let pollId: number | undefined; - - if (pollType !== 'NoAction') { - await homePage.deleteOpenPollCards(); - pollId = await homePage.createPoll(); - - if (pollType === 'CreateAndBeginPoll') { - await homePage.beginVoteBtn.click(); - } - } - - await use(pollId); - - // cleanup - if (pollType !== 'NoAction') { - const pollPage = new PollPage(organizerPage); - await pollPage.goto(pollId); - await pollPage.deletePoll(); - } - }, -}); diff --git a/integration_test/lib/fixtures/poll.ts b/integration_test/lib/fixtures/poll.ts new file mode 100644 index 0000000..6eecdca --- /dev/null +++ b/integration_test/lib/fixtures/poll.ts @@ -0,0 +1,71 @@ +import {delegateWallet, organizerWallet} from '@constants/staticWallets'; +import { test as base } from '@fixtures/walletExtension'; +import {createNewPageWithWallet, newDelegate2Page, newDelegate3Page} from '@helpers/page'; +import HomePage from '@pages/homePage'; +import PollPage from '@pages/pollPage'; +import {expect} from "@playwright/test"; + +type pollEnableType = 'CreatePoll' | 'CreateAndBeginPoll' | 'NoAction' | 'VotedPoll'; + +type TestOptions = { + pollType: pollEnableType; +}; + +export const test = base.extend({ + pollType: ['NoAction', { option: true }], + + pollId: async ({ browser, pollType }, use) => { + // setup + const organizerPage = await createNewPageWithWallet(browser, { + storageState: '.auth/organizer.json', + wallet: organizerWallet, + }); + + const homePage = new HomePage(organizerPage); + await homePage.goto(); + + let pollId: number | undefined; + + if (pollType !== 'NoAction') { + await homePage.deleteOpenPollCards(); + pollId = await homePage.createPoll(); + + if (pollType === 'CreateAndBeginPoll') { + await homePage.beginVoteBtn.click(); + } + if(pollType === 'VotedPoll'){ + await homePage.beginVoteBtn.click(); + + const delegatePage = await createNewPageWithWallet(browser, { + storageState: '.auth/delegate.json', + wallet: delegateWallet, + }); + const delegate2Page= await newDelegate2Page(browser) + const delegate3Page = await newDelegate3Page(browser) + + const votes=['vote-yes-button','vote-no-button','vote-abstain-button'] + + await Promise.all([delegatePage,delegate2Page,delegate3Page].map(async (userPage,index)=>{ + const userPollPage = new PollPage(userPage); + await userPollPage.goto(pollId); + // cast vote + await userPage.getByTestId(votes[index]).click() + })) + const pollPage=new PollPage(organizerPage) + await pollPage.goto(pollId) + await pollPage.endVoting() + + } + } + + await use(pollId); + + // cleanup + if (pollType !== 'NoAction') { + const pollPage = new PollPage(organizerPage); + await pollPage.goto(pollId); + // await pollPage.deletePoll(); + } + }, + +}); diff --git a/integration_test/lib/helpers/page.ts b/integration_test/lib/helpers/page.ts index 6de31f9..a7a3cb2 100644 --- a/integration_test/lib/helpers/page.ts +++ b/integration_test/lib/helpers/page.ts @@ -2,6 +2,7 @@ import { importWallet } from '@fixtures/importWallet'; import loadDemosExtension from '@fixtures/loadExtension'; import { Browser, Page } from '@playwright/test'; import { StaticWallet } from '@types'; +import {delegate2Wallet, delegateWallet} from "@constants/staticWallets"; interface NewPageConfig { storageState?: string; @@ -30,3 +31,37 @@ export async function createNewPageWithWallet( return newPage; } + +export async function newDelegatePage(browser){ + return await createNewPageWithWallet(browser, { + storageState: '.auth/delegate2.json', + wallet: delegate2Wallet, + }); +} +export async function newDelegate2Page(browser){ + return await createNewPageWithWallet(browser, { + storageState: '.auth/delegate2.json', + wallet: delegate2Wallet, + }); +} +export async function newAlternate2Page(browser){ + return await createNewPageWithWallet(browser, { + storageState: '.auth/alternate2.json', + wallet: delegate2Wallet, + }); +} + +export async function newDelegate3Page(browser){ + return await createNewPageWithWallet(browser, { + storageState: '.auth/delegate3.json', + wallet: delegate2Wallet, + }); +} + +export async function newAlternate3Page(browser){ + return await createNewPageWithWallet(browser, { + storageState: '.auth/alternate3.json', + wallet: delegate2Wallet, + }); +} + diff --git a/integration_test/lib/pages/pollPage.ts b/integration_test/lib/pages/pollPage.ts index a26b5b2..8fafd21 100644 --- a/integration_test/lib/pages/pollPage.ts +++ b/integration_test/lib/pages/pollPage.ts @@ -9,6 +9,7 @@ export default class PollPage { readonly voteYesBtn = this.page.getByTestId('vote-yes-button'); readonly voteNoBtn = this.page.getByTestId('vote-no-button'); readonly voteAbstainBtn = this.page.getByTestId('vote-abstain-button'); + readonly endVotingBtn = this.page.getByTestId('end-vote-button') //chip or icon readonly pollPageStatusChip = this.page.getByTestId('poll-page-status-chip'); @@ -23,4 +24,7 @@ export default class PollPage { async deletePoll(): Promise { await this.deletePollBtn.click(); } + async endVoting(){ + await this.endVotingBtn.click() + } } diff --git a/integration_test/tests/0-common/comon.spec.ts b/integration_test/tests/0-common/comon.spec.ts index eee2f6f..63fee8c 100644 --- a/integration_test/tests/0-common/comon.spec.ts +++ b/integration_test/tests/0-common/comon.spec.ts @@ -1,6 +1,6 @@ import { setAllureEpic } from '@helpers/allure'; import { expect } from '@playwright/test'; -import { test } from '@fixtures/organizer'; +import { test } from '@fixtures/poll'; @@ -8,12 +8,13 @@ test.beforeEach(async () => { await setAllureEpic('0. All Users'); }); -test.use({ - pollType: 'CreateAndBeginPoll', -});// test.describe('Polls', () => { + test.use({ + pollType: 'CreateAndBeginPoll', + });// + /** * Description: Anyone can see what stage in its lifecycle a poll is * @@ -21,7 +22,7 @@ test.describe('Polls', () => { * * Acceptance Criteria: Given that I am looking at a given poll, when I look at it, then I can see its status */ - test('01A. Given any user, can view poll status', async ({ page }) => { + test('0-1A-1. Given any user, can view poll status in home page', async ({ page,pollId }) => { await page.goto('/'); await page.waitForSelector('[data-testid^="poll-card-"]'); @@ -40,25 +41,24 @@ test.describe('Polls', () => { expect(['Concluded', 'Pending','Voting']).toContain(statusText); } - const randomIndex = Math.floor(Math.random() * pollCardCount); - const pollCard = pollCards.nth(randomIndex) - const pollCardTestId = await pollCard.getAttribute('data-testid'); - const pollId = pollCardTestId.split('-').pop(); - + }); + test('0-1A-2. Given any user, can view poll status in poll page', async ({page,pollId}) => { await page.goto(`/polls/${pollId}`); - const pollPageStatusChip = page.getByTestId('poll-page-status-chip'); await expect(pollPageStatusChip).toBeVisible(); const statusText = await pollPageStatusChip.textContent(); expect(['Concluded', 'Pending','Voting']).toContain(statusText); - }); - test('01B. Given any user, can view poll status', async ({page}) => { - throw new Error("Not Implemented") - }); + +}) +test.describe('Polls',()=>{ + test.use({ + pollType: 'VotedPoll', + });// + /** * Description: After a poll is closed the results of the poll should be displayed* * @@ -75,8 +75,25 @@ test.describe('Polls', () => { * * *results of a poll should never be displayed before the close of a poll */ - test('01C. Given any user, can view poll results', async ({page}) => { - throw new Error("Not Implemented") + test('0-1B. Given any user, can view poll results', async ({page,pollId,browser}) => { + await page.goto(`/polls/${pollId}`); + const pollPageStatusChip = page.getByTestId('poll-page-status-chip'); + await expect(pollPageStatusChip).toBeVisible(); + + await expect(page.getByTestId('results-yes')).toBeVisible() + await page.getByTestId('results-no').isVisible() + await page.getByTestId('results-abstain').isVisible() + await page.goto(`/polls/${pollId}`); + + const yesCount = page.getByTestId('yes-count'); + const noCount = page.getByTestId('no-count'); + const abstainCount = page.getByTestId('abstain-count'); + + // Assert the text content for each count + await expect(yesCount).toHaveText('1'); + await expect(noCount).toHaveText('1'); + await expect(abstainCount).toHaveText('1'); + }); /** @@ -101,13 +118,13 @@ test.describe('User profile', () => { * * Acceptance Criteria 2: Given that I am on the results page of a closed poll, when I press on the tile of a given voter, then I am taken to their profile page and can see their voting record */ - test('02A-1. Given Delegate or alternate profile page, can view voting hsitory', async ({page}) => { + test('0-2A-1. Given Delegate or alternate profile page, can view voting hsitory', async ({page}) => { throw new Error("Not Implemented") }); - test('02A-1. Can navigate to user profile from delegate/alternate listing page', async ({page}) => { + test('0-2A-1. Can navigate to user profile from delegate/alternate listing page', async ({page}) => { throw new Error("Not Implemented") }); - test('02A-1. Can navigate to user profile from voter view in poll results page', async ({page}) => { + test('0-2A-1. Can navigate to user profile from voter view in poll results page', async ({page}) => { throw new Error("Not Implemented") }); diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index d4cb803..0e06c58 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts @@ -1,7 +1,7 @@ import { organizerWallet } from '@constants/staticWallets'; import { setAllureEpic } from '@helpers/allure'; import { expect } from '@playwright/test'; -import { test } from '@fixtures/organizer'; +import { test } from '@fixtures/poll'; import RepresentativesPage from '@pages/representativesPage'; import HomePage from '@pages/homePage'; import { faker } from '@faker-js/faker'; @@ -31,7 +31,7 @@ test.describe('Delete Poll', async () => { await homePage.deleteOpenPollCards(); pollId = await homePage.createPoll(); }); - test('11F1. Given connected as CO, can delete a pending poll', async ({ + test('1-1F-1. Given connected as CO, can delete a pending poll', async ({ page, }) => { const pollPage = new PollPage(page); @@ -44,7 +44,7 @@ test.describe('Delete Poll', async () => { await expect(page).toHaveURL('/'); }); - test('11F2. Given connected as CO, can delete a ongoing poll', async ({ + test('1-1F-2. Given connected as CO, can delete a ongoing poll', async ({ page, }) => { const pollPage = new PollPage(page); @@ -61,7 +61,7 @@ test.describe('Delete Poll', async () => { await expect(page).toHaveURL('/'); }); - test('11F3. Given connected as CO, can delete a closed poll', async ({ + test('1-1F-3. Given connected as CO, can delete a closed poll', async ({ page, }) => { test.slow(); @@ -96,7 +96,7 @@ test.describe('Open Close Poll', () => { * * Acceptance Criteria: Given that I am a CO on the poll's page, and the poll is in 'pending' status, then when I click the "open poll" button then the poll is opened. */ - test('11C. Given connected as CO can open poll', async ({ + test('1-1C. Given connected as CO can open poll', async ({ page, pollId, }) => { @@ -115,7 +115,7 @@ test.describe('Open Close Poll', () => { * * Acceptance Criteria: Given that I am a CO on the page of a poll that is in "Open" status, when I click "Close Poll" then the poll is closed. */ - test('11D. Given connected as CO can close an open poll', async ({ + test('1-1D. Given connected as CO can close an open poll', async ({ page, pollId, }) => { @@ -137,7 +137,7 @@ test.describe('Open Close Poll', () => { * * Acceptance Criteria: Given that I am on the page of a closed poll, then there is no button or any other way for me to re-open it. */ - test('11E. Given connected as CO cannot re-open closed poll', async ({ + test('1-1E. Given connected as CO cannot re-open closed poll', async ({ page, pollId, }) => { @@ -168,7 +168,7 @@ test.describe('Create Poll', () => { * Acceptance Criteria * Given that I am a CO with my wallet connected, When I go to the homepage, Then I see the "create poll" button */ - test('11A. Given connected as CO can see create poll button', async ({ + test('1-1A. Given connected as CO can see create poll button', async ({ page, }) => { await page.goto('/'); @@ -186,7 +186,7 @@ test.describe('Create Poll', () => { * Acceptance Criteria * Given that I am a CO on the homepage with my wallet connected, when I click the "create poll" button, Then I will go to the create poll page */ - test('11B. Given connected as CO can create a new poll', async ({ + test('1-1B. Given connected as CO can create a new poll', async ({ page, browser, }) => { @@ -212,7 +212,7 @@ test.describe('User Control', () => { * Acceptance Criteria: Given that I am a CO on the page containing the list of user records, I can select the * record that I want to edit and modify the fields in that record as I see fit. */ - test('12A. Given connected as CO can update all fields of user', async ({ + test('1-2A. Given connected as CO can update all fields of user', async ({ page, browser, }) => { @@ -226,7 +226,7 @@ test.describe('User Control', () => { * * Acceptance Criteria: Given that I am a CO on the page listing all the delegates and alternates, when I toggle one of them to be the voter from a given workshop that one can vote, the other one from the workshop is not able to vote. */ - test('12B. Given connected as CO can switch delegate user to alternate or vice-versa', async ({ + test('1-2B-1. Given connected as CO can switch delegate user to alternate or vice-versa', async ({ page, }) => { const representativePage = new RepresentativesPage(page); @@ -236,7 +236,7 @@ test.describe('User Control', () => { // again switch and test. }); - test('12B. Should have corresponding workspace delegate and alternate in a same row', async ({ + test('1-2B-2. Should have corresponding workspace delegate and alternate in a same row', async ({ page, }) => { await page.goto('/'); @@ -253,7 +253,7 @@ test.describe('User Control', () => { expect(alternateList).toContain(alternate); }); - test('1O. Should have workspace_name ordered alphabetically', async ({ + test('1-2C. Should have workspace_name ordered alphabetically', async ({ page, }) => { const workspaceNames = []; @@ -272,7 +272,7 @@ test.describe('User Control', () => { ); }); // As a convention organiser, I want to be able to update the profile information of a delegate (or alternate) to correct any error or omission. - test('1-Org-Invite: 9. Convention organisers can update delegate profile information ', async ({ + test('1-2D. Convention organisers can update delegate profile information ', async ({ page, }) => { const represntativePage = new RepresentativesPage(page); @@ -284,7 +284,7 @@ test.describe('User Control', () => { }); test.describe('Voting Power', () => { - test('1D. Should be able to switch active voting power between delegate and alternate.', async ({ + test('1-3A. Should be able to switch active voting power between delegate and alternate.', async ({ page, }) => { const representativePage = new RepresentativesPage(page); diff --git a/integration_test/tests/2-constitutional-delegates/constitutionalDelegate.spec.ts b/integration_test/tests/2-constitutional-delegates/constitutionalDelegate.spec.ts index fd4a636..816d266 100644 --- a/integration_test/tests/2-constitutional-delegates/constitutionalDelegate.spec.ts +++ b/integration_test/tests/2-constitutional-delegates/constitutionalDelegate.spec.ts @@ -1,5 +1,5 @@ import { setAllureEpic } from '@helpers/allure'; -import { test } from '@fixtures/organizer'; +import { test } from '@fixtures/poll'; import { delegateWallet } from '@constants/staticWallets'; import PollPage from '@pages/pollPage'; import { expect } from '@playwright/test'; @@ -27,7 +27,7 @@ test.describe('Vote', () => { * * *conversely votes that are 'closed' or 'pending' do not give voters the option to vote. */ - test('21A. Given active delegate, and poll is open, then vote option should be visible', async ({ + test('2-1A. Given active delegate, and poll is open, then vote option should be visible', async ({ page, pollId, }) => { @@ -46,7 +46,7 @@ test.describe('Vote', () => { * * Acceptance Criteria: Given that I am a voter on the page of an open poll and I have already voted, when I vote again, then my vote is counted. */ - test('21C. Given active delegate, and poll is open, can update casted vote', async ({ + test('2-1C. Given active delegate, and poll is open, can update casted vote', async ({ page, pollId, }) => { @@ -71,7 +71,7 @@ test.describe('Vote', () => { * Acceptance Criteria: Given that I am a voter, when I choose not to vote, then there is no effect. */ - test('21D. Given active delegate, can choose not to vote', async ({ + test('2-1D. Given active delegate, can choose not to vote', async ({ page, pollId, }) => { @@ -91,7 +91,7 @@ test.describe('Vote', () => { * Acceptance Criteria: Given that I am a voter on the page of an open poll, when I press to vote either "yes", "no", or "abstain", then my the CVT sends a vote message to my wallet to be signed. */ - test('21E: Active Delegate Should Be Able to Vote Yes, No, or Abstain on a Poll', async ({ + test('2-1E: Active Delegate Should Be Able to Vote Yes, No, or Abstain on a Poll', async ({ page, pollId, }) => { @@ -130,7 +130,7 @@ test.describe('Vote', () => { * *conversely votes that are 'closed' or 'pending' do not give voters the option to vote. */ - test('21B. Given active delegate and the poll is pending, voting should be disallowed', async ({ + test('2-1B. Given active delegate and the poll is pending, voting should be disallowed', async ({ page, pollId, }) => { diff --git a/integration_test/tests/4-community-members/communityMembers.pollStatus.spec.ts b/integration_test/tests/4-community-members/communityMembers.pollStatus.spec.ts index 1fa883a..44e119c 100644 --- a/integration_test/tests/4-community-members/communityMembers.pollStatus.spec.ts +++ b/integration_test/tests/4-community-members/communityMembers.pollStatus.spec.ts @@ -7,7 +7,7 @@ test.beforeEach(async () => { }); test.describe('View Poll Status', () => { - test('4G. Must be able to view vote result and its count.', async ({ + test('4-1A. Must be able to view vote result and its count.', async ({ page, }) => { await page.goto('/'); diff --git a/integration_test/tests/5-wallet-connect/walletConnect.independent.spec.ts b/integration_test/tests/5-wallet-connect/walletConnect.independent.spec.ts index b926712..5d7c628 100644 --- a/integration_test/tests/5-wallet-connect/walletConnect.independent.spec.ts +++ b/integration_test/tests/5-wallet-connect/walletConnect.independent.spec.ts @@ -9,7 +9,7 @@ test.beforeEach(async () => { }); test.use({ wallet: organizerWallet }); -test('5A. Should connect wallet if stake key is registered', async ({ +test('5-1A. Should connect wallet if stake key is registered', async ({ page, }) => { const loginPage = new LoginPage(page); @@ -17,7 +17,7 @@ test('5A. Should connect wallet if stake key is registered', async ({ await loginPage.isLoggedIn(); }); -test('5B. Should disconnect Wallet When connected', async ({ page }) => { +test('5-1B. Should disconnect Wallet When connected', async ({ page }) => { const loginPage = new LoginPage(page); await loginPage.login(); diff --git a/integration_test/tests/auth.setup.ts b/integration_test/tests/auth.setup.ts index 7a0032f..b55badc 100644 --- a/integration_test/tests/auth.setup.ts +++ b/integration_test/tests/auth.setup.ts @@ -3,42 +3,34 @@ import { delegateWallet, organizerWallet, } from '@constants/staticWallets'; +import * as wallets from '@constants/staticWallets' import { test as setup } from '@fixtures/walletExtension'; import { setAllureEpic, setAllureStory } from '@helpers/allure'; import { createAuth } from '@helpers/auth'; -const organizerAuthFile = '.auth/organizer.json'; -const delegateAuthFile = '.auth/delegate.json'; -const alternateAuthFile = '.auth/alternate.json'; +const authConfigurations = [ + { wallet: organizerWallet, authFile: '.auth/organizer.json', role: 'Organizer' }, + { wallet: delegateWallet, authFile: '.auth/delegate.json', role: 'Delegate' }, + { wallet: alternateWallet, authFile: '.auth/alternate.json', role: 'Alternate' }, + { wallet: wallets.delegate2Wallet, authFile: '.auth/delegate2.json', role: 'Delegate2' }, + { wallet: wallets.alternate2Wallet, authFile: '.auth/alternate2.json', role: 'Alternate2' }, + { wallet: wallets.delegate3Wallet, authFile: '.auth/delegate3.json', role: 'Delegate3' }, + { wallet: wallets.alternate3Wallet, authFile: '.auth/alternate3.json', role: 'Alternate3' }, + +]; setup.beforeEach(async () => { await setAllureEpic('Setup'); await setAllureStory('Authentication'); }); -setup('Create organizer auth', async ({ page, context }) => { - await createAuth({ - page, - context, - wallet: organizerWallet, - auth: organizerAuthFile, - }); -}); - -setup('Create delegate auth', async ({ page, context }) => { - await createAuth({ - page, - context, - wallet: delegateWallet, - auth: delegateAuthFile, - }); -}); - -setup('Create alternate auth', async ({ page, context }) => { - await createAuth({ - page, - context, - wallet: alternateWallet, - auth: alternateAuthFile, +authConfigurations.forEach(({ wallet, authFile, role }) => { + setup(`Create ${role} auth`, async ({ page, context }) => { + await createAuth({ + page, + context, + wallet, + auth: authFile, + }); }); }); diff --git a/prisma/seed.ts b/prisma/seed.ts index 3d97428..a82f07c 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -7,6 +7,8 @@ const workshopLocations = [ { name: 'Singapore' }, { name: 'Convention Organizer' }, { name: 'Buenos Aires' }, + {name: 'Integration Test 1' }, + {name: 'Integration Test 2'} ]; const users = [ @@ -90,6 +92,46 @@ const users = [ wallet_address: 'stake_test1upzv3vmy37a0zk743vjfaexrxvnnv7fyhrdg5ncla6dknksjfxrpy', }, + { + is_convention_organizer: false, + is_delegate: true, + is_alternate: false, + workshop_id: BigInt(5), + name: 'Integration Delegate 1', + email: 'delegate1@integration.test', + wallet_address: + 'stake_test1uqxdv8wvdprs46el2r0p5gcyvz45nqkcz35dh4lwjjcvs9qltuf86', + }, + { + is_convention_organizer: false, + is_delegate: false, + is_alternate: true, + workshop_id: BigInt(5), + name: 'Integration Alternate 1', + email: 'alternate1@integration.test', + wallet_address: + 'stake_test1uqltqgz58u4e0mnt4u2ttnn82ss3sq7d9an6xh49hajz0egghy55y', + }, + { + is_convention_organizer: false, + is_delegate: true, + is_alternate: false, + workshop_id: BigInt(6), + name: 'Integration Delegate 2', + email: 'delegate2@integration.test', + wallet_address: + 'stake_test1uzn5n0yavvqvp2jhm5gc28a7kyh2nkqsrayu53m97yx7rfqk3qe0g', + }, + { + is_convention_organizer: false, + is_delegate: false, + is_alternate: true, + workshop_id: BigInt(6), + name: 'Integration Alternate 2', + email: 'alternate2@integration.test', + wallet_address: + 'stake_test1uz8nudr07gyltqapgzvx9avyxcwp3cxnnlmgfd35px5jfgcq2hezv', + }, ]; const workshopInfo = [ @@ -112,6 +154,18 @@ const workshopInfo = [ alternate_id: BigInt(7), active_vote_id: BigInt(8), }, + { + name: 'Integration Test 1', + delegate_id: BigInt(9), + alternate_id: BigInt(10), + active_vote_id: BigInt(9), + }, + { + name: 'Integration Test 2', + delegate_id: BigInt(11), + alternate_id: BigInt(12), + active_vote_id: BigInt(11), + }, ]; const seedDB = async (): Promise => { diff --git a/src/lib/helpers/getUser.ts b/src/lib/helpers/getUser.ts index 018fc4b..3794fb5 100644 --- a/src/lib/helpers/getUser.ts +++ b/src/lib/helpers/getUser.ts @@ -38,6 +38,7 @@ export async function getUser(userId: string | string[] | undefined): Promise<{ }; } } else { + console.log('UserI',userId); return { user: null, message: 'Invalid userId', diff --git a/src/lib/helpers/getUserVotes.ts b/src/lib/helpers/getUserVotes.ts index 4880f6a..b73c724 100644 --- a/src/lib/helpers/getUserVotes.ts +++ b/src/lib/helpers/getUserVotes.ts @@ -28,6 +28,7 @@ export async function getUserVotes( return { votes: [], message: data.message }; } } else { + console.log('UserId',userId); return { votes: [], message: 'Invalid userId' }; } } catch (error) {