Skip to content

fix: test idempotency issues#51526

Merged
ckerr merged 7 commits into
42-x-yfrom
trop/42-x-y-bp-fix-test-idempotency-issues-1778099457770
May 7, 2026
Merged

fix: test idempotency issues#51526
ckerr merged 7 commits into
42-x-yfrom
trop/42-x-y-bp-fix-test-idempotency-issues-1778099457770

Conversation

@trop

@trop trop Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Backport of #51504

See that PR for details.

Notes: none.

trop Bot and others added 7 commits May 6, 2026 20:31
The getPath(name) and setPath(name, path) describe blocks both call
app.setPath('music', ...) without restoring the original value. This
causes subsequent tests that call app.getPath('music') to get a
corrupted path if test ordering changes.

Capture the original music path and restore it in afterEach().

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The commandLine.hasSwitch and commandLine.getSwitchValue tests append
switches (foobar1, foobar) that are never removed. These persist for
the entire process lifetime, which could affect tests that check for
switch presence or absence if test ordering changes.

Add afterEach hooks that call removeSwitch for each appended switch.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The 'validates process APIs access in sandboxed renderer' test sets
process.env.sandboxmain = 'foo' without cleaning it up. This env var
persists for all subsequent tests and could affect tests that compare
process.env snapshots.

Use defer() to delete the env var after the test completes.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The release-notes spec sets NOTES_CACHE_PATH in before() but never
deletes it. This env var persists for all subsequent test files and
could interfere with any code that checks for its presence.

Add an after() hook to delete the env var when the suite completes.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The app name tests restore app.name at the end of each test body. If
an assertion fails before the restoration line, the name stays
corrupted for all subsequent tests.

Move restoration to an afterEach hook so it always runs, and remove
the now-redundant inline restoration calls.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The 'can download from custom protocols' test registers an HTTP
protocol handler on session.defaultSession but never unregisters it.
This handler persists globally and could interfere with other tests
that use the same protocol name or the default session.

Use defer() to ensure the protocol is unregistered after the test.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
The 'reporting api' test sets setCertificateVerifyProc on
defaultSession to accept all certificates, but the finally block
only destroys the window and closes the server. The permissive
certificate handler persists globally, causing all subsequent tests
using defaultSession HTTPS requests to skip certificate verification.

Reset the handler to null in the finally block.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
@trop trop Bot requested a review from ckerr May 6, 2026 20:32
@trop trop Bot mentioned this pull request May 6, 2026
6 tasks
@ckerr ckerr added backport This is a backport PR semver/patch backwards-compatible bug fixes labels May 7, 2026
@ckerr ckerr merged commit e7021e3 into 42-x-y May 7, 2026
114 of 118 checks passed
@ckerr ckerr deleted the trop/42-x-y-bp-fix-test-idempotency-issues-1778099457770 branch May 7, 2026 11:58
@release-clerk

release-clerk Bot commented May 7, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant