Skip to content

Commit

Permalink
Test: Fix testnet, format test code
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed Nov 17, 2024
1 parent f6320fc commit d6c0e41
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 160 deletions.
52 changes: 33 additions & 19 deletions integration_test/lib/fixtures/poll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import {delegateWallet, organizerWallet} from '@constants/staticWallets';
import { delegateWallet, organizerWallet } from '@constants/staticWallets';
import { test as base } from '@fixtures/walletExtension';
import {createNewPageWithWallet, newDelegate2Page, newDelegate3Page} from '@helpers/page';
import {
createNewPageWithWallet,
newDelegate2Page,
newDelegate3Page,
} from '@helpers/page';
import HomePage from '@pages/homePage';
import PollPage from '@pages/pollPage';
import {expect} from "@playwright/test";
import { expect } from '@playwright/test';

type pollEnableType = 'CreatePoll' | 'CreateAndBeginPoll' | 'NoAction' | 'VotedPoll';
type pollEnableType =
| 'CreatePoll'
| 'CreateAndBeginPoll'
| 'NoAction'
| 'VotedPoll';

type TestOptions = {
pollType: pollEnableType;
Expand Down Expand Up @@ -33,28 +41,35 @@ export const test = base.extend<TestOptions & { pollId: number }>({
if (pollType === 'CreateAndBeginPoll') {
await homePage.beginVoteBtn.click();
}
if(pollType === 'VotedPoll'){
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 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()
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();
}
}

Expand All @@ -67,5 +82,4 @@ export const test = base.extend<TestOptions & { pollId: number }>({
// await pollPage.deletePoll();
}
},

});
13 changes: 6 additions & 7 deletions integration_test/lib/helpers/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { importWallet } from '@fixtures/importWallet';
import loadDemosExtension from '@fixtures/loadExtension';
import { Browser, Page } from '@playwright/test';
import { StaticWallet } from '@types';
import {delegate2Wallet, delegateWallet} from "@constants/staticWallets";
import { delegate2Wallet, delegateWallet } from '@constants/staticWallets';

interface NewPageConfig {
storageState?: string;
Expand Down Expand Up @@ -32,36 +32,35 @@ export async function createNewPageWithWallet(
return newPage;
}

export async function newDelegatePage(browser){
export async function newDelegatePage(browser) {
return await createNewPageWithWallet(browser, {
storageState: '.auth/delegate2.json',
wallet: delegate2Wallet,
});
}
export async function newDelegate2Page(browser){
export async function newDelegate2Page(browser) {
return await createNewPageWithWallet(browser, {
storageState: '.auth/delegate2.json',
wallet: delegate2Wallet,
});
}
export async function newAlternate2Page(browser){
export async function newAlternate2Page(browser) {
return await createNewPageWithWallet(browser, {
storageState: '.auth/alternate2.json',
wallet: delegate2Wallet,
});
}

export async function newDelegate3Page(browser){
export async function newDelegate3Page(browser) {
return await createNewPageWithWallet(browser, {
storageState: '.auth/delegate3.json',
wallet: delegate2Wallet,
});
}

export async function newAlternate3Page(browser){
export async function newAlternate3Page(browser) {
return await createNewPageWithWallet(browser, {
storageState: '.auth/alternate3.json',
wallet: delegate2Wallet,
});
}

6 changes: 3 additions & 3 deletions integration_test/lib/pages/pollPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class PollPage {
readonly voteYesBtn = this.page.getByTestId('vote-yes-button');
readonly voteNoBtn = this.page.getByTestId('vote-no-button');
readonly voteAbstainBtn = this.page.getByTestId('vote-abstain-button');
readonly endVotingBtn = this.page.getByTestId('end-vote-button')
readonly endVotingBtn = this.page.getByTestId('end-vote-button');

//chip or icon
readonly pollPageStatusChip = this.page.getByTestId('poll-page-status-chip');
Expand All @@ -24,7 +24,7 @@ export default class PollPage {
async deletePoll(): Promise<void> {
await this.deletePollBtn.click();
}
async endVoting(){
await this.endVotingBtn.click()
async endVoting() {
await this.endVotingBtn.click();
}
}
Loading

0 comments on commit d6c0e41

Please sign in to comment.