@antelopejs/dms-assistant 0.2.7-next.444.g0da96b6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/package.json +6 -2
  2. package/frontend-vue/builder/tests/database-build.test.ts +0 -232
  3. package/frontend-vue/builder/tests/database-connect.test.ts +0 -348
  4. package/frontend-vue/builder/tests/database-display.test.ts +0 -112
  5. package/frontend-vue/builder/tests/database.test.ts +0 -138
  6. package/frontend-vue/builder/tests/enabled.test.ts +0 -17
  7. package/frontend-vue/builder/tests/owner-ui.test.ts +0 -29
  8. package/frontend-vue/builder/tests/stubs/frontend-module.ts +0 -63
  9. package/frontend-vue/builder/vitest.config.ts +0 -21
  10. package/frontend-vue/tests/assistant-actions.test.ts +0 -109
  11. package/frontend-vue/tests/assistant-activity.test.ts +0 -281
  12. package/frontend-vue/tests/backend-boundary.test.ts +0 -130
  13. package/frontend-vue/tests/backoff.test.ts +0 -40
  14. package/frontend-vue/tests/block-health.test.ts +0 -142
  15. package/frontend-vue/tests/channel-client.test.ts +0 -246
  16. package/frontend-vue/tests/chat/block-preview.test.ts +0 -367
  17. package/frontend-vue/tests/chat/block-target.test.ts +0 -133
  18. package/frontend-vue/tests/chat/build-view.test.ts +0 -171
  19. package/frontend-vue/tests/chat/chat-scroll.test.ts +0 -251
  20. package/frontend-vue/tests/chat/conversation-events.test.ts +0 -622
  21. package/frontend-vue/tests/chat/diff-and-keys.test.ts +0 -178
  22. package/frontend-vue/tests/chat/held-card.test.ts +0 -133
  23. package/frontend-vue/tests/chat/markdown-content.test.ts +0 -86
  24. package/frontend-vue/tests/chat/markdown.test.ts +0 -352
  25. package/frontend-vue/tests/chat/provider-notice.test.ts +0 -33
  26. package/frontend-vue/tests/chat/tool-lexicon.test.ts +0 -212
  27. package/frontend-vue/tests/chat/useChatChannel.test.ts +0 -124
  28. package/frontend-vue/tests/chat/useConversation.test.ts +0 -288
  29. package/frontend-vue/tests/chat-panel.test.ts +0 -300
  30. package/frontend-vue/tests/chat-transport.test.ts +0 -94
  31. package/frontend-vue/tests/embedding.test.ts +0 -10
  32. package/frontend-vue/tests/formal/connection-analysis-scenarios.ts +0 -130
  33. package/frontend-vue/tests/formal/connection-analysis-world.ts +0 -497
  34. package/frontend-vue/tests/formal/connection-analysis.test.ts +0 -36
  35. package/frontend-vue/tests/host-commands.test.ts +0 -182
  36. package/frontend-vue/tests/launcher-icon.test.ts +0 -62
  37. package/frontend-vue/tests/launcher-label.test.ts +0 -40
  38. package/frontend-vue/tests/launcher-state.test.ts +0 -215
  39. package/frontend-vue/tests/mockup-fold.test.ts +0 -95
  40. package/frontend-vue/tests/navigation.test.ts +0 -142
  41. package/frontend-vue/tests/onboarding-api.test.ts +0 -29
  42. package/frontend-vue/tests/onboarding-claude.test.ts +0 -144
  43. package/frontend-vue/tests/onboarding-connect-memory.test.ts +0 -126
  44. package/frontend-vue/tests/onboarding-controller-restart.test.ts +0 -134
  45. package/frontend-vue/tests/onboarding-controller.test.ts +0 -307
  46. package/frontend-vue/tests/onboarding-database-driver-install.test.ts +0 -112
  47. package/frontend-vue/tests/onboarding-database-engines.test.ts +0 -142
  48. package/frontend-vue/tests/onboarding-database-new-url.test.ts +0 -174
  49. package/frontend-vue/tests/onboarding-database-reload.test.ts +0 -229
  50. package/frontend-vue/tests/onboarding-database-tabs.test.ts +0 -184
  51. package/frontend-vue/tests/onboarding-database.test.ts +0 -540
  52. package/frontend-vue/tests/onboarding-deep-link.test.ts +0 -51
  53. package/frontend-vue/tests/onboarding-flow.test.ts +0 -204
  54. package/frontend-vue/tests/onboarding-install.test.ts +0 -62
  55. package/frontend-vue/tests/onboarding-mockups.test.ts +0 -86
  56. package/frontend-vue/tests/onboarding-scratch.test.ts +0 -70
  57. package/frontend-vue/tests/onboarding-widget.test.ts +0 -97
  58. package/frontend-vue/tests/palette-assistant.test.ts +0 -241
  59. package/frontend-vue/tests/panel-approvals.test.ts +0 -226
  60. package/frontend-vue/tests/panel-closed-conversation.test.ts +0 -53
  61. package/frontend-vue/tests/panel-mockup-prompt.test.ts +0 -238
  62. package/frontend-vue/tests/panel-modes.test.ts +0 -131
  63. package/frontend-vue/tests/panel-questions.test.ts +0 -151
  64. package/frontend-vue/tests/panel-states.test.ts +0 -252
  65. package/frontend-vue/tests/panel-tools.test.ts +0 -219
  66. package/frontend-vue/tests/session-gate.test.ts +0 -66
  67. package/frontend-vue/tests/sidecar-guest.test.ts +0 -81
  68. package/frontend-vue/tests/sidecar-status.test.ts +0 -117
  69. package/frontend-vue/tests/support/api-error-presenter.ts +0 -30
  70. package/frontend-vue/tests/support/database-connect.ts +0 -129
  71. package/frontend-vue/tests/support/dms-frontend-module.ts +0 -9
  72. package/frontend-vue/tests/support/dms-state.ts +0 -12
  73. package/frontend-vue/tests/support/fake-layout.ts +0 -119
  74. package/frontend-vue/tests/support/i18n.ts +0 -49
  75. package/frontend-vue/tests/support/onboarding-host.ts +0 -104
  76. package/frontend-vue/tests/support/onboarding.ts +0 -176
  77. package/frontend-vue/tests/support/panel-fixtures.ts +0 -155
  78. package/frontend-vue/tests/support/panel-harness.ts +0 -211
  79. package/frontend-vue/tests/support/setup-layout.ts +0 -3
  80. package/frontend-vue/tests/support/stand-ins/DmsBlockPreview.ts +0 -18
  81. package/frontend-vue/tests/support/stand-ins/DmsEmptyState.ts +0 -17
  82. package/frontend-vue/tests/support/stand-ins/DmsSegmentedControl.ts +0 -35
  83. package/frontend-vue/tests/support/stand-ins/DmsStatusPill.ts +0 -7
  84. package/frontend-vue/tests/support/stand-ins/OnboardingModal.ts +0 -13
  85. package/frontend-vue/tests/support/stand-ins/UBadge.ts +0 -7
  86. package/frontend-vue/tests/support/stand-ins/UButton.ts +0 -27
  87. package/frontend-vue/tests/support/stand-ins/UCheckbox.ts +0 -25
  88. package/frontend-vue/tests/support/stand-ins/UDropdownMenu.ts +0 -34
  89. package/frontend-vue/tests/support/stand-ins/UFormField.ts +0 -9
  90. package/frontend-vue/tests/support/stand-ins/UInput.ts +0 -16
  91. package/frontend-vue/tests/support/stand-ins/UKbd.ts +0 -7
  92. package/frontend-vue/tests/support/stand-ins/UModal.ts +0 -20
  93. package/frontend-vue/tests/support/stand-ins/UPopover.ts +0 -9
  94. package/frontend-vue/tests/support/stand-ins/UTabs.ts +0 -31
  95. package/frontend-vue/tests/support/stand-ins/UTextarea.ts +0 -19
  96. package/frontend-vue/tests/support/stubs.ts +0 -28
  97. package/frontend-vue/tests/views/api-data-reads.test.ts +0 -451
  98. package/frontend-vue/tests/views/api-error-presentation.test.ts +0 -89
  99. package/frontend-vue/tests/views/diff-view.test.ts +0 -167
  100. package/frontend-vue/tests/views/use-assistant.test.ts +0 -53
  101. package/frontend-vue/tests/views/view-format.test.ts +0 -59
  102. package/frontend-vue/vitest.config.ts +0 -33
@@ -1,62 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { mount } from "@vue/test-utils";
3
- import { afterEach, describe, expect, it } from "vitest";
4
- import { defineComponent, h, nextTick } from "vue";
5
- import LauncherIcon from "../app/components/LauncherIcon.vue";
6
- import type { LauncherState } from "../app/runtime/launcher-state";
7
- import { createHarness, providedSession } from "./support/panel-harness";
8
-
9
- const UIcon = defineComponent({
10
- name: "UIcon",
11
- props: { name: { type: String, required: true } },
12
- setup: (props) => () => h("i", { class: "u-icon", "data-name": props.name }),
13
- });
14
-
15
- const mounted: Array<{ unmount: () => void }> = [];
16
-
17
- afterEach(() => {
18
- mounted.splice(0).forEach((wrapper) => wrapper.unmount());
19
- });
20
-
21
- function mountIcon(provide: ReturnType<typeof providedSession>) {
22
- const wrapper = mount(LauncherIcon, {
23
- global: { provide, components: { UIcon } },
24
- });
25
- mounted.push(wrapper);
26
- return wrapper;
27
- }
28
-
29
- describe("the launcher icon", () => {
30
- it("follows the session's state as it changes, one data-state per state", async () => {
31
- const harness = createHarness();
32
- const wrapper = mountIcon(providedSession(harness.session));
33
- const states: LauncherState[] = [
34
- "working",
35
- "question",
36
- "finished",
37
- "disconnected",
38
- "connected",
39
- ];
40
- expect(wrapper.attributes("data-state")).toBe("connected");
41
- for (const state of states) {
42
- harness.launcherState.value = state;
43
- await nextTick();
44
- expect(wrapper.attributes("data-state")).toBe(state);
45
- }
46
- });
47
-
48
- it("draws the sparkle and a status dot, hidden from assistive technology", () => {
49
- const wrapper = mountIcon(providedSession(createHarness().session));
50
- expect(wrapper.attributes("aria-hidden")).toBe("true");
51
- expect(wrapper.find(".u-icon").attributes("data-name")).toBe(
52
- "i-ph-sparkle",
53
- );
54
- expect(wrapper.find(".dms-assistant-launcher__dot").exists()).toBe(true);
55
- });
56
-
57
- it("draws the plain sparkle before the session exists", async () => {
58
- const wrapper = mountIcon(providedSession(null));
59
- expect(wrapper.attributes("data-state")).toBe("connected");
60
- expect(wrapper.find(".u-icon").exists()).toBe(true);
61
- });
62
- });
@@ -1,40 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { nextTick, ref } from "vue";
3
- import type { Translate } from "../app/chat/composables/useChatI18n";
4
- import {
5
- type LauncherAction,
6
- registerLauncher,
7
- } from "../app/runtime/assistant-commands";
8
- import type { LauncherState } from "../app/runtime/launcher-state";
9
-
10
- const LAUNCHER_KEY = "dms_assistant.panel.launcher";
11
-
12
- /** Like vue-i18n: `t` reads its messages reactively, and gives an empty name while they are missing, as the dashboard does. */
13
- function lateMessages(): {
14
- t: Translate;
15
- load: () => void;
16
- } {
17
- const messages = ref<Record<string, string>>({});
18
- return {
19
- t: (key) => messages.value[key] ?? "",
20
- load: () => {
21
- messages.value = { [LAUNCHER_KEY]: "Assistant" };
22
- },
23
- };
24
- }
25
-
26
- describe("the launcher's label", () => {
27
- it("names the assistant once the locale's messages load after the app mounted", async () => {
28
- const i18n = lateMessages();
29
- const registered: LauncherAction[] = [];
30
- const stop = registerLauncher(
31
- i18n.t,
32
- ref<LauncherState>("connected"),
33
- (action) => registered.push(action),
34
- );
35
- i18n.load();
36
- await nextTick();
37
- stop();
38
- expect(registered.at(-1)?.label).toBe("Assistant (Ctrl+Shift+K)");
39
- });
40
- });
@@ -1,215 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
- import { nextTick, ref } from "vue";
3
- import { LAUNCHER_FINISHED_HOLD_MS } from "../app/runtime/constants";
4
- import {
5
- createLauncherState,
6
- displayLauncher,
7
- type LauncherSnapshot,
8
- } from "../app/runtime/launcher-state";
9
-
10
- function launcher() {
11
- const isConnected = ref(true);
12
- const working = ref(0);
13
- const waiting = ref(0);
14
- const isPanelOpen = ref(false);
15
- const handle = createLauncherState({
16
- isConnected,
17
- working,
18
- waiting,
19
- isPanelOpen,
20
- });
21
- return { isConnected, working, waiting, isPanelOpen, ...handle };
22
- }
23
-
24
- async function settled<T>(change: () => T): Promise<void> {
25
- change();
26
- await nextTick();
27
- }
28
-
29
- beforeEach(() => {
30
- vi.useFakeTimers();
31
- });
32
-
33
- afterEach(() => {
34
- vi.useRealTimers();
35
- });
36
-
37
- const IDLE: LauncherSnapshot = {
38
- isConnected: true,
39
- working: 0,
40
- waiting: 0,
41
- isPanelOpen: false,
42
- };
43
-
44
- describe("the launcher's priorities", () => {
45
- it("ranks a disconnect over a question, a question over a turn, a turn over a finish (fails on any other order)", () => {
46
- const busy = { ...IDLE, working: 2, waiting: 1 };
47
- expect(displayLauncher("unseen", busy)).toBe("question");
48
- expect(displayLauncher("unseen", { ...busy, waiting: 0 })).toBe("working");
49
- expect(displayLauncher("unseen", { ...busy, isConnected: false })).toBe(
50
- "disconnected",
51
- );
52
- expect(displayLauncher("unseen", IDLE)).toBe("finished");
53
- expect(displayLauncher("idle", IDLE)).toBe("connected");
54
- });
55
- });
56
-
57
- describe("the launcher's state over a turn", () => {
58
- it("latches finished when a turn ends with the panel closed, and keeps it until the panel opens", async () => {
59
- const sources = launcher();
60
- expect(sources.state.value).toBe("connected");
61
- await settled(() => (sources.working.value = 1));
62
- expect(sources.state.value).toBe("working");
63
- await settled(() => (sources.working.value = 0));
64
- expect(sources.state.value).toBe("finished");
65
- await vi.advanceTimersByTimeAsync(10 * LAUNCHER_FINISHED_HOLD_MS);
66
- expect(sources.state.value).toBe("finished");
67
- await settled(() => (sources.isPanelOpen.value = true));
68
- expect(sources.state.value).toBe("connected");
69
- sources.stop();
70
- });
71
-
72
- it("shows a question, goes back to working once it is answered, then finishes", async () => {
73
- const sources = launcher();
74
- await settled(() => (sources.working.value = 1));
75
- await settled(() => (sources.waiting.value = 1));
76
- expect(sources.state.value).toBe("question");
77
- await settled(() => (sources.waiting.value = 0));
78
- expect(sources.state.value).toBe("working");
79
- await settled(() => (sources.working.value = 0));
80
- expect(sources.state.value).toBe("finished");
81
- sources.stop();
82
- });
83
-
84
- it("latches finished when a question goes away with no turn running", async () => {
85
- const sources = launcher();
86
- await settled(() => (sources.waiting.value = 1));
87
- expect(sources.state.value).toBe("question");
88
- await settled(() => (sources.waiting.value = 0));
89
- expect(sources.state.value).toBe("finished");
90
- sources.stop();
91
- });
92
-
93
- it("holds finished briefly when the panel was already open to see the turn end, then lets go", async () => {
94
- const sources = launcher();
95
- sources.isPanelOpen.value = true;
96
- await settled(() => (sources.working.value = 1));
97
- await settled(() => (sources.working.value = 0));
98
- expect(sources.state.value).toBe("finished");
99
- await vi.advanceTimersByTimeAsync(LAUNCHER_FINISHED_HOLD_MS - 1);
100
- expect(sources.state.value).toBe("finished");
101
- await vi.advanceTimersByTimeAsync(1);
102
- expect(sources.state.value).toBe("connected");
103
- sources.stop();
104
- });
105
-
106
- it("lets a new turn override finished, and times the next finished from its own end", async () => {
107
- const sources = launcher();
108
- sources.isPanelOpen.value = true;
109
- await settled(() => (sources.working.value = 1));
110
- await settled(() => (sources.working.value = 0));
111
- await vi.advanceTimersByTimeAsync(1_000);
112
- await settled(() => (sources.working.value = 1));
113
- expect(sources.state.value).toBe("working");
114
- await vi.advanceTimersByTimeAsync(LAUNCHER_FINISHED_HOLD_MS);
115
- expect(sources.state.value).toBe("working");
116
- await settled(() => (sources.working.value = 0));
117
- expect(sources.state.value).toBe("finished");
118
- await vi.advanceTimersByTimeAsync(LAUNCHER_FINISHED_HOLD_MS - 1);
119
- expect(sources.state.value).toBe("finished");
120
- await vi.advanceTimersByTimeAsync(1);
121
- expect(sources.state.value).toBe("connected");
122
- sources.stop();
123
- });
124
-
125
- it("shows disconnected over a running turn and a question, then follows them again (fails if a disconnect is not an override)", async () => {
126
- const sources = launcher();
127
- await settled(() => (sources.working.value = 1));
128
- await settled(() => (sources.waiting.value = 1));
129
- await settled(() => (sources.isConnected.value = false));
130
- expect(sources.state.value).toBe("disconnected");
131
- await settled(() => (sources.isConnected.value = true));
132
- expect(sources.state.value).toBe("question");
133
- sources.stop();
134
- });
135
-
136
- it("keeps an unseen finish across a disconnect (fails if the disconnected display resets the latch)", async () => {
137
- const sources = launcher();
138
- await settled(() => (sources.working.value = 1));
139
- await settled(() => (sources.working.value = 0));
140
- expect(sources.state.value).toBe("finished");
141
- await settled(() => (sources.isConnected.value = false));
142
- expect(sources.state.value).toBe("disconnected");
143
- await settled(() => (sources.isConnected.value = true));
144
- expect(sources.state.value).toBe("finished");
145
- sources.stop();
146
- });
147
-
148
- it("finishes a turn that ended while disconnected once the sidecar is back (fails if the latch follows the displayed state)", async () => {
149
- const sources = launcher();
150
- await settled(() => (sources.working.value = 1));
151
- await settled(() => (sources.isConnected.value = false));
152
- await settled(() => (sources.working.value = 0));
153
- expect(sources.state.value).toBe("disconnected");
154
- await settled(() => (sources.isConnected.value = true));
155
- expect(sources.state.value).toBe("finished");
156
- await settled(() => (sources.isPanelOpen.value = true));
157
- expect(sources.state.value).toBe("connected");
158
- sources.stop();
159
- });
160
-
161
- it("clears a finish the owner saw on its timer even when the panel closes during the hold (fails if closing the panel cancels the hold)", async () => {
162
- const sources = launcher();
163
- sources.isPanelOpen.value = true;
164
- await settled(() => (sources.working.value = 1));
165
- await settled(() => (sources.working.value = 0));
166
- expect(sources.state.value).toBe("finished");
167
- await vi.advanceTimersByTimeAsync(1_000);
168
- await settled(() => (sources.isPanelOpen.value = false));
169
- expect(sources.state.value).toBe("finished");
170
- await vi.advanceTimersByTimeAsync(LAUNCHER_FINISHED_HOLD_MS - 1_000);
171
- expect(sources.state.value).toBe("connected");
172
- await vi.advanceTimersByTimeAsync(60_000);
173
- expect(sources.state.value).toBe("connected");
174
- sources.stop();
175
- });
176
-
177
- it("keeps the hold's deadline when the panel reopens during it (fails if a panel change restarts the hold)", async () => {
178
- const sources = launcher();
179
- sources.isPanelOpen.value = true;
180
- await settled(() => (sources.working.value = 1));
181
- await settled(() => (sources.working.value = 0));
182
- await vi.advanceTimersByTimeAsync(1_000);
183
- await settled(() => (sources.isPanelOpen.value = false));
184
- await settled(() => (sources.isPanelOpen.value = true));
185
- expect(sources.state.value).toBe("finished");
186
- await vi.advanceTimersByTimeAsync(LAUNCHER_FINISHED_HOLD_MS - 1_001);
187
- expect(sources.state.value).toBe("finished");
188
- await vi.advanceTimersByTimeAsync(1);
189
- expect(sources.state.value).toBe("connected");
190
- sources.stop();
191
- });
192
-
193
- it("starts disconnected when the sidecar is not there at the first look", () => {
194
- const isConnected = ref(false);
195
- const handle = createLauncherState({
196
- isConnected,
197
- working: ref(0),
198
- waiting: ref(0),
199
- isPanelOpen: ref(false),
200
- });
201
- expect(handle.state.value).toBe("disconnected");
202
- handle.stop();
203
- });
204
-
205
- it("stops following and drops the pending hold when stopped", async () => {
206
- const sources = launcher();
207
- sources.isPanelOpen.value = true;
208
- await settled(() => (sources.working.value = 1));
209
- await settled(() => (sources.working.value = 0));
210
- sources.stop();
211
- expect(vi.getTimerCount()).toBe(0);
212
- await settled(() => (sources.working.value = 1));
213
- expect(sources.state.value).toBe("finished");
214
- });
215
- });
@@ -1,95 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { computed, nextTick, ref } from "vue";
3
- import { createMockupFold, isMockupPath } from "../app/runtime/mockup-fold";
4
-
5
- function dashboard(path: string, isOpen: boolean) {
6
- const route = ref(path);
7
- const open = ref(isOpen);
8
- const panel = {
9
- isOpen: computed(() => open.value),
10
- open: () => {
11
- open.value = true;
12
- },
13
- close: () => {
14
- open.value = false;
15
- },
16
- toggle: () => {
17
- open.value = !open.value;
18
- },
19
- };
20
- const fold = createMockupFold({ path: route, panel });
21
- return { route, open, fold };
22
- }
23
-
24
- describe("which pages fold the panel", () => {
25
- it("folds on /mockup and the pages under it only (fails on a prefix match such as /mockups)", () => {
26
- expect(isMockupPath("/mockup")).toBe(true);
27
- expect(isMockupPath("/mockup/bikes")).toBe(true);
28
- expect(isMockupPath("/mockups")).toBe(false);
29
- expect(isMockupPath("/dashboard")).toBe(false);
30
- });
31
- });
32
-
33
- describe("the panel on a mockup", () => {
34
- it("closes an open panel and shows the bar when a mockup opens (fails when the panel stays docked)", async () => {
35
- const { route, open, fold } = dashboard("/dashboard", true);
36
- route.value = "/mockup";
37
- await nextTick();
38
- expect(open.value).toBe(false);
39
- expect(fold.isFolded.value).toBe(true);
40
- });
41
-
42
- it("opens the panel again when the mockup is left, if the fold closed it (fails when the panel stays closed)", async () => {
43
- const { route, open } = dashboard("/dashboard", true);
44
- route.value = "/mockup";
45
- await nextTick();
46
- route.value = "/dashboard";
47
- await nextTick();
48
- expect(open.value).toBe(true);
49
- });
50
-
51
- it("leaves a panel the person had closed closed after the mockup (fails when leaving always opens it)", async () => {
52
- const { route, open, fold } = dashboard("/dashboard", false);
53
- route.value = "/mockup";
54
- await nextTick();
55
- expect(fold.isFolded.value).toBe(true);
56
- route.value = "/dashboard";
57
- await nextTick();
58
- expect(open.value).toBe(false);
59
- expect(fold.isFolded.value).toBe(false);
60
- });
61
-
62
- it("leaves the panel closed after the mockup when the person opened it some other way and closed it there (fails when leaving reopens a panel the person closed)", async () => {
63
- const { route, open, fold } = dashboard("/dashboard", true);
64
- route.value = "/mockup";
65
- await nextTick();
66
- open.value = true;
67
- await nextTick();
68
- open.value = false;
69
- await nextTick();
70
- expect(fold.isFolded.value).toBe(true);
71
- route.value = "/dashboard";
72
- await nextTick();
73
- expect(open.value).toBe(false);
74
- });
75
-
76
- it("folds a panel the dashboard opened on a mockup, as a reload does (fails when only a route change folds)", () => {
77
- const { open, fold } = dashboard("/mockup/bikes", true);
78
- expect(open.value).toBe(false);
79
- expect(fold.isFolded.value).toBe(true);
80
- });
81
-
82
- it("keeps the panel open on the mockup once the bar opened it, and when the mockup is left (fails when the fold closes it again)", async () => {
83
- const { route, open, fold } = dashboard("/mockup", false);
84
- fold.unfold();
85
- await nextTick();
86
- expect(open.value).toBe(true);
87
- expect(fold.isFolded.value).toBe(false);
88
- route.value = "/mockup/bikes";
89
- await nextTick();
90
- expect(open.value).toBe(true);
91
- route.value = "/dashboard";
92
- await nextTick();
93
- expect(open.value).toBe(true);
94
- });
95
- });
@@ -1,142 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { installCurrentPageTracker } from "../app/runtime/current-page";
4
- import { BLOCK_SETTLE_BUDGET_MS } from "../app/runtime/block-health";
5
- import { installNavigationCompleteEmitter } from "../app/runtime/navigation-complete";
6
-
7
- function navigate(url: string): void {
8
- document.dispatchEvent(
9
- new CustomEvent("inertia:navigate", {
10
- detail: { page: { url } },
11
- }),
12
- );
13
- }
14
-
15
- async function flushMutations(): Promise<void> {
16
- await new Promise((resolve) => setTimeout(resolve, 0));
17
- }
18
-
19
- describe("Inertia host navigation", () => {
20
- it("reports the initial pathname and completed visits, then unsubscribes", () => {
21
- window.history.replaceState({}, "", "/initial?tab=one#section");
22
- const send = vi.fn();
23
- const stop = installCurrentPageTracker({ send });
24
- expect(send).toHaveBeenLastCalledWith({
25
- type: "host_state_update",
26
- currentPage: { path: "/initial" },
27
- });
28
- navigate("/other/deep?tab=two#anchor");
29
- expect(send).toHaveBeenLastCalledWith({
30
- type: "host_state_update",
31
- currentPage: { path: "/other/deep" },
32
- });
33
- stop();
34
- navigate("/ignored");
35
- expect(send).toHaveBeenCalledTimes(2);
36
- });
37
-
38
- it("carries the document title and reports a title rendered after navigation", async () => {
39
- window.history.replaceState({}, "", "/orders");
40
- document.title = "Orders";
41
- const send = vi.fn();
42
- const stop = installCurrentPageTracker({ send });
43
- expect(send).toHaveBeenLastCalledWith({
44
- type: "host_state_update",
45
- currentPage: { path: "/orders", title: "Orders" },
46
- });
47
- navigate("/customers");
48
- document.title = "Customers";
49
- await flushMutations();
50
- expect(send).toHaveBeenLastCalledWith({
51
- type: "host_state_update",
52
- currentPage: { path: "/customers", title: "Customers" },
53
- });
54
- const sentCount = send.mock.calls.length;
55
- document.title = "Customers";
56
- await flushMutations();
57
- expect(send).toHaveBeenCalledTimes(sentCount);
58
- stop();
59
- document.title = "Ignored";
60
- await flushMutations();
61
- expect(send).toHaveBeenCalledTimes(sentCount);
62
- document.title = "";
63
- });
64
-
65
- it("emits completion at once after navigation, announcing the block report, and removes its event listener", () => {
66
- const send = vi.fn();
67
- const stop = installNavigationCompleteEmitter({ send });
68
- expect(send).not.toHaveBeenCalled();
69
- navigate("https://example.test/finished?view=graph#node");
70
- expect(send).toHaveBeenCalledExactlyOnceWith({
71
- type: "host_navigation_complete",
72
- path: "/finished",
73
- blocksWithinMs: BLOCK_SETTLE_BUDGET_MS,
74
- });
75
- stop();
76
- navigate("/ignored");
77
- expect(send).toHaveBeenCalledTimes(1);
78
- });
79
-
80
- describe("block report", () => {
81
- beforeEach(() => {
82
- document.body.replaceChildren();
83
- vi.useFakeTimers();
84
- });
85
-
86
- afterEach(() => {
87
- vi.useRealTimers();
88
- });
89
-
90
- function addChart(state: string): HTMLElement {
91
- const element = document.createElement("div");
92
- element.setAttribute("data-dms-block-state", state);
93
- element.setAttribute("data-dms-block-type", "ChartCard");
94
- element.setAttribute("data-dms-block", "revenue");
95
- document.body.append(element);
96
- return element;
97
- }
98
-
99
- it("follows the completion with the blocks showing no data", async () => {
100
- addChart("empty");
101
- const send = vi.fn();
102
- const stop = installNavigationCompleteEmitter({ send });
103
- navigate("/sales");
104
- await vi.advanceTimersByTimeAsync(BLOCK_SETTLE_BUDGET_MS);
105
- expect(send).toHaveBeenLastCalledWith({
106
- type: "host_page_blocks",
107
- path: "/sales",
108
- status: "settled",
109
- checked: 1,
110
- blocks: [{ path: "revenue", type: "ChartCard", state: "empty" }],
111
- });
112
- stop();
113
- });
114
-
115
- it("reports the first page as superseded when a second navigation starts", async () => {
116
- addChart("loading");
117
- const send = vi.fn();
118
- const stop = installNavigationCompleteEmitter({ send });
119
- navigate("/first");
120
- await vi.advanceTimersByTimeAsync(100);
121
- navigate("/second");
122
- await vi.advanceTimersByTimeAsync(0);
123
- expect(send).toHaveBeenCalledWith(
124
- expect.objectContaining({
125
- type: "host_page_blocks",
126
- path: "/first",
127
- status: "superseded",
128
- }),
129
- );
130
- stop();
131
- });
132
-
133
- it("reports nothing once stopped", async () => {
134
- const send = vi.fn();
135
- const stop = installNavigationCompleteEmitter({ send });
136
- navigate("/sales");
137
- stop();
138
- await vi.advanceTimersByTimeAsync(BLOCK_SETTLE_BUDGET_MS);
139
- expect(send).toHaveBeenCalledTimes(1);
140
- });
141
- });
142
- });
@@ -1,29 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { createOnboardingApi } from "../app/onboarding/api";
3
-
4
- describe("the onboarding api's token check", () => {
5
- it.each(["rejected", "unreachable", "malformed", "unsaved"] as const)(
6
- "keeps the %s answer the backend gave",
7
- async (reason) => {
8
- const api = createOnboardingApi({
9
- get: async () => undefined,
10
- post: async () => ({ ok: false, reason }),
11
- });
12
- expect(await api.checkClaudeToken("sk-ant-oat01-x")).toEqual({
13
- ok: false,
14
- reason,
15
- });
16
- },
17
- );
18
-
19
- it("reads an answer of another shape as Anthropic not answering", async () => {
20
- const api = createOnboardingApi({
21
- get: async () => undefined,
22
- post: async () => ({ ok: false, reason: "gone" }),
23
- });
24
- expect(await api.checkClaudeToken("sk-ant-oat01-x")).toEqual({
25
- ok: false,
26
- reason: "unreachable",
27
- });
28
- });
29
- });