@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,204 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import type {
3
- OnboardingState,
4
- ProviderLogin,
5
- } from "../app/onboarding/contract";
6
- import {
7
- firstFlow,
8
- type FirstViewInput,
9
- opensOnItsOwn,
10
- type OpeningInput,
11
- transition,
12
- } from "../app/onboarding/flow";
13
-
14
- const SIGNED_OUT: ProviderLogin = { status: "signed-out" };
15
- const CLAUDE_CLI: ProviderLogin = {
16
- status: "signed-in",
17
- source: "claude-cli",
18
- email: "owner@example.com",
19
- plan: "max",
20
- };
21
-
22
- function state(
23
- logins: Partial<OnboardingState["logins"]> = {},
24
- provider: OnboardingState["provider"] = "claude",
25
- ): OnboardingState {
26
- return {
27
- bootId: "boot-1",
28
- provider,
29
- logins: { claude: SIGNED_OUT, codex: SIGNED_OUT, ...logins },
30
- };
31
- }
32
-
33
- function input(overrides: Partial<FirstViewInput> = {}): FirstViewInput {
34
- return {
35
- state: state(),
36
- hasContent: false,
37
- canConnectDatabase: true,
38
- step: null,
39
- ...overrides,
40
- };
41
- }
42
-
43
- describe("the view the popup opens on", () => {
44
- it("is the welcome when no AI login works", () => {
45
- expect(firstFlow(input()).view).toEqual({ kind: "welcome" });
46
- });
47
-
48
- it("skips the welcome for a login found on the machine", () => {
49
- const flow = firstFlow(input({ state: state({ claude: CLAUDE_CLI }) }));
50
- expect(flow.view).toEqual({ kind: "ready", provider: "claude" });
51
- });
52
-
53
- it("offers the other provider's login when the assistant's own is signed out", () => {
54
- const flow = firstFlow(input({ state: state({ codex: CLAUDE_CLI }) }));
55
- expect(flow.view).toEqual({ kind: "ready", provider: "codex" });
56
- });
57
-
58
- it("is the AI step for an expired login, the assistant's provider chosen", () => {
59
- const expired: ProviderLogin = { status: "expired", source: "saved" };
60
- const flow = firstFlow(input({ state: state({ claude: expired }) }));
61
- expect(flow.view).toEqual({ kind: "ai", choice: "claude" });
62
- });
63
-
64
- it("is Continue once a login works and the project has content", () => {
65
- const flow = firstFlow(
66
- input({ state: state({ claude: CLAUDE_CLI }), hasContent: true }),
67
- );
68
- expect(flow.view).toEqual({ kind: "continue" });
69
- expect(flow.start).toBe("continue");
70
- });
71
-
72
- it("is the connect form for ?assistant=connect when a login works", () => {
73
- const flow = firstFlow(
74
- input({
75
- state: state({ claude: CLAUDE_CLI }),
76
- hasContent: true,
77
- step: "connect-database",
78
- }),
79
- );
80
- expect(flow.view).toEqual({ kind: "connect-database" });
81
- });
82
-
83
- it("goes through the AI step for ?assistant=connect without a login, then on to the connect form", () => {
84
- const flow = firstFlow(input({ step: "connect-database" }));
85
- expect(flow.view).toEqual({ kind: "ai", choice: "claude" });
86
- const token = transition(flow, { type: "sign-in", provider: "claude" });
87
- expect(token.view).toEqual({ kind: "claude" });
88
- const connected = transition(token, {
89
- type: "signed-in",
90
- provider: "claude",
91
- });
92
- expect(connected.view).toEqual({ kind: "connect-database" });
93
- });
94
-
95
- it("ignores ?assistant=connect without the builder, as there is no form to open", () => {
96
- const flow = firstFlow(
97
- input({
98
- state: state({ claude: CLAUDE_CLI }),
99
- canConnectDatabase: false,
100
- step: "connect-database",
101
- }),
102
- );
103
- expect(flow.view).toEqual({ kind: "ready", provider: "claude" });
104
- });
105
- });
106
-
107
- describe("moving through the popup", () => {
108
- it("confirms a new login, then leads to the starting point", () => {
109
- const welcome = firstFlow(input());
110
- const ai = transition(welcome, { type: "get-started" });
111
- const codex = transition(
112
- transition(ai, { type: "choose", provider: "codex" }),
113
- { type: "sign-in", provider: "codex" },
114
- );
115
- expect(codex.view).toEqual({ kind: "codex", mode: "idle" });
116
- const connected = transition(codex, {
117
- type: "signed-in",
118
- provider: "codex",
119
- });
120
- expect(connected.view).toEqual({ kind: "connected", provider: "codex" });
121
- expect(transition(connected, { type: "next" }).view).toEqual({
122
- kind: "paths",
123
- });
124
- });
125
-
126
- it("goes back to the view it came from, and to the starting point once a login worked", () => {
127
- const ready = firstFlow(
128
- input({ state: state({ claude: CLAUDE_CLI }), hasContent: true }),
129
- );
130
- const scratch = transition(ready, { type: "pick", path: "scratch" });
131
- expect(transition(scratch, { type: "back" }).view).toEqual({
132
- kind: "continue",
133
- });
134
- const ai = transition(firstFlow(input()), { type: "get-started" });
135
- expect(transition(ai, { type: "back" }).view).toEqual({ kind: "welcome" });
136
- const signedIn = transition(
137
- transition(ai, { type: "sign-in", provider: "claude" }),
138
- { type: "signed-in", provider: "claude" },
139
- );
140
- expect(signedIn.history).toEqual([]);
141
- });
142
-
143
- it("keeps an analysis off the Back path, so the written connection is not submitted again", () => {
144
- const form = transition(
145
- firstFlow(input({ state: state({ claude: CLAUDE_CLI }) })),
146
- {
147
- type: "pick",
148
- path: "connect-database",
149
- },
150
- );
151
- const analysis = transition(form, {
152
- type: "analysed",
153
- connection: "shop",
154
- module: "builder-db-shop-tables",
155
- });
156
- expect(transition(analysis, { type: "back" }).view).toEqual({
157
- kind: "ready",
158
- provider: "claude",
159
- });
160
- });
161
- });
162
-
163
- describe("whether the popup opens on its own", () => {
164
- function opening(overrides: Partial<OpeningInput> = {}): OpeningInput {
165
- return {
166
- done: true,
167
- dontShow: false,
168
- bootId: "boot-2",
169
- seenBootId: "boot-1",
170
- step: null,
171
- ...overrides,
172
- };
173
- }
174
-
175
- it("reopens once per server start after onboarding", () => {
176
- expect(opensOnItsOwn(opening())).toBe(true);
177
- expect(opensOnItsOwn(opening({ seenBootId: "boot-2" }))).toBe(false);
178
- });
179
-
180
- it("stays closed once Don't show on startup is ticked, on this start as on a new one", () => {
181
- expect(
182
- opensOnItsOwn(opening({ dontShow: true, seenBootId: "boot-2" })),
183
- ).toBe(false);
184
- expect(opensOnItsOwn(opening({ dontShow: true }))).toBe(false);
185
- });
186
-
187
- it("opens on every load until onboarding is done", () => {
188
- expect(opensOnItsOwn(opening({ done: false, seenBootId: "boot-2" }))).toBe(
189
- true,
190
- );
191
- });
192
-
193
- it("opens for a step a link asked for, whatever the preference", () => {
194
- expect(
195
- opensOnItsOwn(
196
- opening({
197
- dontShow: true,
198
- seenBootId: "boot-2",
199
- step: "connect-database",
200
- }),
201
- ),
202
- ).toBe(true);
203
- });
204
- });
@@ -1,62 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import {
4
- resetBrowser,
5
- silenceStartup,
6
- startWithBackend,
7
- UNFINISHED,
8
- widget,
9
- } from "./support/onboarding-host";
10
-
11
- vi.mock("#dms/frontend-module", async () => {
12
- const { dmsModule } = await import("./support/dms-state");
13
- return dmsModule;
14
- });
15
-
16
- beforeEach(silenceStartup);
17
- afterEach(resetBrowser);
18
-
19
- describe("a backend that does not answer the first read", () => {
20
- it("still registers the chip, and a click of it opens the popup once the backend answers", async () => {
21
- const { provided, stop } = startWithBackend({
22
- stateAnswers: [
23
- async () => {
24
- throw new Error("503");
25
- },
26
- UNFINISHED,
27
- ],
28
- conversations: [],
29
- });
30
- await vi.waitFor(() => expect(widget()).toBeDefined());
31
- expect(provided.value?.isAvailable.value).toBe(false);
32
- expect(widget()).not.toHaveProperty("badge");
33
-
34
- provided.value?.open();
35
- await vi.waitFor(() => expect(provided.value?.isOpen.value).toBe(true));
36
- expect(provided.value?.isAvailable.value).toBe(true);
37
- stop();
38
- });
39
-
40
- it("keeps the step a deep link asked for until the popup can open", async () => {
41
- window.history.pushState({}, "", "/?assistant=connect");
42
- const { provided, stop } = startWithBackend(
43
- {
44
- stateAnswers: [
45
- async () => {
46
- throw new Error("503");
47
- },
48
- UNFINISHED,
49
- ],
50
- conversations: [],
51
- },
52
- { assistant: "connect" },
53
- );
54
- await vi.waitFor(() => expect(widget()).toBeDefined());
55
- provided.value?.open();
56
- await vi.waitFor(() => expect(provided.value?.isOpen.value).toBe(true));
57
- expect(provided.value?.flow.value.view).toEqual({
58
- kind: "connect-database",
59
- });
60
- stop();
61
- });
62
- });
@@ -1,86 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { listMockups, MOCKUPS_PATH } from "../app/onboarding/mockups";
3
-
4
- const SHOP = {
5
- name: "shop",
6
- title: "Shop back office",
7
- pages: 3,
8
- openComments: 2,
9
- source: "claude-code",
10
- updatedAt: "2026-11-12T09:00:00.000Z",
11
- status: "built",
12
- builtAt: "2026-11-12T10:00:00.000Z",
13
- builtPages: [{ path: "/orders", title: "Orders" }],
14
- };
15
-
16
- const CRM = {
17
- name: "crm",
18
- pages: 1,
19
- openComments: 0,
20
- updatedAt: "2026-11-13T08:00:00.000Z",
21
- status: "draft",
22
- };
23
-
24
- function answering(body: unknown) {
25
- return async (path: string) => {
26
- expect(path).toBe(MOCKUPS_PATH);
27
- return body;
28
- };
29
- }
30
-
31
- describe("the popup's mockups", () => {
32
- it("reads the rows of GET /api/mockup, latest first, titled by their name when they have no title", async () => {
33
- const mockups = await listMockups(
34
- answering({ results: [SHOP, CRM], total: 2 }),
35
- );
36
- expect(mockups).toEqual([
37
- {
38
- name: "crm",
39
- title: "crm",
40
- pages: 1,
41
- source: undefined,
42
- status: "draft",
43
- updatedAtMs: Date.parse(CRM.updatedAt),
44
- openComments: 0,
45
- },
46
- {
47
- name: "shop",
48
- title: "Shop back office",
49
- pages: 3,
50
- source: "claude-code",
51
- status: "built",
52
- updatedAtMs: Date.parse(SHOP.updatedAt),
53
- openComments: 2,
54
- },
55
- ]);
56
- });
57
-
58
- it("leaves out a row of another shape and keeps the others", async () => {
59
- const mockups = await listMockups(
60
- answering({ results: [{ ...SHOP, name: undefined }, CRM], total: 2 }),
61
- );
62
- expect(mockups.map((mockup) => mockup.name)).toEqual(["crm"]);
63
- });
64
-
65
- it("lists a mockup whose source it does not know, without a source", async () => {
66
- const mockups = await listMockups(
67
- answering({ results: [{ ...CRM, source: "cursor" }], total: 1 }),
68
- );
69
- expect(mockups).toHaveLength(1);
70
- expect(mockups[0]?.source).toBeUndefined();
71
- });
72
-
73
- it("reads a DMS without the mockups route as none", async () => {
74
- const mockups = await listMockups(async () => {
75
- throw Object.assign(new Error("Not Found"), { statusCode: 404 });
76
- });
77
- expect(mockups).toEqual([]);
78
- });
79
-
80
- it("passes on any other failure", async () => {
81
- const failing = listMockups(async () => {
82
- throw Object.assign(new Error("Server Error"), { statusCode: 500 });
83
- });
84
- await expect(failing).rejects.toThrow("Server Error");
85
- });
86
- });
@@ -1,70 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { flushPromises, mount } from "@vue/test-utils";
3
- import { afterEach, describe, expect, it } from "vitest";
4
- import Onboarding from "../app/components/Onboarding.vue";
5
- import {
6
- CLAUDE_LOGIN,
7
- createOnboardingHarness,
8
- ONBOARDING_STUBS,
9
- type OnboardingHarness,
10
- onboardingState,
11
- } from "./support/onboarding";
12
-
13
- let harness: OnboardingHarness;
14
-
15
- afterEach(() => {
16
- harness.controller.stop();
17
- });
18
-
19
- async function popupOnScratch() {
20
- harness = createOnboardingHarness({
21
- state: onboardingState({ claude: CLAUDE_LOGIN }),
22
- });
23
- const wrapper = mount(Onboarding, {
24
- global: { provide: harness.provide, stubs: ONBOARDING_STUBS },
25
- });
26
- await harness.controller.load();
27
- await flushPromises();
28
- expect(wrapper.text()).toContain("Your assistant is ready");
29
- harness.controller.send({ type: "use-login" });
30
- harness.controller.send({ type: "pick", path: "scratch" });
31
- await flushPromises();
32
- return wrapper;
33
- }
34
-
35
- describe("starting from scratch", () => {
36
- it("closes the popup and sends the description as a new conversation's first message", async () => {
37
- const wrapper = await popupOnScratch();
38
- await wrapper
39
- .find("textarea")
40
- .setValue("A back office for my bike rental shop");
41
- await wrapper.find("[data-start]").trigger("click");
42
-
43
- expect(harness.assistant.startConversation).toHaveBeenCalledTimes(1);
44
- const [prompt, mode, send] =
45
- harness.assistant.startConversation.mock.calls[0] ?? [];
46
- expect(prompt).toContain("A back office for my bike rental shop");
47
- expect(mode).toBeUndefined();
48
- expect(send).toBe(true);
49
- await flushPromises();
50
- expect(harness.controller.isOpen.value).toBe(false);
51
- expect(wrapper.find("[role=dialog]").exists()).toBe(false);
52
- });
53
-
54
- it("fills the description from a suggestion, and sends nothing while it is empty", async () => {
55
- const wrapper = await popupOnScratch();
56
- const start = wrapper.find<HTMLButtonElement>("[data-start]");
57
- expect(start.element.disabled).toBe(true);
58
-
59
- const suggestion = wrapper
60
- .findAll("button")
61
- .find((button) => button.text() === "Inventory & suppliers");
62
- await suggestion?.trigger("click");
63
- expect(wrapper.find("textarea").element.value).toBe(
64
- "Inventory & suppliers",
65
- );
66
- await start.trigger("click");
67
- const [prompt] = harness.assistant.startConversation.mock.calls[0] ?? [];
68
- expect(prompt).toContain("Inventory & suppliers");
69
- });
70
- });
@@ -1,97 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { ONBOARDING_SELECTED_STATE_KEY } from "../app/onboarding/install";
4
- import { dmsState } from "./support/dms-state";
5
- import {
6
- type Backend,
7
- CONVERSATION,
8
- resetBrowser,
9
- silenceStartup,
10
- startWithBackend,
11
- UNFINISHED,
12
- widget,
13
- } from "./support/onboarding-host";
14
-
15
- vi.mock("#dms/frontend-module", async () => {
16
- const { dmsModule } = await import("./support/dms-state");
17
- return dmsModule;
18
- });
19
-
20
- function chipClicked(): void {
21
- const clicks = dmsState.get(ONBOARDING_SELECTED_STATE_KEY);
22
- if (clicks === undefined) throw new Error("the chip was never registered");
23
- clicks.value = (clicks.value as number) + 1;
24
- }
25
-
26
- beforeEach(silenceStartup);
27
- afterEach(resetBrowser);
28
-
29
- describe("the assistant's chip in the widget dock", () => {
30
- it("registers the chip with the key its clicks are counted under", async () => {
31
- const { stop } = startWithBackend({
32
- stateAnswers: [UNFINISHED],
33
- conversations: [],
34
- });
35
- await vi.waitFor(() => expect(widget()).toBeDefined());
36
- expect(widget()?.onSelectEvent).toBe(ONBOARDING_SELECTED_STATE_KEY);
37
- stop();
38
- });
39
-
40
- it("shows the dot while the onboarding needs attention and clears it once it does not", async () => {
41
- const backend: Backend = {
42
- stateAnswers: [UNFINISHED, UNFINISHED],
43
- conversations: [],
44
- };
45
- const { stop } = startWithBackend(backend);
46
- await vi.waitFor(() => expect(widget()?.badge).toBe("dot"));
47
-
48
- backend.conversations = [CONVERSATION];
49
- chipClicked();
50
- await vi.waitFor(() => expect(widget()).toBeDefined());
51
- await vi.waitFor(() => expect(widget()).not.toHaveProperty("badge"));
52
- stop();
53
- });
54
-
55
- it("opens the popup on a click of the chip and not on its initial count", async () => {
56
- const { provided, stop } = startWithBackend({
57
- stateAnswers: [UNFINISHED, UNFINISHED],
58
- conversations: [],
59
- });
60
- await vi.waitFor(() => expect(widget()).toBeDefined());
61
- expect(provided.value?.isOpen.value).toBe(false);
62
-
63
- chipClicked();
64
- await vi.waitFor(() => expect(provided.value?.isOpen.value).toBe(true));
65
- stop();
66
- });
67
-
68
- it("takes the chip off the dock when onboarding stops", async () => {
69
- const { stop } = startWithBackend({
70
- stateAnswers: [UNFINISHED],
71
- conversations: [],
72
- });
73
- await vi.waitFor(() => expect(widget()).toBeDefined());
74
- stop();
75
- expect(widget()).toBeUndefined();
76
- });
77
- });
78
-
79
- describe("the chip of a backend that does not answer the first read", () => {
80
- it("registers anyway, and a click of it opens the popup once the backend answers", async () => {
81
- const { provided, stop } = startWithBackend({
82
- stateAnswers: [
83
- async () => {
84
- throw new Error("503");
85
- },
86
- UNFINISHED,
87
- ],
88
- conversations: [],
89
- });
90
- await vi.waitFor(() => expect(widget()).toBeDefined());
91
- expect(widget()).not.toHaveProperty("badge");
92
-
93
- chipClicked();
94
- await vi.waitFor(() => expect(provided.value?.isOpen.value).toBe(true));
95
- stop();
96
- });
97
- });