Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update browser extension tests

Leendert de Borstd4adb0d67e5c
diff --git a/apps/browser-extension/tests/fixtures/TestClient.ts b/apps/browser-extension/tests/fixtures/TestClient.ts
index 64fa1db46..7e0d98e53 100644
--- a/apps/browser-extension/tests/fixtures/TestClient.ts
+++ b/apps/browser-extension/tests/fixtures/TestClient.ts
@@ -13,7 +13,7 @@
import type { BrowserContext, Page } from '@playwright/test';
import { createFreshContext, expect, test } from './fixtures';
-import { completeVaultUpgrade } from './helpers';
+import { waitForVaultOpen } from './helpers';
import { FieldSelectors, ButtonSelectors } from './selectors';
import {
waitForVaultReady,
@@ -119,14 +119,14 @@ export class TestClient {
await this.popup.fill('input[type="text"]', username);
await this.popup.fill('input[type="password"]', password);
await this.popup.click('button:has-text("Log in")');
- return this.completeVaultUpgrade();
+ return this.waitForVaultOpen();
}
/**
- * Clear the vault upgrade gate, if the popup landed on it, and wait for the vault to be ready.
+ * Wait for the vault to open after a login or unlock; fails on the upgrade gate.
*/
- async completeVaultUpgrade(timeout: number = Timeouts.LONG): Promise<this> {
- await completeVaultUpgrade(this.popup, timeout);
+ async waitForVaultOpen(timeout: number = Timeouts.LONG): Promise<this> {
+ await waitForVaultOpen(this.popup, timeout);
return this;
}
@@ -166,7 +166,7 @@ export class TestClient {
*/
async submitLogin(): Promise<this> {
await this.popup.click('button:has-text("Log in")');
- return this.completeVaultUpgrade();
+ return this.waitForVaultOpen();
}
/**
@@ -449,8 +449,7 @@ export class TestClient {
async unlockVault(password: string): Promise<this> {
await this.popup.fill('input#password', password);
await this.popup.click('button[type="submit"]:has-text("Unlock")');
- // Unlocking routes to the upgrade gate too, whenever the local vault still owes a migration.
- return this.completeVaultUpgrade();
+ return this.waitForVaultOpen();
}
/**
diff --git a/apps/browser-extension/tests/fixtures/fixtures.ts b/apps/browser-extension/tests/fixtures/fixtures.ts
index c84161bda..64948e65c 100644
--- a/apps/browser-extension/tests/fixtures/fixtures.ts
+++ b/apps/browser-extension/tests/fixtures/fixtures.ts
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';
import { createTestUser, type TestUser } from '../helpers/test-api';
-import { completeVaultUpgrade } from './helpers';
+import { waitForVaultOpen } from './helpers';
import { waitForPopupReady as waitForPopupReadyState, Timeouts } from './waits';
const __filename = fileURLToPath(import.meta.url);
@@ -148,14 +148,13 @@ export async function openPopup(
/**
* Helper to wait for post-login state (vault is visible).
*
- * This confirms the user has successfully logged in and the vault UI is ready. Test accounts start
- * out on a legacy sqlite-blob vault, so this also clears the upgrade gate the popup lands on.
+ * This confirms the user has successfully logged in and the vault UI is ready.
*
* @param popup - The popup page
* @param timeout - Maximum time to wait in milliseconds (default: 30000)
*/
export async function waitForLoggedIn(popup: Page, timeout: number = 30000): Promise<void> {
- await completeVaultUpgrade(popup, timeout);
+ await waitForVaultOpen(popup, timeout);
}
/**
diff --git a/apps/browser-extension/tests/fixtures/helpers.ts b/apps/browser-extension/tests/fixtures/helpers.ts
index d3a49fe30..44d0aba3a 100644
--- a/apps/browser-extension/tests/fixtures/helpers.ts
+++ b/apps/browser-extension/tests/fixtures/helpers.ts
@@ -60,20 +60,14 @@ export async function getNotesValue(popup: Page): Promise<string> {
}
/**
- * Selectors for the vault upgrade gate (the `/upgrade` route).
- */
-const UpgradeSelectors = {
- UPGRADE_BUTTON: 'button#upgrade-button',
- CONTINUE_BUTTON: 'button#upgrade-continue-button',
-} as const;
-
-/**
- * Walk the vault upgrade gate, if the popup landed on it.
+ * Wait until the popup has opened the vault after a login or unlock, failing if it lands on the upgrade gate instead.
+ *
+ * Test accounts are created on the current storage format, so only the vault upgrade specs (90.x) may walk the gate.
*
* @param popup - The popup page
- * @param timeout - Timeout in milliseconds for each step of the flow
+ * @param timeout - Timeout in milliseconds
*/
-export async function completeVaultUpgrade(popup: Page, timeout: number = Timeouts.LONG): Promise<void> {
+export async function waitForVaultOpen(popup: Page, timeout: number = Timeouts.LONG): Promise<void> {
/*
* The popup hops through `/reinitialize` before it routes on, and that route already renders the
* bottom nav, so a visible `#nav-vault` on its own is no proof that the app has settled. The hash
@@ -87,26 +81,8 @@ export async function completeVaultUpgrade(popup: Page, timeout: number = Timeou
);
const hash = await popup.evaluate(() => window.location.hash);
- if (!hash.startsWith('#/upgrade')) {
- return;
- }
-
- /*
- * The gate classifies the pending upgrade on mount: a storage format move asks for consent, while
- * a local-only schema rebuild runs unattended and opens the vault by itself.
- */
- const upgradeButton = popup.locator(UpgradeSelectors.UPGRADE_BUTTON);
- await popup.locator(`${UpgradeSelectors.UPGRADE_BUTTON}, #nav-vault`).first().waitFor({ state: 'visible', timeout });
-
- if (await upgradeButton.isVisible()) {
- await upgradeButton.click();
-
- // The storage format upgrade ends on a success screen that auto-continues after a countdown.
- const continueButton = popup.locator(UpgradeSelectors.CONTINUE_BUTTON);
- await popup.locator(`${UpgradeSelectors.CONTINUE_BUTTON}, #nav-vault`).first().waitFor({ state: 'visible', timeout });
- if (await continueButton.isVisible()) {
- await continueButton.click();
- }
+ if (hash.startsWith('#/upgrade')) {
+ throw new Error('The popup landed on the vault upgrade gate, but test accounts are created on the current storage format. Only the vault upgrade specs (90.x) should reach it.');
}
await waitForVaultReady(popup, timeout);
diff --git a/apps/browser-extension/tests/fixtures/index.ts b/apps/browser-extension/tests/fixtures/index.ts
index c57ff9dd6..0e58f7f5f 100644
--- a/apps/browser-extension/tests/fixtures/index.ts
+++ b/apps/browser-extension/tests/fixtures/index.ts
@@ -41,7 +41,7 @@ export {
getUsernameValue,
getPasswordValue,
getNotesValue,
- completeVaultUpgrade,
+ waitForVaultOpen,
} from './helpers';
// Field selectors and constants