diff --git a/integration_test/lib/pages/homePage.ts b/integration_test/lib/pages/homePage.ts index 4b2fa65..527133f 100644 --- a/integration_test/lib/pages/homePage.ts +++ b/integration_test/lib/pages/homePage.ts @@ -29,7 +29,7 @@ export default class HomePage { } async createPoll( - pollName = faker.commerce.productName(), + pollName = faker.commerce.productName() || 'default', pollDescription = faker.commerce.productDescription() ): Promise { await this.createPollBtn.click(); diff --git a/integration_test/lib/pages/pollPage.ts b/integration_test/lib/pages/pollPage.ts index 37287ab..a26b5b2 100644 --- a/integration_test/lib/pages/pollPage.ts +++ b/integration_test/lib/pages/pollPage.ts @@ -1,13 +1,19 @@ import { Page } from '@playwright/test'; export default class PollPage { + //btn readonly createPollBtn = this.page.getByTestId('create-poll-button'); readonly beginVoteBtn = this.page.getByTestId('begin-vote-button'); + readonly closeVoteBtn = this.page.getByTestId('end-vote-button'); readonly deletePollBtn = this.page.getByTestId('DeleteRoundedIcon'); readonly voteYesBtn = this.page.getByTestId('vote-yes-button'); readonly voteNoBtn = this.page.getByTestId('vote-no-button'); readonly voteAbstainBtn = this.page.getByTestId('vote-abstain-button'); + //chip or icon + readonly pollPageStatusChip = this.page.getByTestId('poll-page-status-chip'); + readonly voteYesIcon = this.page.getByTestId('ThumbUpOutlinedIcon'); + constructor(private readonly page: Page) {} async goto(pollId: number): Promise { diff --git a/integration_test/lib/pages/representativesPage.ts b/integration_test/lib/pages/representativesPage.ts index 5ce5dd1..92450e0 100644 --- a/integration_test/lib/pages/representativesPage.ts +++ b/integration_test/lib/pages/representativesPage.ts @@ -62,4 +62,25 @@ export default class RepresentativesPage { .click({ force: true }); await this.saveUpdatedVotingPowerBtn.click(); } + + async assertSwitchedVotingPower(): Promise { + await expect(this.page.getByRole('row').first()).toBeVisible(); + const activeVoterRole = await this.page + .locator('[data-id="1"]') + .locator('[data-field="active_voter_id"]') + .innerText(); + const changedRow = await this.page + .locator('[data-id="1"]') + .filter({ has: this.page.getByTestId('edit-active-voter-1') }) + .allInnerTexts(); + const changedRowData = changedRow[0].split('\n\n'); + const activeVoter = + activeVoterRole === 'Delegate' ? changedRowData[1] : changedRowData[2]; + await this.page.goto('/'); + const activeVoterNamme = await this.page + .locator('[data-id="1"]') + .locator('[data-field="active_voter"]') + .innerText(); + expect(activeVoterNamme).toBe(activeVoter); + } }