-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: Refactor test names, add vote setup
- Loading branch information
Showing
15 changed files
with
300 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {delegateWallet, organizerWallet} from '@constants/staticWallets'; | ||
import { test as base } from '@fixtures/walletExtension'; | ||
import {createNewPageWithWallet, newDelegate2Page, newDelegate3Page} from '@helpers/page'; | ||
import HomePage from '@pages/homePage'; | ||
import PollPage from '@pages/pollPage'; | ||
import {expect} from "@playwright/test"; | ||
|
||
type pollEnableType = 'CreatePoll' | 'CreateAndBeginPoll' | 'NoAction' | 'VotedPoll'; | ||
|
||
type TestOptions = { | ||
pollType: pollEnableType; | ||
}; | ||
|
||
export const test = base.extend<TestOptions & { pollId: number }>({ | ||
pollType: ['NoAction', { option: true }], | ||
|
||
pollId: async ({ browser, pollType }, use) => { | ||
// setup | ||
const organizerPage = await createNewPageWithWallet(browser, { | ||
storageState: '.auth/organizer.json', | ||
wallet: organizerWallet, | ||
}); | ||
|
||
const homePage = new HomePage(organizerPage); | ||
await homePage.goto(); | ||
|
||
let pollId: number | undefined; | ||
|
||
if (pollType !== 'NoAction') { | ||
await homePage.deleteOpenPollCards(); | ||
pollId = await homePage.createPoll(); | ||
|
||
if (pollType === 'CreateAndBeginPoll') { | ||
await homePage.beginVoteBtn.click(); | ||
} | ||
if(pollType === 'VotedPoll'){ | ||
await homePage.beginVoteBtn.click(); | ||
|
||
const delegatePage = await createNewPageWithWallet(browser, { | ||
storageState: '.auth/delegate.json', | ||
wallet: delegateWallet, | ||
}); | ||
const delegate2Page= await newDelegate2Page(browser) | ||
const delegate3Page = await newDelegate3Page(browser) | ||
|
||
const votes=['vote-yes-button','vote-no-button','vote-abstain-button'] | ||
|
||
await Promise.all([delegatePage,delegate2Page,delegate3Page].map(async (userPage,index)=>{ | ||
const userPollPage = new PollPage(userPage); | ||
await userPollPage.goto(pollId); | ||
// cast vote | ||
await userPage.getByTestId(votes[index]).click() | ||
})) | ||
const pollPage=new PollPage(organizerPage) | ||
await pollPage.goto(pollId) | ||
await pollPage.endVoting() | ||
|
||
} | ||
} | ||
|
||
await use(pollId); | ||
|
||
// cleanup | ||
if (pollType !== 'NoAction') { | ||
const pollPage = new PollPage(organizerPage); | ||
await pollPage.goto(pollId); | ||
// await pollPage.deletePoll(); | ||
} | ||
}, | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.