diff --git a/integration_test/lib/pages/representativesPage.ts b/integration_test/lib/pages/representativesPage.ts index 320b757..4ef5c14 100644 --- a/integration_test/lib/pages/representativesPage.ts +++ b/integration_test/lib/pages/representativesPage.ts @@ -27,7 +27,7 @@ export default class RepresentativesPage { stake_address: string ): Promise { await this.goto(); - await this.editUserProfileBtn.isVisible(); + await expect(this.editUserProfileBtn).toBeVisible({ timeout: 30_000 }); await this.editUserProfileBtn.click(); await this.page .getByRole('textbox') @@ -40,7 +40,7 @@ export default class RepresentativesPage { async isRepresentativeUpdated(infos: Array): Promise { await expect(this.page.getByText(representativeUpdatedToast)).toBeVisible(); - await this.editUserProfileBtn.isVisible(); + await expect(this.editUserProfileBtn).toBeVisible({ timeout: 30_000 }); await Promise.all( infos.map( async (info) => diff --git a/integration_test/tests/0-common/comon.spec.ts b/integration_test/tests/0-common/comon.spec.ts index 1074e9d..295f8ae 100644 --- a/integration_test/tests/0-common/comon.spec.ts +++ b/integration_test/tests/0-common/comon.spec.ts @@ -153,8 +153,8 @@ test.describe('Polls', () => { await expect(pollPageStatusChip).toBeVisible(); await expect(page.getByTestId('results-yes')).toBeVisible(); - await page.getByTestId('results-no').isVisible(); - await page.getByTestId('results-abstain').isVisible(); + await expect(page.getByTestId('results-no')).toBeVisible(); + await expect(page.getByTestId('results-abstain')).toBeVisible(); await page.goto(`/polls/${pollId}`); const yesCount = page.getByTestId('yes-count'); diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index 8a106b9..311bda5 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts @@ -365,9 +365,10 @@ 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('1-2A. Given connected as CO can update all fields of user', async ({ + test('1-2A-1. Given connected as CO can update all fields of user', async ({ page, }) => { + test.slow(); // delete exisiting opened polls const homePage = new HomePage(page); await homePage.goto(); @@ -387,6 +388,52 @@ test.describe('User Control', () => { ]); }); + test('1-2A-2. CO cannot update representative email with existing email', async ({ + page, + }) => { + test.slow(); + // delete exisiting opened polls + const homePage = new HomePage(page); + await homePage.goto(); + await homePage.deleteOpenPollCards(); + + // Update representative email with existing email + const name = faker.person.lastName(); + const email = 'alternate12@email.com'; + const stake_address = faker.person.jobArea(); + const represntativePage = new RepresentativesPage(page); + + // Update representative profile + await represntativePage.updateUserProfile(name, email, stake_address); + + // Assert error toast msg + await expect(page.getByRole('status')).toBeVisible(); + await expect(page.getByRole('status')).toHaveText('Error updating user.'); + }); + + test('1-2A-3. CO cannot update representative stake with existing stake', async ({ + page, + }) => { + test.slow(); + // delete exisiting opened polls + const homePage = new HomePage(page); + await homePage.goto(); + await homePage.deleteOpenPollCards(); + + // Update representative stake address with existing stake address + const name = faker.person.lastName(); + const email = name + '@email.com'; + const stake_address = organizerWallets[0].stakeAddress; + const represntativePage = new RepresentativesPage(page); + + // Update representative profile + await represntativePage.updateUserProfile(name, email, stake_address); + + // Assert error toast msg + await expect(page.getByRole('status')).toBeVisible(); + await expect(page.getByRole('status')).toHaveText('Error updating user.'); + }); + /** * Description: The table displaying delegates and workshops should follow a default sorting methodology so that it is easy for users to see what is included. * @@ -632,7 +679,7 @@ test.describe('Voting Power', () => { const voterPollPage = new PollPage(activeVoterPage); await voterPollPage.goto(pollId); await voterPollPage.voteYesBtn.click(); - await activeVoterPage.getByText('Vote recorded').isVisible(); + await expect(activeVoterPage.getByText('Vote recorded')).toBeVisible(); // Assert vote await expect(activeVoterPage.getByText('Vote recorded')).toBeVisible({ diff --git a/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts b/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts index 945f6c1..edc2f0b 100644 --- a/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts +++ b/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts @@ -123,6 +123,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(`${index + 2}-1C. Given active ${user}, and poll is open, can update casted vote`, async () => { + test.slow(); // yes vote await pollPage.voteYesBtn.click(); await expect(userPage.getByTestId('poll-page-vote-count')).toHaveText( @@ -145,6 +146,7 @@ test.describe('Vote', () => { */ test(`${index + 2}-1F. Given active ${user}, can see what they have voted`, async () => { + test.slow(); // yes vote await pollPage.voteYesBtn.click(); await expect(userPage.getByTestId('vote-status')).toHaveText('YES', { @@ -161,6 +163,7 @@ test.describe('Vote', () => { */ test(`${index + 2}-1D. Given active ${user}, can choose not to vote`, async () => { + test.slow(); await pollPage.voteAbstainBtn.click(); await expect(userPage.getByTestId('vote-status')).toHaveText( @@ -181,6 +184,7 @@ test.describe('Vote', () => { */ test(`${index + 2}-1E: Active ${user} should be able to vote Yes, No, or Abstain on a poll`, async () => { + test.slow(); // yes vote await pollPage.voteYesBtn.click(); await expect(userPage.getByTestId('vote-status')).toHaveText('YES'); @@ -275,7 +279,6 @@ test.describe('Representative Status', () => { test(`${index + 2}-1G. Once login ${user} should be able to know their voting right status`, async ({ browser, }) => { - test.slow(); const delegatePage = await newDelegatePage(browser, 3); const alternatePage = await newAlternatePage(browser, 3); @@ -284,28 +287,22 @@ test.describe('Representative Status', () => { await Promise.all( pages.map(async (page) => { await page.goto('/'); - await expect( - page.locator('[data-testid^="active-voter-name-"]').first() - ).toBeVisible(); - const activeVoter = ( - await page - .locator('[data-testid^="active-voter-name-"]') - .allInnerTexts() - )[4]; - console.log('active voter: ', activeVoter); - const delegateName = ( - await page - .locator('[data-testid^="delegate-name-"]') - .allInnerTexts() - )[4]; - const alternateName = ( - await page - .locator('[data-testid^="alternate-name-"]') - .allInnerTexts() - )[4]; - - // Assert active voter is among the delegate and alternate - expect([delegateName, alternateName]).toContain(activeVoter); + await expect(page.locator('[data-id="5"]').first()).toBeVisible({ + timeout: 10_000, + }); + + // Fetch representative list of workshop 5 + const representativeList = await page + .locator('[data-id="5"]') + .allInnerTexts(); + const [workshop, delegate, alternate, active_voter] = + representativeList[0].split('\n\n'); + + // Assert workshop name + expect(workshop).toBe('Workshop 05'); + + // Assert active voter value to be in between delegate and alternate + expect([delegate, alternate]).toContain(active_voter); }) ); });