Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions test/e2e_tests/pageManager/webapp/pages/login.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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'});
}
}
17 changes: 11 additions & 6 deletions test/e2e_tests/specs/Authentication/authentication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
});

Expand Down Expand Up @@ -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;
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions test/e2e_tests/specs/Edit/edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
14 changes: 12 additions & 2 deletions test/e2e_tests/test.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
Expand Down Expand Up @@ -144,11 +144,21 @@ export const test = baseTest.extend<Fixtures>({

/** PagePlugin to log in as the given user */
export const withLogin =
(user: User | Promise<User>): PagePlugin =>
(user: User | Promise<User>, 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'});
};

/**
Expand Down
Loading