Skip to content

Commit 5b44ed5

Browse files
committed
test(webview): pin the other half of the setState fixture's dependency
The previous commit asserted the doc-identity premise but left its twin in prose: this fixture kills the dispatch-interception mutant only because setState does not dispatch. If that ever changed, the state would still be replaced, the test would still pass, and the mutant would quietly survive — the same silent revival the doc premise had, in the other direction. A dispatch counter around the call pins it. Measured: making the fixture dispatch before setState reds the test, and the doc-comparison mutant still reds it too, so neither pin displaced the other.
1 parent 7ac2ac8 commit 5b44ed5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/webview/helpers/unstarved-frontier.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,18 @@ describe("a state replacement after the LAST gate is refused", () => {
350350
// Asserted inside the fixture rather than as its own `it`, because a separate
351351
// test would not be coupled to the state this one actually passes to setState.
352352
expect(replacement.doc).toBe(view.state.doc);
353+
// The other half of the same dependency: this fixture only kills the
354+
// dispatch-interception mutant because setState does NOT dispatch. If that ever
355+
// changed, the state would still be replaced, this test would still pass, and
356+
// that mutant would quietly survive again.
357+
let dispatches = 0;
358+
const realDispatch = view.dispatch.bind(view);
359+
view.dispatch = ((...args: Parameters<typeof realDispatch>) => {
360+
dispatches++;
361+
return realDispatch(...args);
362+
}) as typeof view.dispatch;
353363
view.setState(replacement);
364+
expect(dispatches).toBe(0);
354365
},
355366
})
356367
).toThrow(

0 commit comments

Comments
 (0)