Repository navigation
test(electron): drive IPC handlers with bad input instead of checking registration - #4338
Conversation
… registration Several Electron IPC tests only proved a channel was registered or spied the method they were meant to exercise, so a broken input check would still pass. They now invoke each handler the way the renderer does, with malformed input, and assert it is rejected with no side effect. - Updater: malformed release tags (traversal, query strings, trailing newline, non-strings) are refused without pinning or touching the feed. - Agent manager: unknown, empty and non-string ids never spawn a process or reach the backend, and uninstall ids stay URL-encoded. - Notifications: a late or repeated renderer response cannot overturn an answer already sent to the agent. - Install progress window: first test coverage for its IPC handlers, progress buffering and failure-dialog routing. Part of amd#4258
|
Verdict: Approve with suggestions This PR replaces Electron IPC tests that only checked "is this channel registered" with tests that actually call each handler the way the renderer does — including with malformed input — and adds first-time coverage for the install progress window. The tests are real: I reproduced both mutation claims from the test plan exactly, so these tests would catch the regressions they're written to catch. Nothing blocking. Three small things worth a follow-up:
Real-world evidenceNo Both mutation claims in the test plan reproduce exactly: Three consecutive randomized-order runs ( 🔍 Technical detailsIssues🟢 The three deleted tests were the only thing asserting that 🟢
🟢 Each of these ends with a bare 🟢 The new block adds a real not-running rejection test, but the adjacent happy-path test still spies on Strengths
|
Several Electron IPC tests passed without ever calling the handler with bad input. They only checked that a channel was registered, or they mocked out the method under test. A broken check would still pass: the updater could accept a path-traversal release tag, or the agent manager could spawn a process for an unknown id, with no test failing. These tests now call each handler the way the renderer does, pass malformed input, and assert that the call is rejected and nothing else happens. The install progress window had no tests at all and now has coverage. This PR changes tests only. Temporarily loosening the updater's tag regex fails 7 of the new tests, and removing the agent-id and URL-encoding guards fails 11.
Tray-manager
tray:set-configvalidation is left to #4299 and #4330, which already add those tests.Test plan
cd tests/electron && npm ci && npx jest(26 suites, 770 tests pass on Node 20)TAG_REinauto-updater.cjsto/^v\d+\.\d+\.\d+/: 7 new tag tests failencodeURIComponentinagent-process-manager.cjs: 11 new IPC tests failPart of #4258