Skip to content

Commit 5524ad3

Browse files
committed
test(ui): align ResetConnectionDialog test with machine-driven reset
1 parent 4a91f38 commit 5524ad3

1 file changed

Lines changed: 7 additions & 20 deletions

File tree

packages/ui/src/components/ConfigureSSO/__tests__/ResetConnectionDialog.test.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,11 @@ import { bindCreateFixtures } from '@/test/create-fixtures';
55
import { render, screen, waitFor } from '@/test/utils';
66
import { CardStateProvider } from '@/ui/elements/contexts';
77

8-
const goToStep = vi.fn();
9-
10-
vi.mock('../elements/Wizard', () => ({
11-
useWizard: () => ({
12-
activeSteps: [],
13-
currentStep: undefined,
14-
currentIndex: -1,
15-
totalSteps: 0,
16-
isFirstStep: true,
17-
isLastStep: false,
18-
isNested: false,
19-
goNext: vi.fn(),
20-
goPrev: vi.fn(),
21-
goToStep,
22-
registerStep: vi.fn(),
23-
unregisterStep: vi.fn(),
24-
}),
8+
const dispatch = vi.fn();
9+
10+
vi.mock('../elements/WizardMachineContext', () => ({
11+
useWizardMachine: () => ({ dispatch }),
12+
WizardMachineProvider: ({ children }: { children: React.ReactNode }) => children,
2513
}));
2614

2715
const setProvider = vi.fn();
@@ -70,11 +58,10 @@ const renderDialog = (
7058
};
7159

7260
const resetMocks = () => {
73-
goToStep.mockReset();
61+
dispatch.mockReset();
7462
setProvider.mockReset();
7563
deleteEnterpriseConnection.mockReset();
7664
deleteEnterpriseConnection.mockResolvedValue({} as DeletedObjectResource);
77-
goToStep.mockResolvedValue(undefined);
7865
connectionMockState.current = { id: 'idn_connection_1' };
7966
};
8067

@@ -156,7 +143,7 @@ describe('ResetConnectionDialog', () => {
156143
expect(deleteEnterpriseConnection).toHaveBeenCalledWith('idn_connection_1');
157144
});
158145
expect(setProvider).toHaveBeenCalledWith(undefined);
159-
expect(goToStep).toHaveBeenCalledWith('select-provider');
146+
expect(dispatch).toHaveBeenCalledWith({ type: 'RESET' });
160147
await waitFor(() => {
161148
expect(onClose).toHaveBeenCalledTimes(1);
162149
});

0 commit comments

Comments
 (0)