diff --git a/integration_test/lib/pages/homePage.ts b/integration_test/lib/pages/homePage.ts index c8be483..c0e699d 100644 --- a/integration_test/lib/pages/homePage.ts +++ b/integration_test/lib/pages/homePage.ts @@ -3,6 +3,7 @@ import { faker } from '@faker-js/faker'; import { extractPollIdFromUrl } from '@helpers/string'; import { blake } from 'libcardano'; import PollPage from './pollPage'; +import Logger from '@helpers/logger'; export default class HomePage { readonly heading = this.page.getByText( @@ -15,8 +16,8 @@ export default class HomePage { // input readonly pollNameInput = this.page.locator( - '[data-testid="poll-name-input"] input' - ); + '[data-testid="poll-name-input"] textarea' + ).first(); readonly constitutionLinkInput = this.page .locator('[data-testid="poll-link-input"] input') @@ -48,12 +49,17 @@ export default class HomePage { await this.submitPollBtn.click(); - await expect(this.page.getByText(pollName)).toBeVisible({ - timeout: 10_000, + await this.page.waitForURL(/\/polls\/(?!new)/, { + timeout: 10_000, }); - + const currentPageUrl = this.page.url(); - return extractPollIdFromUrl(currentPageUrl); + Logger.info("Current page Url: " + currentPageUrl); + + const pollId = extractPollIdFromUrl(currentPageUrl); + + // Return the extracted poll ID + return pollId; } async getOpenPollCard(): Promise { diff --git a/integration_test/lib/pages/loginPage.ts b/integration_test/lib/pages/loginPage.ts index cffd8c6..22b2b2e 100644 --- a/integration_test/lib/pages/loginPage.ts +++ b/integration_test/lib/pages/loginPage.ts @@ -15,9 +15,8 @@ export default class LoginPage { await this.goto(); await this.connectWalletBtn.first().click(); - await this.eternlWalletBtn.click({ force: false }); - await expect(this.page.getByText("Welcome")).toBeVisible() - + await this.eternlWalletBtn.click({ force: true }); + await expect(this.page.getByTestId('connected-user-name')).toBeVisible({timeout: 30000}) } async logout(): Promise { diff --git a/integration_test/lib/pages/pollPage.ts b/integration_test/lib/pages/pollPage.ts index 2fa9584..2700f0c 100644 --- a/integration_test/lib/pages/pollPage.ts +++ b/integration_test/lib/pages/pollPage.ts @@ -33,6 +33,9 @@ export default class PollPage { async deletePoll(): Promise { await this.deletePollBtn.click(); await this.deletePollConfirm.click(); + await this.page.waitForURL('/', { + timeout: 10_000, + }); } async endVoting() { diff --git a/integration_test/tests/voted-poll-setup.ts b/integration_test/tests/voted-poll-setup.ts index 54afa8a..0d364d2 100644 --- a/integration_test/tests/voted-poll-setup.ts +++ b/integration_test/tests/voted-poll-setup.ts @@ -6,6 +6,7 @@ import { import { importWallet, injectWalletExtension } from '@fixtures/importWallet'; import loadEternlExtension from '@fixtures/loadExtension'; import { setAllureEpic, setAllureStory } from '@helpers/allure'; +import Logger from '@helpers/logger'; import HomePage from '@pages/homePage'; import LoginPage from '@pages/loginPage'; import PollPage from '@pages/pollPage'; @@ -31,11 +32,10 @@ async function pageWithInjectedWallet(browser:Browser, wallet:StaticWallet): Pro const loginPage = new LoginPage(page); await loginPage.login(); - await sleep(2000) return page; } test(`Create Voted Poll`, async ({browser }) => { - test.slow() + test.setTimeout(300000) // let's set it to 5 minute const getPage=async (w:StaticWallet)=>await pageWithInjectedWallet(browser,w) @@ -60,10 +60,12 @@ test(`Create Voted Poll`, async ({browser }) => { let pollPage=new PollPage(page) await pollPage.goto(pollId) - const isActive = await pollPage.voteYesBtn.waitFor({state: "visible",timeout: 20000}).then(()=>true).catch(()=>false) + const isActive = await pollPage.voteYesBtn.waitFor({state: "visible",timeout: 30000}).then(()=>true).catch(()=>false) if(!isActive){ + Logger.info("User is not active voter: "+wallet.stakeAddress) await page.close() + wallet=alternateWallets[index] page = await pageWithInjectedWallet(browser,alternateWallets[index]) pollPage=new PollPage(page) await pollPage.goto(pollId) @@ -71,7 +73,7 @@ test(`Create Voted Poll`, async ({browser }) => { const randomVote = Math.floor(Math.random() * 3); await page.getByTestId(votes[randomVote]).click(); - await expect(page.getByText('Vote recorded!')).toBeVisible() + await expect(page.getByText('Vote recorded!'),"Expected Vote to be recorded for user: "+wallet.stakeAddress).toBeVisible({timeout:10000}) await page.close() }); const organizerPollPage=new PollPage(organizerPages[0]) diff --git a/src/components/buttons/connectWalletButton.tsx b/src/components/buttons/connectWalletButton.tsx index 7ebf7f7..0bb424c 100644 --- a/src/components/buttons/connectWalletButton.tsx +++ b/src/components/buttons/connectWalletButton.tsx @@ -259,6 +259,7 @@ export function ConnectWalletButton(props: Props): JSX.Element { ? theme.palette.secondary.contrastText : '#FFFFFF', }} + data-testid={session?.data?.user?.name?'connected-user-name':''} > {session.status === 'authenticated' ? session.data.user.name diff --git a/src/components/polls/pollResults.tsx b/src/components/polls/pollResults.tsx index fc96ded..597e816 100644 --- a/src/components/polls/pollResults.tsx +++ b/src/components/polls/pollResults.tsx @@ -185,6 +185,7 @@ export function PollResults(props: Props): JSX.Element { > Summary Transaction {`Vote record Tx #${index + 1}`}