Skip to content

Commit 5b67922

Browse files
committed
Move ipcRenderer.send stub restore to afterEach in CLI-installed test
The inline restore after assertions would leak the stub into subsequent tests if any assertion threw. Use the same afterEach + restoreIpcSend pattern already established in commit-message-warning-dialogs-test.tsx and path-text-and-link-button-test.tsx to guarantee cleanup.
1 parent 614ef96 commit 5b67922

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

app/test/unit/ui/small-action-and-dialog-surfaces-test.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import assert from 'node:assert'
2-
import { describe, it, mock } from 'node:test'
2+
import { afterEach, describe, it, mock } from 'node:test'
33
import * as React from 'react'
44

55
import { CICheckRunNoStepItem } from '../../../src/ui/check-runs/ci-check-run-no-steps'
66
import { fireEvent, render, screen } from '../../helpers/ui/render'
77

8+
let restoreIpcSend: (() => void) | null = null
9+
810
describe('small action and dialog surfaces', () => {
11+
afterEach(() => {
12+
restoreIpcSend?.()
13+
restoreIpcSend = null
14+
})
15+
916
it('renders the no-step check-run state and invokes the external-view callback', () => {
1017
let externalViewCount = 0
1118

@@ -51,6 +58,9 @@ describe('small action and dialog surfaces', () => {
5158
const electron = await import('electron')
5259
const previousSend = electron.ipcRenderer.send
5360
electron.ipcRenderer.send = () => {}
61+
restoreIpcSend = () => {
62+
electron.ipcRenderer.send = previousSend
63+
}
5464

5565
const { CLIInstalled } = await import(
5666
'../../../src/ui/cli-installed/cli-installed'
@@ -69,7 +79,5 @@ describe('small action and dialog surfaces', () => {
6979
fireEvent.click(okButton)
7080

7181
assert.equal(dismissedCount, 1)
72-
73-
electron.ipcRenderer.send = previousSend
7482
})
7583
})

0 commit comments

Comments
 (0)