diff --git a/tests/e2e/login.spec.mjs b/tests/e2e/login.spec.mjs index 9e1141a..346a28e 100644 --- a/tests/e2e/login.spec.mjs +++ b/tests/e2e/login.spec.mjs @@ -60,6 +60,8 @@ test.beforeEach(async () => { page = await app.firstWindow(); // main.js opens DevTools in dev mode, and that window can be the first one registered. while (page.url().startsWith('devtools://')) { + // Recorded so a hang here names which windows existed instead of reporting a bare timeout. + logs.push(`[window] ${page.url()}`); page = app.windows().find((w) => !w.url().startsWith('devtools://')) ?? await new Promise((resolve) => app.once('window', resolve)); } @@ -68,6 +70,7 @@ test.beforeEach(async () => { // crash is render-process-gone, so it does not fire on the MatrixError or the ServiceWorker error. page.on('crash', () => { crashed = true; + logs.push('[renderer] page crashed'); }); await chooseServer(HOMESERVER); @@ -78,7 +81,9 @@ test.beforeEach(async () => { test.afterEach(async ({}, testInfo) => { if (testInfo.status !== testInfo.expectedStatus) { // Console first: a failed launch has no app and no page, so this is the only artifact that - // path can produce. + // path can produce, and it is empty by construction because no handler is attached before + // launch — the failure message in the report is the diagnosis there. A crashed page produces + // no screenshot; the crash line in the console names it. await testInfo.attach('console.log', { body: logs.join('\n'), contentType: 'text/plain' }); if (page && !page.isClosed()) { // screenshot() throws on a crashed page, which would mask the original failure. @@ -132,10 +137,11 @@ test('failed login reports an error and keeps the renderer alive', async () => { // so accept both branches rather than asserting one exact string. await expect(page.getByText(/Invalid Username or Password\.|rate-limited by server/)).toBeVisible(); - // A dead renderer cannot render the form. Pageerrors go into the artifact but are not - // asserted — the failed login itself produces MatrixError, and dev mode produces a - // ServiceWorker registration error. No second login here: every run costs Synapse rc_login - // budget, and the re-login was the main flake source. - await expect(usernameInput()).toBeVisible(); + // Asserted before the form check: on a crashed page the locator throws TargetClosedError, + // which names the wrong thing. Pageerrors go into the artifact but are not asserted — the + // failed login itself produces MatrixError, and dev mode produces a ServiceWorker registration + // error. No second login here: every run costs Synapse rc_login budget, and the re-login was + // the main flake source. await expect(crashed).toBe(false); + await expect(usernameInput()).toBeVisible(); });