Skip to content

Commit

Permalink
refactor: voting test ,update auth page and switching workshop id
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerose committed Nov 18, 2024
1 parent 0cdd7f5 commit 4772538
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { setAllureEpic } from '@helpers/allure';
import { test } from '@fixtures/poll';
import PollPage from '@pages/pollPage';
import { expect, Page } from '@playwright/test';
import { Browser, expect, Page } from '@playwright/test';
import RepresentativesPage from '@pages/representativesPage';
import {
newAlternate1Page,
newDelegate1Page,
newOrganizer1Page,
newAlternatePage,
newDelegatePage,
newOrganizerPage,
} from '@helpers/page';
import { upperCaseFirstLetter } from '@helpers/string';

Expand All @@ -20,7 +20,7 @@ const switchVotingPowerAndBeginPoll = async (
await representativePage.goto();
const activeUser = await representativePage.getActiveVoterStatus();
if (activeUser.toLowerCase() !== user) {
await representativePage.switchVotingPower(1);
await representativePage.switchVotingPower(5);
}

if (!isPendingPoll) {
Expand All @@ -43,10 +43,23 @@ const revertVotingPower = async (
await representativePage.goto();
const activeUser = await representativePage.getActiveVoterStatus();
if (activeUser.toLowerCase() === 'alternate') {
await representativePage.switchVotingPower(1);
await representativePage.switchVotingPower(5);
}
};

const userNavigateToPollPage = async (
user: string,
browser: Browser,
pollId: number
) => {
const userPage =
user === 'delegate'
? await newDelegatePage(browser, 3)
: await newAlternatePage(browser, 3);
const pollPage = new PollPage(userPage);
await pollPage.goto(pollId);
};

test.describe('Vote', () => {
test.use({
pollType: 'CreatePollWithoutTeardown',
Expand All @@ -70,15 +83,10 @@ test.describe('Vote', () => {
);

currentPollId = pollId;
organizerPage = await newOrganizer1Page(browser);
organizerPage = await newOrganizerPage(browser, 0);
await switchVotingPowerAndBeginPoll(user, organizerPage, pollId);

userPage =
user === 'delegate'
? await newDelegate1Page(browser)
: await newAlternate1Page(browser);
pollPage = new PollPage(userPage);
await pollPage.goto(pollId);
await userNavigateToPollPage(user, browser, pollId);
});

/**
Expand Down Expand Up @@ -188,20 +196,15 @@ test.describe('Vote', () => {
);

currentPollId = pollId;
organizerPage = await newOrganizer1Page(browser);
organizerPage = await newOrganizerPage(browser, 0);
await switchVotingPowerAndBeginPoll(
user,
organizerPage,
pollId,
true
);

userPage =
user === 'delegate'
? await newDelegate1Page(browser)
: await newAlternate1Page(browser);
pollPage = new PollPage(userPage);
await pollPage.goto(pollId);
await userNavigateToPollPage(user, browser, pollId);
});

/**
Expand Down

0 comments on commit 4772538

Please sign in to comment.