Skip to content

Commit ac17d85

Browse files
test(web): add-project dialog test resets its shared project mock
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cf9aed4 commit ac17d85

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/web/src/components/AddProjectToMachineDialog.browser.test.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const project = vi.hoisted(() => {
88
let value: unknown = null;
99
const listeners = new Set<() => void>();
1010
return {
11+
// Each test starts from no project and no listeners left by an earlier test.
12+
setup: (initial: unknown) => {
13+
value = initial;
14+
listeners.clear();
15+
},
1116
get: () => value,
1217
set: (next: unknown) => {
1318
value = next;
@@ -64,7 +69,7 @@ const PROJECT = {
6469

6570
describe("AddProjectToMachineDialog", () => {
6671
it("closes when its project goes away", async () => {
67-
project.set(PROJECT);
72+
project.setup(PROJECT);
6873
await using screen = await render(<AddProjectToMachineDialogHost />);
6974

7075
await act(() => openAddProjectToMachine({ projectRef, targetEnvironmentId: null }));
@@ -76,7 +81,7 @@ describe("AddProjectToMachineDialog", () => {
7681
});
7782

7883
it("does not reopen for a project that vanished before the dialog showed", async () => {
79-
project.set(PROJECT);
84+
project.setup(PROJECT);
8085
await using screen = await render(<AddProjectToMachineDialogHost />);
8186

8287
await act(() => {

0 commit comments

Comments
 (0)