Move the crash assertion ahead of the locator and name the crash path in the artifact. (#109)
- The `crash` assertion now runs before the form check, because on a crashed page the locator throws TargetClosedError and names the wrong thing. - The `crash` handler logs the crash, so the failure artifact is not empty on that path. - The DevTools window loop records the window URLs, so a hang there names which windows existed instead of reporting a bare timeout. - Comment states that a launch failure produces an empty console artifact by construction, so the report's failure message is the diagnosis there. Checks: `node --check` on the file, `npm run test:unit` — 2 passed. E2E cannot be run locally (no `E2E_PASSWORD` in this session); CI is the check.
This commit is contained in:
@@ -60,6 +60,8 @@ test.beforeEach(async () => {
|
|||||||
page = await app.firstWindow();
|
page = await app.firstWindow();
|
||||||
// main.js opens DevTools in dev mode, and that window can be the first one registered.
|
// main.js opens DevTools in dev mode, and that window can be the first one registered.
|
||||||
while (page.url().startsWith('devtools://')) {
|
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://'))
|
page = app.windows().find((w) => !w.url().startsWith('devtools://'))
|
||||||
?? await new Promise((resolve) => app.once('window', resolve));
|
?? 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.
|
// crash is render-process-gone, so it does not fire on the MatrixError or the ServiceWorker error.
|
||||||
page.on('crash', () => {
|
page.on('crash', () => {
|
||||||
crashed = true;
|
crashed = true;
|
||||||
|
logs.push('[renderer] page crashed');
|
||||||
});
|
});
|
||||||
|
|
||||||
await chooseServer(HOMESERVER);
|
await chooseServer(HOMESERVER);
|
||||||
@@ -78,7 +81,9 @@ test.beforeEach(async () => {
|
|||||||
test.afterEach(async ({}, testInfo) => {
|
test.afterEach(async ({}, testInfo) => {
|
||||||
if (testInfo.status !== testInfo.expectedStatus) {
|
if (testInfo.status !== testInfo.expectedStatus) {
|
||||||
// Console first: a failed launch has no app and no page, so this is the only artifact that
|
// 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' });
|
await testInfo.attach('console.log', { body: logs.join('\n'), contentType: 'text/plain' });
|
||||||
if (page && !page.isClosed()) {
|
if (page && !page.isClosed()) {
|
||||||
// screenshot() throws on a crashed page, which would mask the original failure.
|
// 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.
|
// so accept both branches rather than asserting one exact string.
|
||||||
await expect(page.getByText(/Invalid Username or Password\.|rate-limited by server/)).toBeVisible();
|
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 before the form check: on a crashed page the locator throws TargetClosedError,
|
||||||
// asserted — the failed login itself produces MatrixError, and dev mode produces a
|
// which names the wrong thing. Pageerrors go into the artifact but are not asserted — the
|
||||||
// ServiceWorker registration error. No second login here: every run costs Synapse rc_login
|
// failed login itself produces MatrixError, and dev mode produces a ServiceWorker registration
|
||||||
// budget, and the re-login was the main flake source.
|
// error. No second login here: every run costs Synapse rc_login budget, and the re-login was
|
||||||
await expect(usernameInput()).toBeVisible();
|
// the main flake source.
|
||||||
await expect(crashed).toBe(false);
|
await expect(crashed).toBe(false);
|
||||||
|
await expect(usernameInput()).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user