From 6f5399b3774ec02b005f8c1f47800ed508be0392 Mon Sep 17 00:00:00 2001 From: Sital999 Date: Fri, 15 Nov 2024 11:27:43 +0545 Subject: [PATCH] Test case for Closing an open poll Given connected as CO can close an open poll --- integration_test/lib/pages/homePage.ts | 2 +- .../conventionOrganizer.spec.ts | 102 ++++++++++-------- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/integration_test/lib/pages/homePage.ts b/integration_test/lib/pages/homePage.ts index 46bbaf3..1195015 100644 --- a/integration_test/lib/pages/homePage.ts +++ b/integration_test/lib/pages/homePage.ts @@ -43,7 +43,7 @@ export default class HomePage { } async deleteOpenPollCards() { - await this.page.waitForTimeout(2_000); + await this.page.waitForTimeout(1_000); const pollCards = await this.pollCard.all(); if (pollCards.length > 0) { for (const pollCard of pollCards) { diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index e2cc905..f719529 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts @@ -6,16 +6,13 @@ import RepresentativesPage from '@pages/representativesPage'; import HomePage from '@pages/homePage'; import { faker } from '@faker-js/faker'; - test.beforeEach(async () => { await setAllureEpic('1. Convention Organizers'); }); test.use({ storageState: '.auth/organizer.json', wallet: organizerWallet }); - test.describe('Polls', () => { - /** * Description * The Convention Voting Tool (CVT) recognises a Convention Organiser (CO) @@ -26,7 +23,9 @@ test.describe('Polls', () => { * 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 ({ page }) => { + test('11A. Given connected as CO can see create poll button', async ({ + page, + }) => { await page.goto('/'); const CreatePollButton = page.getByTestId('create-poll-button').first(); await expect(CreatePollButton).toBeVisible(); @@ -42,17 +41,20 @@ test.describe('Polls', () => { * 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 ({ page, browser }) => { - await page.goto('/'); - const homePage = new HomePage(page); - const pollName = faker.commerce.productName(); - const pollDescription = faker.commerce.productDescription(); - await homePage.createPoll(pollName, pollDescription); - - await expect(page.getByText(pollName)).toBeVisible(); - await expect( - page.getByTestId('poll-status-chip').getByText('Pending') - ).toBeVisible(); + test('11B. Given connected as CO can create a new poll', async ({ + page, + browser, + }) => { + await page.goto('/'); + const homePage = new HomePage(page); + const pollName = faker.commerce.productName(); + const pollDescription = faker.commerce.productDescription(); + await homePage.createPoll(pollName, pollDescription); + + await expect(page.getByText(pollName)).toBeVisible(); + await expect( + page.getByTestId('poll-status-chip').getByText('Pending') + ).toBeVisible(); }); /** @@ -62,15 +64,20 @@ test.describe('Polls', () => { * * 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 ({ page, browser }) => { - await page.goto('/'); - const homePage = new HomePage(page); - await homePage.deleteOpenPollCards(); + test('11C. Given connected as CO can open poll', async ({ + page, + browser, + }) => { + test.slow(); + await page.goto('/'); + const homePage = new HomePage(page); + await homePage.deleteOpenPollCards(); - await homePage.createPoll(); - await page.getByTestId('begin-vote-button').click(); + await homePage.createPoll(); + await page.getByTestId('begin-vote-button').click(); - await expect(page.getByText('Poll voting is open!')).toBeVisible(); + await expect(page.getByText('Poll voting is open!')).toBeVisible(); + await expect(page.getByTestId('end-vote-button')).toBeVisible(); }); /** * Description: If a poll is open then a CO can close it @@ -79,9 +86,17 @@ test.describe('Polls', () => { * * 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 ({ page, browser }) => { - throw new Error("Not Implemented") - + test('11D. Given connected as CO can close an open poll', async ({ + page, + browser, + }) => { + await page.goto('/'); + const votingPollCard = page + .getByTestId('poll-status-chip') + .getByText('Voting', { exact: true }); + await votingPollCard.click(); + await page.getByTestId('end-vote-button').click(); + await expect(page.getByTestId('results-yes')).toBeVisible(); }); /** * Description: Once a poll has been closed to voting it cannot be re-opened, and no further votes will be accepted. @@ -90,9 +105,11 @@ test.describe('Polls', () => { * * 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 ({ page, browser }) => { - throw new Error("Not Implemented") - + test('11E. Given connected as CO cannot re-open closed poll', async ({ + page, + browser, + }) => { + throw new Error('Not Implemented'); }); /** @@ -102,14 +119,14 @@ test.describe('Polls', () => { * * Acceptance Criteria: Given that I am a CO on the page of a given poll, when I press the delete button I will be asked in a modal if I am sure, then if I confirm that I want to delete, then the poll will be deleted. */ - test('11F. Given connected as CO, can delete a poll', async ({ page, browser }) => { - throw new Error("Not Implemented") - + test('11F. Given connected as CO, can delete a poll', async ({ + page, + browser, + }) => { + throw new Error('Not Implemented'); }); }); - - test.describe('User Control', () => { /** * Description: A CO can update individual fields in the information held on a given user of the CVT @@ -119,11 +136,13 @@ 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 ({ page, browser }) => { - throw new Error("Not Implemented") + test('12A. Given connected as CO can update all fields of user', async ({ + page, + browser, + }) => { + throw new Error('Not Implemented'); }); - /** * Description: If a delegate is unable to vote then their alternate needs to be given voting rights, and if they become able to vote again, then the voting rights need to be able to be returned. * @@ -132,8 +151,8 @@ 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 ({ - page, - }) => { + page, + }) => { const representativePage = new RepresentativesPage(page); await representativePage.switchVotingPower(); await expect(page.getByText('Active voter updated!')).toBeVisible(); @@ -177,17 +196,17 @@ 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 ({ page }) => { + test('1-Org-Invite: 9. Convention organisers can update delegate profile information ', async ({ + page, + }) => { const represntativePage = new RepresentativesPage(page); await represntativePage.updateDelegateProfile(); await represntativePage.isRepresentativeUpdated(); await represntativePage.updateAlternateProfile(); await represntativePage.isRepresentativeUpdated(); }); - }); - test.describe('Voting Power', () => { test('1D. Should be able to switch active voting power between delegate and alternate.', async ({ page, @@ -204,5 +223,4 @@ test.describe('Voting Power', () => { await representativePage.switchVotingPower(); await expect(page.getByText('Active voter updated!')).toBeVisible(); }); - });