diff --git a/test/e2e_tests/pageManager/webapp/pages/login.page.ts b/test/e2e_tests/pageManager/webapp/pages/login.page.ts index 11d371ae4be..63c389fc7df 100644 --- a/test/e2e_tests/pageManager/webapp/pages/login.page.ts +++ b/test/e2e_tests/pageManager/webapp/pages/login.page.ts @@ -21,8 +21,6 @@ import type {Page, Locator} from '@playwright/test'; import type {User} from 'test/e2e_tests/data/user'; -import {webAppPath} from '../..'; - export class LoginPage { readonly page: Page; @@ -46,11 +44,5 @@ export class LoginPage { await this.emailInput.fill(user.email); await this.passwordInput.fill(user.password); await this.signInButton.click(); - - /** - * Since the login may take up to 40s we manually wait for it to finish here instead of increasing the timeout on all actions / assertions after this util - * This is an exception to the general best practice of using playwrights web assertions. (See: https://playwright.dev/docs/best-practices#use-web-first-assertions) - */ - await this.page.waitForURL(new RegExp(`^${webAppPath}$`), {timeout: 40_000, waitUntil: 'networkidle'}); } } diff --git a/test/e2e_tests/specs/Authentication/authentication.spec.ts b/test/e2e_tests/specs/Authentication/authentication.spec.ts index 6c8c0c21b5a..82c52f4feed 100644 --- a/test/e2e_tests/specs/Authentication/authentication.spec.ts +++ b/test/e2e_tests/specs/Authentication/authentication.spec.ts @@ -48,12 +48,13 @@ test.describe('Authentication', () => { test( 'I want to be asked to share telemetry data when I log in', {tag: ['@TC-8780', '@regression']}, - async ({pageManager, createUser}) => { + async ({page, pageManager, createUser}) => { const {pages, modals} = pageManager.webapp; const user = await createUser({disableTelemetry: false}); await pageManager.openLoginPage(); await pages.login().login(user); + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); await expect(modals.dataShareConsent().modalTitle).toBeVisible(); }, @@ -76,7 +77,7 @@ test.describe('Authentication', () => { test( 'Verify current browser is set as temporary device', {tag: ['@TC-3460', '@regression']}, - async ({pageManager, createUser}) => { + async ({page, pageManager, createUser}) => { const user = await createUser(); const {pages, components} = pageManager.webapp; @@ -85,6 +86,7 @@ test.describe('Authentication', () => { await pages.login().publicComputerCheckbox.click(); await pages.login().login(user); await pages.historyInfo().clickConfirmButton(); + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); }); let proteusId: string; @@ -104,6 +106,7 @@ test.describe('Authentication', () => { await test.step('Log in again on non public computer', async () => { await pageManager.openLoginPage(); await pages.login().login(user); + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); }); await test.step("Open device settings and ensure the public computer isn't active and the ID was re-generated", async () => { @@ -136,7 +139,7 @@ test.describe('Authentication', () => { test( `I want to keep my history after refreshing the page on ${deviceType} device`, {tag: [tag, '@regression']}, - async ({pageManager, createTeam}) => { + async ({page, pageManager, createTeam}) => { const {pages} = pageManager.webapp; const team = await createTeam('Test Team', {withMembers: 1}); const userA = team.owner; @@ -153,6 +156,7 @@ test.describe('Authentication', () => { await pages.login().login(userA); } + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); await connectWithUser(pageManager, userB); }); @@ -192,7 +196,7 @@ test.describe('Authentication', () => { test( 'Make sure user does not see data of user of previous sessions on same browser', {tag: ['@TC-1311', '@regression']}, - async ({pageManager, createTeam}) => { + async ({page, pageManager, createTeam}) => { const {pages, components} = pageManager.webapp; const team = await createTeam('Test Team', {withMembers: 1}); const userA = team.owner; @@ -203,6 +207,7 @@ test.describe('Authentication', () => { await pages.login().publicComputerCheckbox.click(); await pages.login().login(userA); await pages.historyInfo().clickConfirmButton(); + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); }); await test.step('Connect with and send message to userB', async () => { @@ -221,6 +226,7 @@ test.describe('Authentication', () => { await pageManager.openLoginPage(); await pages.login().login(userA); await pages.historyInfo().clickConfirmButton(); + await page.waitForURL(webAppPath, {timeout: 30_000, waitUntil: 'networkidle'}); }); await test.step('Verify previously sent message is gone', async () => { @@ -241,8 +247,7 @@ test.describe('Authentication', () => { pages: device2Pages, modals: device2Modals, components: device2Components, - } = PageManager.from(await createPage(withLogin(user))).webapp; - await device2Pages.historyInfo().clickConfirmButton(); + } = PageManager.from(await createPage(withLogin(user, {confirmNewHistory: true}))).webapp; await device2Components.conversationSidebar().clickPreferencesButton(); await device2Pages.settings().devicesButton.click(); diff --git a/test/e2e_tests/specs/Edit/edit.spec.ts b/test/e2e_tests/specs/Edit/edit.spec.ts index dcd0ced94e0..a47ff48dffa 100644 --- a/test/e2e_tests/specs/Edit/edit.spec.ts +++ b/test/e2e_tests/specs/Edit/edit.spec.ts @@ -72,8 +72,7 @@ test.describe('Edit', () => { const deviceA = (await PageManager.from(createPage(withLogin(userA), withConnectedUser(userB)))).webapp.pages; // Device 2 is intentionally created after device 1 to ensure the history info warning is confirmed - const deviceB = (await PageManager.from(createPage(withLogin(userA)))).webapp.pages; - await deviceB.historyInfo().clickConfirmButton(); + const deviceB = (await PageManager.from(createPage(withLogin(userA, {confirmNewHistory: true})))).webapp.pages; await deviceB.conversationList().openConversation(userB.fullName); await deviceA.conversation().sendMessage('Message from device 1'); diff --git a/test/e2e_tests/test.fixtures.ts b/test/e2e_tests/test.fixtures.ts index fc9343628b1..6e300b34d08 100644 --- a/test/e2e_tests/test.fixtures.ts +++ b/test/e2e_tests/test.fixtures.ts @@ -21,7 +21,7 @@ import {test as baseTest, type BrowserContext, type Page} from '@playwright/test import {ApiManagerE2E} from './backend/apiManager.e2e'; import {getUser, User} from './data/user'; -import {PageManager} from './pageManager'; +import {PageManager, webAppPath} from './pageManager'; import {connectWithUser, sendConnectionRequest} from './utils/userActions'; type PagePlugin = (page: Page) => void | Promise; @@ -144,11 +144,21 @@ export const test = baseTest.extend({ /** PagePlugin to log in as the given user */ export const withLogin = - (user: User | Promise): PagePlugin => + (user: User | Promise, options?: {confirmNewHistory?: boolean}): PagePlugin => async page => { const pageManager = PageManager.from(page); await pageManager.openLoginPage(); await pageManager.webapp.pages.login().login(await user); + + if (options?.confirmNewHistory) { + await pageManager.webapp.pages.historyInfo().clickConfirmButton(); + } + + /** + * Since the login may take up to 40s we manually wait for it to finish here instead of increasing the timeout on all actions / assertions after this util + * This is an exception to the general best practice of using playwrights web assertions. (See: https://playwright.dev/docs/best-practices#use-web-first-assertions) + */ + await page.waitForURL(new RegExp(`^${webAppPath}$`), {timeout: 40_000, waitUntil: 'networkidle'}); }; /**