Skip to content

Commit

Permalink
Update "switch voting power"
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Nov 15, 2024
1 parent 2afb445 commit 08677da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion integration_test/lib/pages/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class HomePage {
}

async createPoll(
pollName = faker.commerce.productName(),
pollName = faker.commerce.productName() || 'default',
pollDescription = faker.commerce.productDescription()
): Promise<number> {
await this.createPollBtn.click();
Expand Down
6 changes: 6 additions & 0 deletions integration_test/lib/pages/pollPage.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
Expand Down
21 changes: 21 additions & 0 deletions integration_test/lib/pages/representativesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,25 @@ export default class RepresentativesPage {
.click({ force: true });
await this.saveUpdatedVotingPowerBtn.click();
}

async assertSwitchedVotingPower(): Promise<void> {
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);
}
}

0 comments on commit 08677da

Please sign in to comment.