Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update tests
Leendert de Borstfc082aea0037
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/AuthSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/AuthSettings.tsxindex dc40940d6..cd382d642 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/AuthSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/AuthSettings.tsx@@ -68,16 +68,30 @@ const AuthSettings: React.FC = () => {const urlSchema = createUrlSchema(t);const apiUrlDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);const clientUrlDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);+ // Track pending values that haven't been saved yet due to debounce+ const pendingApiUrlRef = useRef<string | null>(null);+ const pendingClientUrlRef = useRef<string | null>(null);- // Clean up debounce timers on unmount+ // Flush pending saves and clean up on unmount (when navigating away)useEffect((): (() => void) => {return (): void => {+ // Clear debounce timersif (apiUrlDebounceRef.current) {clearTimeout(apiUrlDebounceRef.current);}if (clientUrlDebounceRef.current) {clearTimeout(clientUrlDebounceRef.current);}++ // Save any pending values synchronously before unmount+ if (pendingApiUrlRef.current !== null) {+ const value = pendingApiUrlRef.current;+ storage.setItem('local:apiUrl', value);+ }+ if (pendingClientUrlRef.current !== null) {+ const value = pendingClientUrlRef.current;+ storage.setItem('local:clientUrl', value);+ }};}, []);@@ -136,6 +150,7 @@ const AuthSettings: React.FC = () => {const handleCustomUrlChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) : void => {const value = e.target.value;setCustomUrl(value);+ pendingApiUrlRef.current = value;if (apiUrlDebounceRef.current) {clearTimeout(apiUrlDebounceRef.current);@@ -146,12 +161,14 @@ const AuthSettings: React.FC = () => {await urlSchema.validateAt('apiUrl', { apiUrl: value });setErrors(prev => ({ ...prev, apiUrl: undefined }));await storage.setItem('local:apiUrl', value);+ pendingApiUrlRef.current = null;} catch (error: unknown) {if (error instanceof Yup.ValidationError) {setErrors(prev => ({ ...prev, apiUrl: error.message }));// On error we revert back to the aliasvault.net official hosted instance.await storage.setItem('local:apiUrl', AppInfo.DEFAULT_API_URL);await storage.setItem('local:clientUrl', AppInfo.DEFAULT_CLIENT_URL);+ pendingApiUrlRef.current = null;}}}, 150);@@ -164,6 +181,7 @@ const AuthSettings: React.FC = () => {const handleCustomClientUrlChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) : void => {const value = e.target.value;setCustomClientUrl(value);+ pendingClientUrlRef.current = value;if (clientUrlDebounceRef.current) {clearTimeout(clientUrlDebounceRef.current);@@ -174,9 +192,11 @@ const AuthSettings: React.FC = () => {await urlSchema.validateAt('clientUrl', { clientUrl: value });setErrors(prev => ({ ...prev, clientUrl: undefined }));await storage.setItem('local:clientUrl', value);+ pendingClientUrlRef.current = null;} catch (error: unknown) {if (error instanceof Yup.ValidationError) {setErrors(prev => ({ ...prev, clientUrl: error.message }));+ pendingClientUrlRef.current = null;}}}, 150);diff --git a/apps/browser-extension/tests/e2e/06-field-level-merge.spec.ts b/apps/browser-extension/tests/e2e/06-field-level-merge.spec.tsindex 516686126..cc5c33ac5 100644--- a/apps/browser-extension/tests/e2e/06-field-level-merge.spec.ts+++ b/apps/browser-extension/tests/e2e/06-field-level-merge.spec.ts@@ -66,7 +66,9 @@ test.describe.serial('6. Field-Level Merge', () => {.then((c) => c.fillNotes(clientANotes)).then((c) => c.screenshot('6.3-client-a-before-save.png')).then((c) => c.saveCredential())- .then((c) => c.screenshot('6.3-client-a-after-save.png'));+ .then((c) => c.screenshot('6.3-client-a-after-save.png'))+ // Ensure changes are synced to server before Client B edits+ .then((c) => c.triggerSync());});test('6.4 Client B edits same credential (password and notes) with stale data', async () => {@@ -83,8 +85,9 @@ test.describe.serial('6. Field-Level Merge', () => {});test('6.5 Client B verifies field-level merge result', async () => {+ // Sync to get the merged result from server after Client B's save triggered the mergeawait clientB- .goToVault()+ .triggerSync().then((c) => c.clickCredential(credentialName)).then((c) => c.openEditForm()).then((c) => c.screenshot('6.5-client-b-merged-form.png'));diff --git a/apps/browser-extension/tests/fixtures/TestClient.ts b/apps/browser-extension/tests/fixtures/TestClient.tsindex 0daa6cbf2..764610289 100644--- a/apps/browser-extension/tests/fixtures/TestClient.ts+++ b/apps/browser-extension/tests/fixtures/TestClient.ts@@ -19,6 +19,7 @@ import { expect } from './fixtures';import { FieldSelectors, ButtonSelectors } from './selectors';import {waitForVaultReady,+ waitForSyncComplete,waitForCredentialSaved,waitForSettingsPage,waitForUnlockPage,@@ -92,16 +93,24 @@ export class TestClient {/*** Configure the API URL for the extension.+ * Verifies the URL is displayed on the login page after configuration.*/async configureApiUrl(apiUrl: string): Promise<this> {const settingsButton = await this.popup.waitForSelector('button#settings');await settingsButton.click();await this.popup.selectOption('select', ['custom']);await this.popup.fill('input#custom-api-url', apiUrl);- // Wait for debounce to complete before navigating away (settings use 300ms debounce for storage writes)- await this.popup.waitForTimeout(Timeouts.DEBOUNCE);await this.popup.click('button#back');await waitForLoginForm(this.popup);++ // Sanity check: verify the configured URL is displayed on the login page+ // This catches cases where the URL wasn't saved (e.g., debounce issues)+ const displayedUrl = await this.popup.locator('text=' + new URL(apiUrl).host).isVisible({ timeout: 2000 })+ .catch(() => false);+ if (!displayedUrl) {+ throw new Error(`API URL configuration failed: expected "${apiUrl}" to be displayed on login page, but it wasn't. This may indicate the URL was not saved properly.`);+ }+return this;}@@ -194,13 +203,14 @@ export class TestClient {/*** Navigate to root to trigger a fresh sync.+ * Waits for the sync indicator to disappear before returning.*/async triggerSync(): Promise<this> {await this.popup.evaluate(() => {window.location.href = '/popup.html';});await this.popup.waitForLoadState('domcontentloaded');- await waitForVaultReady(this.popup, Timeouts.LONG);+ await waitForSyncComplete(this.popup, Timeouts.LONG);return this;}diff --git a/apps/browser-extension/tests/fixtures/fixtures.ts b/apps/browser-extension/tests/fixtures/fixtures.tsindex 1f75c5755..379bba1fe 100644--- a/apps/browser-extension/tests/fixtures/fixtures.ts+++ b/apps/browser-extension/tests/fixtures/fixtures.ts@@ -176,14 +176,9 @@ export async function waitForLoggedIn(popup: Page, timeout: number = 30000): Proawait popup.getByRole('button', { name: 'Vault' }).waitFor({ state: 'visible', timeout });}-/**- * Debounce wait time for settings that use debounced storage writes (e.g., API URL).- * The extension uses 150ms debounce, we add a small buffer.- */-const DEBOUNCE_WAIT = 200;-/*** Helper to configure the extension to use a custom API URL.+ * Verifies the URL is displayed on the login page after configuration.** @param popup - The popup page* @param apiUrl - The API URL to configure@@ -199,14 +194,19 @@ export async function configureApiUrl(popup: Page, apiUrl: string): Promise<void// Fill in the custom URL inputawait popup.fill('input#custom-api-url', apiUrl);- // Wait for debounce to complete before navigating away (settings use 300ms debounce for storage writes)- await popup.waitForTimeout(DEBOUNCE_WAIT);-// Go back to main pageawait popup.click('button#back');// Wait for the login form to be visible (indicates settings were saved and we're back)await popup.waitForSelector('input[type="text"], input[type="password"]', { state: 'visible' });++ // Sanity check: verify the configured URL is displayed on the login page+ // This catches cases where the URL wasn't saved (e.g., debounce issues)+ const host = new URL(apiUrl).host;+ const displayedUrl = await popup.locator(`text=${host}`).isVisible({ timeout: 2000 }).catch(() => false);+ if (!displayedUrl) {+ throw new Error(`API URL configuration failed: expected "${apiUrl}" to be displayed on login page, but it wasn't. This may indicate the URL was not saved properly.`);+ }}/**diff --git a/apps/browser-extension/tests/fixtures/waits.ts b/apps/browser-extension/tests/fixtures/waits.tsindex 1dac9a3b8..78544a789 100644--- a/apps/browser-extension/tests/fixtures/waits.ts+++ b/apps/browser-extension/tests/fixtures/waits.ts@@ -16,8 +16,6 @@ export const Timeouts = {SHORT: 5000,MEDIUM: 10000,LONG: 30000,- /** Debounce wait time for settings that use debounced storage writes (e.g., API URL). The extension uses 150ms debounce. */- DEBOUNCE: 200,} as const;/**@@ -65,20 +63,35 @@ export async function waitForVaultReady(popup: Page, timeout: number = Timeouts./*** Wait for a sync operation to complete.- * Detects sync by waiting for the vault content to update or sync indicator to disappear.+ * Waits for vault UI to be ready, then waits for sync/pending indicators to disappear.** @param popup - The popup page* @param timeout - Timeout in milliseconds*/export async function waitForSyncComplete(popup: Page, timeout: number = Timeouts.MEDIUM): Promise<void> {+ // First wait for the vault button to be visible (basic UI ready)+ await waitForVaultReady(popup, timeout);+// Wait for any loading spinner to disappear (if present)const loadingOverlay = popup.locator('.z-50');await loadingOverlay.waitFor({ state: 'hidden', timeout }).catch(() => {// Loading overlay might not exist, which is fine});- // Also wait for the vault button to be visible and enabled- await waitForVaultReady(popup, timeout);+ // Wait for the sync indicator (green spinning icon) to disappear+ const syncIndicator = popup.locator('div.bg-green-100, div.bg-green-900\\/30');+ await syncIndicator.waitFor({ state: 'hidden', timeout }).catch(() => {+ // Sync indicator might not exist or sync was very fast, which is fine+ });++ // Also wait for pending sync indicator (blue icon) to disappear+ const pendingSyncIndicator = popup.locator('div.bg-blue-100, div.bg-blue-900\\/30');+ await pendingSyncIndicator.waitFor({ state: 'hidden', timeout }).catch(() => {+ // Pending sync indicator might not exist, which is fine+ });++ // Small buffer to ensure async operations complete after UI indicators disappear+ await popup.waitForTimeout(100);}/**diff --git a/apps/server/Tests/AliasVault.E2ETests/Common/BrowserExtensionPlaywrightTest.cs b/apps/server/Tests/AliasVault.E2ETests/Common/BrowserExtensionPlaywrightTest.csindex 8e2712e9d..cfbc10b87 100644--- a/apps/server/Tests/AliasVault.E2ETests/Common/BrowserExtensionPlaywrightTest.cs+++ b/apps/server/Tests/AliasVault.E2ETests/Common/BrowserExtensionPlaywrightTest.cs@@ -97,9 +97,6 @@ public class BrowserExtensionPlaywrightTest : ClientPlaywrightTest// Fill in the custom URL input that appearsawait extensionPopup.FillAsync("input[id='custom-api-url']", ApiBaseUrl);- // Wait for debounce to complete before navigating away (settings use 150ms debounce for storage writes)- await Task.Delay(200);-// Go back to main pageawait extensionPopup.ClickAsync("button[id='back']");