Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveWizardNavigation } from "./AddProviderInstanceDialog.logic";
4
5describe("resolveWizardNavigation", () => {
6 const invalidId = { instanceIdError: "Instance ID is required." };
7 const validId = { instanceIdError: null };
8
9 it("allows moving from Driver to Identity before the instance id is valid", () => {
10 expect(resolveWizardNavigation(0, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
11 });
12
13 it("blocks Next from Identity to Config while the instance id is invalid", () => {
14 expect(resolveWizardNavigation(1, 2, 3, invalidId)).toEqual({
15 kind: "blocked",
16 step: 1,
17 error: "Instance ID is required.",
18 });
19 });
20
21 it("stops a direct Driver-to-Config skip at Identity and surfaces its error", () => {
22 expect(resolveWizardNavigation(0, 2, 3, invalidId)).toEqual({
23 kind: "blocked",
24 step: 1,
25 error: "Instance ID is required.",
26 });
27 });
28
29 it("allows advancing and skipping forward once the instance id is valid", () => {
30 expect(resolveWizardNavigation(1, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
31 expect(resolveWizardNavigation(0, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
32 });
33
34 it("always preserves backward Driver and Identity navigation", () => {
35 expect(resolveWizardNavigation(2, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
36 expect(resolveWizardNavigation(2, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
37 expect(resolveWizardNavigation(1, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
38 });
39
40 it("clamps requested steps to the wizard bounds", () => {
41 expect(resolveWizardNavigation(2, 8, 3, validId)).toEqual({ kind: "navigate", step: 2 });
42 expect(resolveWizardNavigation(0, -1, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
43 });
44});