Skip to content

Commit

Permalink
chore: fix page and workspace issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerose committed Nov 18, 2024
1 parent bc1d2dd commit 3ff4881
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const switchVotingPowerAndBeginPoll = async (
) => {
const representativePage = new RepresentativesPage(organizerPage);
await representativePage.goto();
const activeUser = await representativePage.getActiveVoterStatus();
const activeUser = await representativePage.getActiveVoterStatus(5);
if (activeUser.toLowerCase() !== user) {
await representativePage.switchVotingPower(5);
await organizerPage.waitForTimeout(10_000);
}

if (!isPendingPoll) {
Expand All @@ -41,23 +42,26 @@ const revertVotingPower = async (

const representativePage = new RepresentativesPage(organizerPage);
await representativePage.goto();
const activeUser = await representativePage.getActiveVoterStatus();
const activeUser = await representativePage.getActiveVoterStatus(5);
if (activeUser.toLowerCase() === 'alternate') {
await representativePage.switchVotingPower(5);
}
};

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

const pollPage = new PollPage(userPage);
await pollPage.goto(pollId);

return { pollPage, userPage };
};

test.describe('Vote', () => {
Expand Down Expand Up @@ -85,8 +89,11 @@ test.describe('Vote', () => {
currentPollId = pollId;
organizerPage = await newOrganizerPage(browser, 0);
await switchVotingPowerAndBeginPoll(user, organizerPage, pollId);

await userNavigateToPollPage(user, browser, pollId);
({ pollPage, userPage } = await setupUserAndPollPage(
user,
browser,
pollId
));
});

/**
Expand Down Expand Up @@ -115,7 +122,8 @@ test.describe('Vote', () => {
// yes vote
await pollPage.voteYesBtn.click();
await expect(userPage.getByTestId('poll-page-vote-count')).toHaveText(
'1 vote'
'1 vote',
{ timeout: 10_000 }
);

// change vote
Expand Down Expand Up @@ -201,7 +209,11 @@ test.describe('Vote', () => {
true
);

await userNavigateToPollPage(user, browser, pollId);
({ pollPage, userPage } = await setupUserAndPollPage(
user,
browser,
pollId
));
});

/**
Expand All @@ -217,7 +229,7 @@ test.describe('Vote', () => {
test(`${index + 2}-1B. Given active ${user} and the poll is pending, voting should be disallowed`, async () => {
await expect(
userPage.getByTestId('poll-page-status-chip').getByText('Pending')
).toBeVisible();
).toBeVisible({ timeout: 10_000 });
await expect(pollPage.voteYesBtn).not.toBeVisible();
await expect(pollPage.voteNoBtn).not.toBeVisible();
await expect(pollPage.voteAbstainBtn).not.toBeVisible();
Expand Down

0 comments on commit 3ff4881

Please sign in to comment.