Skip to content

test(mocks): pin electron mock shapes via satisfies Pick#2846

Merged
setchy merged 1 commit intomainfrom
tighten-electron-mocks
May 7, 2026
Merged

test(mocks): pin electron mock shapes via satisfies Pick#2846
setchy merged 1 commit intomainfrom
tighten-electron-mocks

Conversation

@afonsojramos
Copy link
Copy Markdown
Member

Summary

Generalises the PR #2839 safety pattern (satisfies Pick<SafeStorage, …> on storage.test.ts) to every other vi.mock('electron', …) factory in the test suite. Any future drift between a mocked Electron API and its real signature now fails tsc.

Already paid off: the new constraint surfaced two real, pre-existing mock drifts that this PR fixes:

  • dialog.showMessageBox mock returned {response} instead of {response, checkboxChecked}.
  • ipcRenderer.on mock returned void instead of IpcRenderer (chainable).

Verified

  • pnpm tsc --noEmit — clean.
  • pnpm test — 938/938 (renderer route timeouts are a preexisting flake; pass on retry).
  • Drift verification: temporarily changed globalShortcut.register to return a string — tsc errors with Type 'Mock<() => string>' is not assignable to type '(accelerator: string, callback: () => void) => boolean'.

Wraps each vi.mock('electron', ...) factory with satisfies Pick<Electron.X, '...'> on every mocked namespace, so any drift between the mock and Electron's real type signatures fails at tsc time. Caught two pre-existing drifts: showMessageBox missing checkboxChecked, and ipcRenderer.on returning void instead of IpcRenderer.
@github-actions github-actions Bot added the test Enhancements to test coverage or quality label May 7, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@setchy setchy merged commit 6a76a3c into main May 7, 2026
17 checks passed
@setchy setchy deleted the tighten-electron-mocks branch May 7, 2026 11:16
@github-actions github-actions Bot added this to the Release 7.0.0 milestone May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Enhancements to test coverage or quality

Development

Successfully merging this pull request may close these issues.

2 participants