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
41 changes: 11 additions & 30 deletions packages/functional-tests/pages/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { Page } from '@playwright/test';
import { Page, expect } from '@playwright/test';
import { BaseTarget } from '../lib/targets/base';

import {
Expand Down Expand Up @@ -74,36 +74,17 @@ export abstract class BaseLayout {
}

async checkWebChannelMessage(command: FirefoxCommand) {
await this.page.evaluate(async (command) => {
const noNotificationError = new Error(
`NoSuchBrowserNotification - ${command}`
// Retry across navigations — a client-side redirect after page.goto
// can destroy the execution context mid-evaluate.
await expect(async () => {
const messages = await this.page.evaluate(() =>
JSON.parse(sessionStorage.getItem('webChannelEvents') || '[]')
);

await new Promise((resolve, reject) => {
const timeoutHandle = setTimeout(
() => reject(noNotificationError),
5000
);

function findMessage() {
const messages = JSON.parse(
sessionStorage.getItem('webChannelEvents') || '[]'
);
const m = messages.find(
(x: { command: string }) => x.command === command
);

if (m) {
clearTimeout(timeoutHandle);
resolve(m);
} else {
setTimeout(findMessage, 50);
}
}

findMessage();
});
}, command);
const found = messages.find(
(x: { command: string }) => x.command === command
);
expect(found).toBeTruthy();
}).toPass({ timeout: 5000 });
}

async getWebChannelEvents(): Promise<
Expand Down
9 changes: 7 additions & 2 deletions packages/functional-tests/pages/settings/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ export abstract class SettingsLayout extends BaseLayout {

async signOut() {
await this.avatarDropDownMenuToggle.click();
await this.avatarMenuSignOut.click();

await expect(this.page).not.toHaveURL(/settings/);
// Wait for the hard navigation (window.location.assign) to complete.
// SPA redirects during sign-out can change the URL before the real
// page load fires, so we wait for the actual 'load' event.
await Promise.all([
this.page.waitForEvent('load'),
this.avatarMenuSignOut.click(),
]);
}
}
2 changes: 2 additions & 0 deletions packages/functional-tests/pages/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export class SigninPage extends PasskeyPage {
}

async fillOutEmailFirstForm(email: string) {
// Ensure the page is ready after a hard navigation.
await expect(this.emailTextbox).toBeVisible();
await this.emailTextbox.fill(email);
await this.emailFirstSubmitButton.click();
}
Expand Down