Apply the #109 re-review: crash assertion, artifact hook on launch failure, dropped redundant lines. (#109)
Tests / unit (pull_request) Successful in 17s
Tests / e2e (pull_request) Successful in 4m10s

tests/e2e/login.spec.mjs: assert the render process is alive with the `crash`
event instead of counting pageerrors; the failed-login test now accepts the
rate-limited message as well as the wrong-password one; the failure hook
attaches the console before the app guard so a launch failure still produces an
artifact, wraps `screenshot()` because it throws on a crashed page, and reaches
`fs.rmSync` on launch failure; dropped the duplicate login-form assertion.

playwright.config.mjs: pin `trace: 'off'` explicitly rather than relying on the
version default, since a trace captures the login POST body.

.gitea/workflows/tests.yml: dropped `--prefer-offline`; corrected the xvfb
comment (the guard is live for the host runner, which already has xvfb); dropped
an unresolvable CI run-number citation.

Checks: `node --check` on both JS files, `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:
2026-11-03 13:22:39 +11:00
parent 347acd0ebd
commit 1ddca42473
3 changed files with 41 additions and 25 deletions
+6 -4
View File
@@ -58,17 +58,19 @@ jobs:
# The E2E run drives the vite dev server, so cinny's dependencies are needed too. # The E2E run drives the vite dev server, so cinny's dependencies are needed too.
- name: Install dependencies (cinny) - name: Install dependencies (cinny)
working-directory: ./cinny working-directory: ./cinny
run: npm ci --prefer-offline run: npm ci
# Electron needs system libraries the runner image does not ship. Do not narrow this to # Electron needs system libraries the runner image does not ship. Do not narrow this to
# chromium: Playwright's chromium dep set covers its own bundled browser, not Electron, # chromium: Playwright's chromium dep set covers its own bundled browser, not Electron,
# and drops libgtk-3-0t64, libegl1, libegl-mesa0, libgles2, libsecret-1-0, libxtst6 and # and drops libgtk-3-0t64, libegl1, libegl-mesa0, libgles2, libsecret-1-0, libxtst6 and
# libxss1, which Electron needs to launch. Run 930 failed with "Process failed to launch!" # libxss1, which Electron needs to launch. Narrowing it fails with "Process failed to
# on the narrowed set. # launch!".
- name: Install system libraries for Electron - name: Install system libraries for Electron
run: npx playwright install-deps run: npx playwright install-deps
# The runner image has no xvfb and no fresh apt lists. # The container runner image has no xvfb and no fresh apt lists. The host runner already
# has xvfb, so the guard skips the install there; both share the ubuntu-latest label, so
# which one runs is not fixed.
- name: Ensure a display for Electron - name: Ensure a display for Electron
run: command -v xvfb-run >/dev/null || (sudo apt-get update && sudo apt-get install -y xvfb) run: command -v xvfb-run >/dev/null || (sudo apt-get update && sudo apt-get install -y xvfb)
+4
View File
@@ -10,7 +10,11 @@ export default defineConfig({
workers: 1, workers: 1,
// The suite logs in to a live homeserver, where Synapse login rate limiting is a real flake. // The suite logs in to a live homeserver, where Synapse login rate limiting is a real flake.
retries: process.env.CI ? 1 : 0, retries: process.env.CI ? 1 : 0,
// An explicit reporter replaces the default, so list stays for the CI log.
reporter: [['list'], ['html']], reporter: [['list'], ['html']],
// A trace captures the login POST body, which contains the password. Pin it off rather than
// relying on the version default.
trace: 'off',
// cinny/vite.config.js binds 0.0.0.0 with fs.allow: ['..'], which is exposed on a shared // cinny/vite.config.js binds 0.0.0.0 with fs.allow: ['..'], which is exposed on a shared
// CI runner, so pin the dev server to loopback. The flag has to reach vite itself: // CI runner, so pin the dev server to loopback. The flag has to reach vite itself:
// `npm run dev:vite -- --host` lands on sh's positional params, not on vite. // `npm run dev:vite -- --host` lands on sh's positional params, not on vite.
+31 -21
View File
@@ -11,6 +11,7 @@ let app;
let page; let page;
let logs = []; let logs = [];
let profile; let profile;
let crashed = false;
// ServerPicker gives its input no name or test id, so position is the only handle on it; // ServerPicker gives its input no name or test id, so position is the only handle on it;
// this breaks if the form ever gains a field before the ones below. // this breaks if the form ever gains a field before the ones below.
@@ -43,6 +44,7 @@ async function submitLogin(username, password) {
test.beforeEach(async () => { test.beforeEach(async () => {
logs = []; logs = [];
crashed = false;
if (!PASSWORD) { if (!PASSWORD) {
throw new Error('E2E_PASSWORD is not set. Export it, or add it as the CI secret.'); throw new Error('E2E_PASSWORD is not set. Export it, or add it as the CI secret.');
@@ -63,29 +65,37 @@ test.beforeEach(async () => {
} }
page.on('console', (msg) => logs.push(`[renderer] ${msg.type()}: ${msg.text()}`)); page.on('console', (msg) => logs.push(`[renderer] ${msg.type()}: ${msg.text()}`));
page.on('pageerror', (err) => logs.push(`[renderer] pageerror: ${err}`)); page.on('pageerror', (err) => logs.push(`[renderer] pageerror: ${err}`));
// crash is render-process-gone, so it does not fire on the MatrixError or the ServiceWorker error.
page.on('crash', () => {
crashed = true;
});
await chooseServer(HOMESERVER); await chooseServer(HOMESERVER);
}); });
// Config-based screenshots do not fire for a page taken from app.firstWindow(), and console // Config-based screenshots do not fire for a page taken from app.firstWindow(), and console
// capture is not covered by config at all, so this hook stays manual. Traces stay off because a // capture is not covered by config at all, so this hook stays manual.
// trace captures the login POST body.
test.afterEach(async ({}, testInfo) => { test.afterEach(async ({}, testInfo) => {
if (!app) return;
if (testInfo.status !== testInfo.expectedStatus) { if (testInfo.status !== testInfo.expectedStatus) {
if (page && !page.isClosed()) { // Console first: a failed launch has no app and no page, so this is the only artifact that
await testInfo.attach('failure.png', { body: await page.screenshot(), contentType: 'image/png' }); // path can produce.
}
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()) {
// screenshot() throws on a crashed page, which would mask the original failure.
const shot = await page.screenshot().catch(() => null);
if (shot) await testInfo.attach('failure.png', { body: shot, contentType: 'image/png' });
}
} }
await app if (app) {
.close() await app
// main.js preventDefault()s window close to minimise to tray, so close can hang. .close()
.catch(() => app.process().kill('SIGTERM')); // main.js preventDefault()s window close to minimise to tray, so close can hang.
.catch(() => app.process().kill('SIGTERM'));
}
fs.rmSync(profile, { recursive: true, force: true }); // Reachable on launch failure, so the temp profile does not leak.
if (profile) fs.rmSync(profile, { recursive: true, force: true });
}); });
async function expectAuthenticated() { async function expectAuthenticated() {
@@ -108,9 +118,6 @@ async function expectAuthenticated() {
return res.status; return res.status;
}) })
.toBe(200); .toBe(200);
// The login form is gone, so the app is on the authenticated shell.
await expect(usernameInput()).toHaveCount(0);
} }
test('test account can log in and reaches the authenticated app', async () => { test('test account can log in and reaches the authenticated app', async () => {
@@ -118,14 +125,17 @@ test('test account can log in and reaches the authenticated app', async () => {
await expectAuthenticated(); await expectAuthenticated();
}); });
test('failed login reports an error without crashing the app', async () => { test('failed login reports an error and keeps the renderer alive', async () => {
await submitLogin(USER, 'not-the-password'); await submitLogin(USER, 'not-the-password');
await expect(page.getByText('Invalid Username or Password.')).toBeVisible(); // A rate-limited run renders LoginError.RateLimited instead of the wrong-password message,
// so accept both branches rather than asserting one exact string.
await expect(page.getByText(/Invalid Username or Password\.|rate-limited by server/)).toBeVisible();
// "Without crashing" is proven by the form still rendering: a dead renderer cannot render it. // A dead renderer cannot render the form. Pageerrors go into the artifact but are not
// Pageerrors go into the artifact but are not asserted — the failed login itself produces // asserted — the failed login itself produces MatrixError, and dev mode produces a
// MatrixError, and dev mode produces a ServiceWorker registration error. No second login // ServiceWorker registration error. No second login here: every run costs Synapse rc_login
// here: every run costs Synapse rc_login budget, and the re-login was the main flake source. // budget, and the re-login was the main flake source.
await expect(usernameInput()).toBeVisible(); await expect(usernameInput()).toBeVisible();
await expect(crashed).toBe(false);
}); });