Skip to content

Commit

Permalink
Test case for Closing an open poll
Browse files Browse the repository at this point in the history
Given connected as CO can close an open poll
  • Loading branch information
Sital999 committed Nov 15, 2024
1 parent b623eb7 commit 6f5399b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 43 deletions.
2 changes: 1 addition & 1 deletion integration_test/lib/pages/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand All @@ -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();
});

/**
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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');
});

/**
Expand All @@ -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
Expand All @@ -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.
*
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -204,5 +223,4 @@ test.describe('Voting Power', () => {
await representativePage.switchVotingPower();
await expect(page.getByText('Active voter updated!')).toBeVisible();
});

});

0 comments on commit 6f5399b

Please sign in to comment.