Skip to content

test(e2e): cover closing the app menu with the scrim and reopening it - #713

Merged
manusa merged 2 commits into
mainfrom
test/app-menu-reopen
Sep 13, 2026
Merged

manusa merged 2 commits into
mainfrom
test/app-menu-reopen

Conversation

@manusa

@manusa manusa commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

What this covers

The open → scrim click → close → reopen chain, end to end.

Every link is already tested, but only with its neighbours mocked:

layer existing test
scrim click → close() (JSDOM) src/app-menu/__tests__/app-menu.browser.test.mjs:31
close → appMenuClose channel src/app-menu/__tests__/preload.test.js:49
IPC → destroy on close, rebuild on open src/main/__tests__/global-listeners.test.js

Nothing proved that a real scrim click in a real renderer reaches the real main process and leaves the menu reopenable — the e2e suites (about, help) only ever open the menu once and never close it. This closes that gap, and catches a broken scrim handler, a bad guard in appMenuOpen, or a menu that fails to be rebuilt for the next open.

Verified it fails on broken code

A test that has never been seen to fail isn't evidence of anything, so both halves were mutation-checked:

mutation result
appMenuClose made a no-op close assertion fails
appMenuOpen refuses the second open all 4 reopen assertions fail

What it deliberately does NOT prove

The suite carries a long comment about this, and it's the part most worth keeping.

It cannot show the reopened menu is visible. A WebContentsView can be attached, visible, correctly bounded and backed by a perfectly healthy renderer while compositing nothing — which is exactly what happens on Linux when a view is attached a second time (see the comment above destroyAppMenu in src/main/index.js). In that state isDestroyed() is false, isLoading() is false, the DOM is laid out, and every assertion in this file still passes while the window is blank and dead to both mouse and keyboard.

Playwright cannot see it: DOM visibility is renderer-side and the renderer is fine; what fails is that the view's composited output never reaches the window. Catching that requires scoring the composited window from outside the process — see the experiment/x11-repaint-harness branch.

So this suite must not be renamed into something that claims to guard the repaint bug, and a green run here is not evidence that reopening the menu works on Linux.

Testing

New suite passes (5/5). Note keyboard-shortcuts.test.e2e.js currently fails its 2 F11 fullscreen assertions on my machine — reproduced without this change and in isolation, so it is pre-existing environmental flakiness, unrelated to this PR.

Every link in the open -> scrim click -> close -> reopen chain was already
tested, but only with its neighbours mocked: app-menu.browser.test.mjs fires
the wrapper click in JSDOM, preload.test.js maps close to the appMenuClose
channel, and global-listeners.test.js drives the main process side. Nothing
proved a real scrim click in a real renderer reaches the real main process and
leaves the menu reopenable. The e2e suites only ever opened the menu once.

Verified it fails on broken code rather than assuming it would. Making
appMenuClose a no-op fails the close assertion; making appMenuOpen refuse the
second open fails all four reopen assertions.

The suite carries a long comment about what it does NOT prove, which is the
part worth keeping: it cannot show the reopened menu is visible. A
WebContentsView can be attached, visible, correctly bounded and backed by a
healthy renderer while compositing nothing, which is what happens on Linux when
a view is attached twice. In that state every assertion here still passes while
the window is blank and dead to mouse and keyboard, because DOM visibility is
renderer-side and the renderer is fine. Catching that needs the composited
window scored out of process; see experiment/x11-repaint-harness.
…exists

Two fixes to the reopen suite.

SonarLint flagged 'releases the app menu renderer' as having no assertion, since expect.poll is not recognised as one. Re-asserts the settled state synchronously, matching how the other e2e suites pair an awaited operation with a plain expect.

More importantly, the suite's mutation evidence did not survive contact with #712. It was validated against rebuild-on-open, where no app-menu window exists unless the menu was opened. With pre-warming, a menu renderer is always alive - built at startup and after every close - so waitForWindow matches one whether or not the click did anything, and the reopen assertions pass against a menu that was never attached.

Measured, with appMenuOpen mutated to refuse the second open: on main 4 of 5 tests fail, as the PR claimed; with #712 merged only 1 fails, via a 30s Playwright click timeout - the failure shape most likely to be dismissed as flake. Waiting on attachment restores it to 5 of 7 failing, and fast.

isAppMenuOpen mirrors the existing isFindInPageOpen helper. It says the view is attached, which is strictly weaker than visible: an attached view can composite nothing while its renderer stays healthy, so the suite's standing caveat about what it cannot prove is unchanged.

Full suites on Fedora: 1173 unit, 138 e2e.
@manusa
manusa force-pushed the test/app-menu-reopen branch from 960e14f to 1b41093 Compare September 13, 2026 04:52
@sonarqubecloud

Copy link
Copy Markdown

@manusa
manusa merged commit a571c19 into main Sep 13, 2026
6 checks passed
@manusa
manusa deleted the test/app-menu-reopen branch September 13, 2026 05:08
@manusa manusa added this to the 0.1.0 milestone Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant