Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update browser extension e2e tests (#1404)
Leendert de Borst6f48bd251781
diff --git a/apps/browser-extension/playwright.config.ts b/apps/browser-extension/playwright.config.tsindex 48abf8006..471854595 100644--- a/apps/browser-extension/playwright.config.ts+++ b/apps/browser-extension/playwright.config.ts@@ -36,7 +36,7 @@ export default defineConfig({],// Global timeout for each test- timeout: 600000,+ timeout: 10000,// Expect timeoutexpect: {diff --git a/apps/browser-extension/src/entrypoints/popup/components/HeaderButton.tsx b/apps/browser-extension/src/entrypoints/popup/components/HeaderButton.tsxindex 7e90a0464..97a71d6e4 100644--- a/apps/browser-extension/src/entrypoints/popup/components/HeaderButton.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/HeaderButton.tsx@@ -7,6 +7,7 @@ type HeaderButtonProps = {title: string;iconType: HeaderIconType;variant?: 'default' | 'primary' | 'danger';+ id?: string;};/**@@ -16,7 +17,8 @@ const HeaderButton: React.FC<HeaderButtonProps> = ({onClick,title,iconType,- variant = 'default'+ variant = 'default',+ id}) => {const colorClasses = {default: 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700',@@ -26,6 +28,7 @@ const HeaderButton: React.FC<HeaderButtonProps> = ({return (<button+ id={id}onClick={onClick}className={`p-2 rounded-lg ${colorClasses[variant]}`}title={title}diff --git a/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsxindex 9285a820b..791d90e1e 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx@@ -595,6 +595,7 @@ const ItemAddEdit: React.FC = () => {/>)}<HeaderButton+ id="save-credential"onClick={handleSave}title={t('credentials.saveCredential')}iconType={HeaderIconType.SAVE}diff --git a/apps/browser-extension/tests/e2e/05-vault-merge.spec.ts b/apps/browser-extension/tests/e2e/05-vault-merge.spec.tsindex 73ece8958..27fe6bd49 100644--- a/apps/browser-extension/tests/e2e/05-vault-merge.spec.ts+++ b/apps/browser-extension/tests/e2e/05-vault-merge.spec.ts@@ -11,7 +11,7 @@* 5. After merge, Client B's vault should contain both credentials* 6. Client A syncs and should also see both credentials*/-import { test, expect, TestClient, FieldSelectors } from '../fixtures';+import { test, expect, TestClient, FieldSelectors, ButtonSelectors } from '../fixtures';test.describe.serial('5. Vault Merge', () => {let clientA: TestClient;@@ -42,12 +42,12 @@ test.describe.serial('5. Vault Merge', () => {test('5.2 Client A should create a credential and sync', async () => {// Client A fills and saves the credential (both clients have revision 1 at this point)- await clientA.popup.fill('input#itemName', credentialNameA);- await clientA.popup.click('button:has-text("Next")');+ // All fields are now visible on the same page (no "Next" step)await expect(clientA.popup.locator(FieldSelectors.LOGIN_USERNAME)).toBeVisible({ timeout: 10000 });+ await clientA.popup.fill(FieldSelectors.ITEM_NAME, credentialNameA);await clientA.popup.fill(FieldSelectors.LOGIN_USERNAME, '[email protected]');await clientA.popup.fill(FieldSelectors.LOGIN_PASSWORD, 'ClientAPassword123!');- await clientA.popup.click('button:has-text("Save")');+ await clientA.popup.click(ButtonSelectors.SAVE);await clientA.verifyCredentialExists(credentialNameA)@@ -60,12 +60,12 @@ test.describe.serial('5. Vault Merge', () => {test('5.3 Client B should create a credential (triggers merge with Client A changes)', async () => {// Client B still has stale data (revision 1, empty vault)// This should trigger a merge because the server has revision 2 from Client A- await clientB.popup.fill('input#itemName', credentialNameB);- await clientB.popup.click('button:has-text("Next")');+ // All fields are now visible on the same page (no "Next" step)await expect(clientB.popup.locator(FieldSelectors.LOGIN_USERNAME)).toBeVisible({ timeout: 10000 });+ await clientB.popup.fill(FieldSelectors.ITEM_NAME, credentialNameB);await clientB.popup.fill(FieldSelectors.LOGIN_USERNAME, '[email protected]');await clientB.popup.fill(FieldSelectors.LOGIN_PASSWORD, 'ClientBPassword456!');- await clientB.popup.click('button:has-text("Save")');+ await clientB.popup.click(ButtonSelectors.SAVE);await clientB.verifyCredentialExists(credentialNameB)diff --git a/apps/browser-extension/tests/e2e/07-offline-sync.spec.ts b/apps/browser-extension/tests/e2e/07-offline-sync.spec.tsindex 670cebe4c..110138656 100644--- a/apps/browser-extension/tests/e2e/07-offline-sync.spec.ts+++ b/apps/browser-extension/tests/e2e/07-offline-sync.spec.ts@@ -14,7 +14,7 @@* 8. Client B navigates to root to trigger sync (should merge local changes with server)* 9. Client A syncs and verifies both credentials are present*/-import { test, expect, TestClient, FieldSelectors } from '../fixtures';+import { test, expect, TestClient, FieldSelectors, ButtonSelectors } from '../fixtures';test.describe.serial('7. Offline Sync', () => {let clientA: TestClient;@@ -62,14 +62,13 @@ test.describe.serial('7. Offline Sync', () => {test('7.4 Client B creates a credential while offline', async () => {await clientB.goToVault();- await clientB.popup.locator('[title="Add new item"]').click();- await expect(clientB.popup.locator('input#itemName')).toBeVisible();- await clientB.popup.fill('input#itemName', credentialNameB);- await clientB.popup.click('button:has-text("Next")');+ await clientB.popup.locator(ButtonSelectors.ADD_NEW_ITEM).click();+ // All fields are now visible on the same page (no "Next" step)await expect(clientB.popup.locator(FieldSelectors.LOGIN_USERNAME)).toBeVisible({ timeout: 10000 });+ await clientB.popup.fill(FieldSelectors.ITEM_NAME, credentialNameB);await clientB.popup.fill(FieldSelectors.LOGIN_USERNAME, '[email protected]');await clientB.popup.fill(FieldSelectors.LOGIN_PASSWORD, 'ClientBPassword456!');- await clientB.popup.click('button:has-text("Save")');+ await clientB.popup.click(ButtonSelectors.SAVE);await clientB.verifyCredentialExists(credentialNameB)diff --git a/apps/browser-extension/tests/fixtures/TestClient.ts b/apps/browser-extension/tests/fixtures/TestClient.tsindex 2c105d1b2..07f0d8d28 100644--- a/apps/browser-extension/tests/fixtures/TestClient.ts+++ b/apps/browser-extension/tests/fixtures/TestClient.ts@@ -213,12 +213,13 @@ export class TestClient {/*** Create a new login credential.+ * The new ItemAddEdit page shows all fields directly without an intermediate step.*/async createCredential(name: string, username: string, password: string): Promise<this> {await this.openAddCredentialForm();- await this.popup.fill(FieldSelectors.ITEM_NAME, name);- await this.popup.click(ButtonSelectors.NEXT);+ // All fields are now visible on the same page (no "Next" step)await expect(this.popup.locator(FieldSelectors.LOGIN_USERNAME)).toBeVisible({ timeout: Timeouts.MEDIUM });+ await this.popup.fill(FieldSelectors.ITEM_NAME, name);await this.popup.fill(FieldSelectors.LOGIN_USERNAME, username);await this.popup.fill(FieldSelectors.LOGIN_PASSWORD, password);await this.popup.click(ButtonSelectors.SAVE);@@ -270,8 +271,22 @@ export class TestClient {/*** Fill the notes field.+ * If the notes section is not visible, opens the add field menu and adds it first.*/async fillNotes(notes: string): Promise<this> {+ // Check if notes field is visible, if not add it via the add field menu+ const notesField = this.popup.locator(FieldSelectors.LOGIN_NOTES);+ const isVisible = await notesField.isVisible().catch(() => false);++ if (!isVisible) {+ // Click the add field menu button (dashed border button)+ await this.popup.click(ButtonSelectors.ADD_FIELD_MENU);+ // Click the Notes option in the dropdown+ await this.popup.click('button:has-text("Notes")');+ // Wait for notes field to appear+ await expect(this.popup.locator(FieldSelectors.LOGIN_NOTES)).toBeVisible({ timeout: Timeouts.SHORT });+ }+return this.fillField(FieldSelectors.LOGIN_NOTES, notes);}diff --git a/apps/browser-extension/tests/fixtures/selectors.ts b/apps/browser-extension/tests/fixtures/selectors.tsindex 9568e463a..2790df0ed 100644--- a/apps/browser-extension/tests/fixtures/selectors.ts+++ b/apps/browser-extension/tests/fixtures/selectors.ts@@ -10,14 +10,14 @@*//**- * Field key constants matching shared/models/src/vault/FieldKey.ts+ * Field key constants matching shared/models/src/vault/FieldKey.ts and SystemFieldRegistry.ts* These are the raw field key values used in the application.*/export const FieldKey = {LoginUsername: 'login.username',LoginPassword: 'login.password',- LoginNotes: 'login.notes',LoginUrl: 'login.url',+ MetadataNotes: 'metadata.notes',CardNumber: 'card.number',CardCardholderName: 'card.cardholder_name',CardExpiryMonth: 'card.expiry_month',@@ -51,9 +51,11 @@ export const FieldSelectors = {// Login fieldsLOGIN_USERNAME: `input#${escapeFieldKey(FieldKey.LoginUsername)}`,LOGIN_PASSWORD: `input#${escapeFieldKey(FieldKey.LoginPassword)}`,- LOGIN_NOTES: `textarea#${escapeFieldKey(FieldKey.LoginNotes)}`,LOGIN_URL: `input#${escapeFieldKey(FieldKey.LoginUrl)}`,+ // Metadata fields (shared across item types)+ LOGIN_NOTES: `textarea#${escapeFieldKey(FieldKey.MetadataNotes)}`,+// Card fieldsCARD_NUMBER: `input#${escapeFieldKey(FieldKey.CardNumber)}`,CARD_CARDHOLDER_NAME: `input#${escapeFieldKey(FieldKey.CardCardholderName)}`,@@ -79,6 +81,6 @@ export const FieldSelectors = {export const ButtonSelectors = {ADD_NEW_ITEM: 'button[title="Add new item"]',EDIT_CREDENTIAL: 'button[title="Edit Credential"]',- SAVE: 'button:has-text("Save")',- NEXT: 'button:has-text("Next")',+ SAVE: 'button#save-credential',+ ADD_FIELD_MENU: 'button.border-dashed',} as const;