Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update web app tests
Leendert de Borst3bd63116ac8c
diff --git a/apps/web/tests/e2e/05-email.spec.ts b/apps/web/tests/e2e/05-email.spec.tsindex 80682f2dd..275612f5c 100644--- a/apps/web/tests/e2e/05-email.spec.ts+++ b/apps/web/tests/e2e/05-email.spec.ts@@ -2,19 +2,10 @@* Category 5: Email (requires API and SMTP service, e.g. `./scripts/dev.sh smtp`)*/import { test, expect } from '../fixtures';-import { isSmtpAvailable, resolveSmtpTarget, sendMail } from '../helpers/smtp';+import { requireSmtp, sendMail } from '../helpers/smtp';test.describe('5. Email', () => {- test.beforeAll(async () => {- const { host, port } = resolveSmtpTarget();- const available = await isSmtpAvailable();- const hint = `No SMTP service at ${host}:${port}. Start it with ./scripts/dev.sh smtp, or set ALIASVAULT_SMTP_HOST / ALIASVAULT_SMTP_PORT.`;- // CI starts the SMTP service, so a missing one there is a failure, not a reason to skip.- if (!available && process.env.CI) {- throw new Error(hint);- }- test.skip(!available, hint);- });+ test.beforeAll(requireSmtp);test('5.1 should receive and decrypt mail on an alias of a new account', async ({ app, testUser }) => {const { page } = app;diff --git a/apps/web/tests/e2e/07-vault-upgrade.spec.ts b/apps/web/tests/e2e/07-vault-upgrade.spec.tsindex 43f27aa3d..b4110a423 100644--- a/apps/web/tests/e2e/07-vault-upgrade.spec.ts+++ b/apps/web/tests/e2e/07-vault-upgrade.spec.ts@@ -1,39 +1,56 @@/**- * Category 7: Vault upgrades (requires API)+ * Category 7: Vault upgrades.*/-import { test, expect } from '../fixtures';-import { readLegacyVaultFixture, restoreLegacyVault } from '../helpers/test-api';+import { test, expect, type WebApp } from '../fixtures';+import { requireSmtp, sendMail } from '../helpers/smtp';+import { readLegacyVaultFixture, restoreLegacyVault, type LegacyVaultFixture, type TestUser } from '../helpers/test-api';++/**+ * Put the 1.0.0 vault on the account, log in and run both upgrade steps, ending on the items page.+ */+async function upgradeLegacyVault(app: WebApp, apiUrl: string, testUser: TestUser): Promise<LegacyVaultFixture> {+ const { page } = app;+ const fixture = readLegacyVaultFixture('1.0.0');+ await restoreLegacyVault(apiUrl, testUser.username, fixture);+ const startUpgrade = page.getByRole('button', { name: 'Start upgrade process' });++ await test.step('log in to the account with the 1.0.0 vault', async () => {+ await app.openStart();+ await page.getByRole('link', { name: 'Log in with existing account' }).click();+ await app.submitLogin(testUser.username, fixture.password);+ await expect(page).toHaveURL(/\/sync$/);+ });++ await test.step('run the legacy database upgrade', async () => {+ await expect(page.getByText('New available version:')).toBeVisible();+ await app.pause();+ await startUpgrade.click();+ });++ await test.step('run the storage format upgrade', async () => {+ await expect(page.getByText('your other AliasVault apps need version')).toBeVisible();+ await app.pause();+ await startUpgrade.click();+ await expect(page.getByText('Vault upgrade successful.')).toBeVisible();+ await page.locator('#upgrade-continue-button').click();+ await expect(page).toHaveURL(/\/items$/);+ });++ return fixture;+}test.describe('7. Vault upgrades', () => {+ /*+ * One after the other: every test account gets the fixture's SRP identity, and the server keys the login handshake+ * on that identity, so two logins at once would overwrite each other's handshake.+ */+ test.describe.configure({ mode: 'default' });+test('7.1 should upgrade a 1.0.0 vault to the current storage format', async ({ app, apiUrl, testUser }) => {const { page } = app;- const fixture = readLegacyVaultFixture('1.0.0');- await restoreLegacyVault(apiUrl, testUser.username, fixture);- const startUpgrade = page.getByRole('button', { name: 'Start upgrade process' });-- await test.step('log in to the account with the 1.0.0 vault', async () => {- await app.openStart();- await page.getByRole('link', { name: 'Log in with existing account' }).click();- await app.submitLogin(testUser.username, fixture.password);- await expect(page).toHaveURL(/\/sync$/);- });-- await test.step('run the legacy database upgrade', async () => {- await expect(page.getByText('New available version:')).toBeVisible();- await app.pause();- await startUpgrade.click();- });-- await test.step('run the storage format upgrade', async () => {- await expect(page.getByText('your other AliasVault apps need version')).toBeVisible();- await app.pause();- await startUpgrade.click();- await expect(page.getByText('Vault upgrade successful.')).toBeVisible();- await page.locator('#upgrade-continue-button').click();- });+ const fixture = await upgradeLegacyVault(app, apiUrl, testUser);await test.step('the items of the 1.0.0 vault are there', async () => {- await expect(page).toHaveURL(/\/items$/);for (const name of fixture.expectedItemNames) {await expect(page.getByText(name, { exact: true })).toBeVisible();}@@ -57,4 +74,41 @@ test.describe('7. Vault upgrades', () => {}});});++ test('7.2 should receive and decrypt mail on a new alias after upgrading a 1.0.0 vault', async ({ app, apiUrl, testUser }) => {+ await requireSmtp();+ const { page } = app;+ const id = Math.random().toString(36).substring(2, 10);+ const address = `e2e_${id}@example.tld`;+ const subject = `Mail ${id}`;++ await upgradeLegacyVault(app, apiUrl, testUser);++ await test.step('create a login item with an address on a private domain', async () => {+ await page.locator('#topBarQuickCreateButton').click();+ await page.locator('#serviceName').fill('Mail test');+ await page.locator('#quickIdentitySubmit').click();+ await page.getByRole('button', { name: 'Email', exact: true }).click();+ await page.locator('#email').fill(address);+ await app.saveItemButton().click();+ await expect(page.getByText('Item created successfully')).toBeVisible();+ await app.expectItemView('Mail test');+ });++ await test.step('the SMTP service accepts mail for the address', async () => {+ // A 550 here means the upgraded vault published no email delivery key for its manifest.+ await sendMail({+ from: '[email protected]',+ to: address,+ subject,+ text: 'This is a test email plain.',+ html: '<html><body><p>Test email after a vault upgrade.</p></body></html>',+ });+ });++ await test.step('the email shows decrypted on the item page', async () => {+ await page.locator('#recent-email-refresh').click();+ await expect(page.getByText(subject)).toBeVisible();+ });+ });});diff --git a/apps/web/tests/helpers/smtp.ts b/apps/web/tests/helpers/smtp.tsindex 253579343..feb44b353 100644--- a/apps/web/tests/helpers/smtp.ts+++ b/apps/web/tests/helpers/smtp.ts@@ -3,6 +3,8 @@*/import { connect, type Socket } from 'node:net';+import { test } from '@playwright/test';+/*** Where the SMTP service listens: ALIASVAULT_SMTP_HOST / ALIASVAULT_SMTP_PORT, else port 25 of this machine* (the fixed port of `./scripts/dev.sh smtp`). IPv4 on purpose, so a Docker stack bound to [::]:25 is not hit instead.@@ -38,6 +40,20 @@ export async function isSmtpAvailable(): Promise<boolean> {}}+/**+ * Skip the calling test (or describe block, from a beforeAll) when no SMTP service answers. CI starts the SMTP service,+ * so a missing one there is a failure, not a reason to skip.+ */+export async function requireSmtp(): Promise<void> {+ const { host, port } = resolveSmtpTarget();+ const available = await isSmtpAvailable();+ const hint = `No SMTP service at ${host}:${port}. Start it with ./scripts/dev.sh smtp, or set ALIASVAULT_SMTP_HOST / ALIASVAULT_SMTP_PORT.`;+ if (!available && process.env.CI) {+ throw new Error(hint);+ }+ test.skip(!available, hint);+}+/*** Send a message; throws with the server reply when any step is refused, e.g. when AliasVault rejects the recipient.*/