@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,241 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
3
- import { afterEach, describe, expect, it, vi } from "vitest";
4
- import { nextTick, ref } from "vue";
5
- import PaletteAnswer from "../app/components/PaletteAnswer.vue";
6
- import type { CurrentPage } from "../app/chat/types/conversation";
7
- import {
8
- assistantSidePanel,
9
- launcherAction,
10
- paletteAssistant,
11
- } from "../app/runtime/assistant-commands";
12
- import {
13
- createHarness,
14
- type Harness,
15
- providedSession,
16
- sentOfType,
17
- } from "./support/panel-harness";
18
- import { createTestI18n } from "./support/i18n";
19
- import { PANEL_STUBS } from "./support/stubs";
20
-
21
- const PROMPT = "What does this page show?";
22
-
23
- let answer: VueWrapper | null = null;
24
-
25
- afterEach(() => {
26
- answer?.unmount();
27
- answer = null;
28
- localStorage.clear();
29
- });
30
-
31
- function askFromPalette(harness: Harness, close = vi.fn()): VueWrapper {
32
- answer = mount(PaletteAnswer, {
33
- props: { prompt: PROMPT, close },
34
- global: { provide: providedSession(harness.session), stubs: PANEL_STUBS },
35
- });
36
- return answer;
37
- }
38
-
39
- function paletteConversation(harness: Harness): string {
40
- const hello = sentOfType(harness, "hello")[0];
41
- return String(hello?.conversationId);
42
- }
43
-
44
- function deliverToPalette(
45
- harness: Harness,
46
- event: Record<string, unknown>,
47
- ): void {
48
- harness.hub.deliver({
49
- conversationId: paletteConversation(harness),
50
- ...event,
51
- });
52
- }
53
-
54
- describe("the assistant's registrations in the dashboard", () => {
55
- it("docks the panel by id, and lets the DMS toggle it from the launcher", () => {
56
- const { t } = createTestI18n();
57
- const panel = assistantSidePanel();
58
- expect(panel).toMatchObject({
59
- id: "dms-assistant:assistant",
60
- component: "DmsAssistantChatPanel",
61
- ariaLabel: "$dms_assistant.panel.launcher",
62
- });
63
- expect(panel.minWidth).toBeLessThan(panel.defaultWidth);
64
- expect(panel.defaultWidth).toBeLessThan(panel.maxWidth);
65
- const launcher = launcherAction(t, "connected");
66
- expect(launcher.sidePanelId).toBe(panel.id);
67
- expect(launcher).not.toHaveProperty("onSelect");
68
- expect(launcher).not.toHaveProperty("isActive");
69
- });
70
-
71
- it("draws the launcher with its icon component, keeping the sparkle for a DMS without one, and names the state in its label", () => {
72
- const { t } = createTestI18n();
73
- const connected = launcherAction(t, "connected");
74
- expect(connected).toMatchObject({
75
- icon: "i-ph-sparkle",
76
- iconComponent: "DmsAssistantLauncherIcon",
77
- });
78
- expect(connected.label).toMatch(/^Assistant \(.+K\)$/);
79
- const labels = (
80
- ["disconnected", "working", "finished", "question"] as const
81
- ).map((state) => launcherAction(t, state).label);
82
- expect(labels).toEqual([
83
- expect.stringMatching(/^Assistant · Disconnected \(.+K\)$/),
84
- expect.stringMatching(/^Assistant · Working \(.+K\)$/),
85
- expect.stringMatching(/^Assistant · Finished \(.+K\)$/),
86
- expect.stringMatching(/^Assistant · Waiting for you \(.+K\)$/),
87
- ]);
88
- expect(new Set(labels).size).toBe(labels.length);
89
- });
90
-
91
- it("offers the palette prompts that fit the page on screen", () => {
92
- const { t } = createTestI18n();
93
- const page = ref<CurrentPage | null>({
94
- path: "/sales/overview",
95
- title: "Sales overview · DMS",
96
- });
97
- const assistant = paletteAssistant(t, page);
98
- expect(assistant).toMatchObject({
99
- id: "dms-assistant:assistant",
100
- answerComponent: "DmsAssistantPaletteAnswer",
101
- label: "$dms_assistant.panel.palette.assistant",
102
- placeholder: "$dms_assistant.panel.palette.placeholder",
103
- });
104
- expect(assistant.suggestions().map((item) => item.label)).toEqual([
105
- "Explain what Sales overview shows",
106
- "Add a chart to Sales overview",
107
- "Add a filter to the table on Sales overview",
108
- ]);
109
- page.value = { path: "/home", title: "Home" };
110
- expect(assistant.suggestions().map((item) => item.label)).toContain(
111
- "Explain how this project is organised",
112
- );
113
- });
114
- });
115
-
116
- describe("an answer in the command palette", () => {
117
- it("asks read-only, in a conversation of its own it follows next to the panel's", async () => {
118
- const harness = createHarness();
119
- askFromPalette(harness);
120
- await flushPromises();
121
- const conversationId = paletteConversation(harness);
122
- expect(sentOfType(harness, "hello")).toEqual([
123
- { type: "hello", role: "chat", conversationId, follow: true },
124
- ]);
125
- expect(sentOfType(harness, "set_conversation_mode")).toEqual([
126
- {
127
- type: "set_conversation_mode",
128
- conversationId,
129
- mode: "plan",
130
- generationMode: "safe",
131
- },
132
- ]);
133
- expect(sentOfType(harness, "user_message")).toMatchObject([
134
- { conversationId, content: PROMPT },
135
- ]);
136
- expect(harness.streamHolds).toBe(1);
137
- });
138
-
139
- it("waits for the stream before it asks", async () => {
140
- const harness = createHarness();
141
- harness.setChannelStatus("connecting");
142
- askFromPalette(harness);
143
- await flushPromises();
144
- expect(sentOfType(harness, "user_message")).toEqual([]);
145
- harness.setChannelStatus("connected");
146
- harness.hub.announceReady();
147
- await flushPromises();
148
- expect(sentOfType(harness, "user_message")).toHaveLength(1);
149
- expect(sentOfType(harness, "hello")[0]).toMatchObject({ follow: true });
150
- });
151
-
152
- it("streams the answer, and ignores the panel's conversation", async () => {
153
- const harness = createHarness();
154
- const view = askFromPalette(harness);
155
- await flushPromises();
156
- harness.hub.deliver({
157
- conversationId: "conv-of-the-panel",
158
- type: "assistant_message_chunk",
159
- text: "not for the palette",
160
- });
161
- deliverToPalette(harness, {
162
- type: "assistant_message_chunk",
163
- text: "It lists the **sales** of the quarter.",
164
- });
165
- deliverToPalette(harness, { type: "run_done" });
166
- await flushPromises();
167
- expect(view.text()).toContain("It lists the sales of the quarter.");
168
- expect(view.text()).not.toContain("not for the palette");
169
- expect(view.text()).not.toContain(PROMPT);
170
- });
171
-
172
- it("continues in the assistant: the panel opens on that conversation and the turn keeps running", async () => {
173
- const harness = createHarness();
174
- const close = vi.fn();
175
- const view = askFromPalette(harness, close);
176
- await flushPromises();
177
- const conversationId = paletteConversation(harness);
178
- const button = view
179
- .findAll("button")
180
- .find((item) => item.text() === "Continue in the assistant");
181
- await button?.trigger("click");
182
- expect(close).toHaveBeenCalledOnce();
183
- expect(harness.session.panel.isOpen.value).toBe(true);
184
- expect(harness.session.intents.pending.value).toEqual({
185
- kind: "open",
186
- conversationId,
187
- });
188
- view.unmount();
189
- answer = null;
190
- expect(sentOfType(harness, "interrupt_turn")).toEqual([]);
191
- expect(harness.streamHolds).toBe(0);
192
- });
193
-
194
- it("stops its turn when the palette closes on it, and lets the stream go", async () => {
195
- const harness = createHarness();
196
- const view = askFromPalette(harness);
197
- await flushPromises();
198
- const conversationId = paletteConversation(harness);
199
- view.unmount();
200
- answer = null;
201
- expect(sentOfType(harness, "interrupt_turn")).toEqual([
202
- { type: "interrupt_turn", conversationId },
203
- ]);
204
- expect(harness.streamHolds).toBe(0);
205
- });
206
-
207
- it("says when the agent waits for the user, who answers in the assistant", async () => {
208
- const harness = createHarness();
209
- const view = askFromPalette(harness);
210
- await flushPromises();
211
- deliverToPalette(harness, {
212
- type: "ask_question",
213
- requestId: "q1",
214
- questions: [
215
- {
216
- header: "Scope",
217
- question: "Which table?",
218
- options: [{ label: "Orders" }, { label: "Customers" }],
219
- multiSelect: false,
220
- },
221
- ],
222
- createdAtMs: Date.now(),
223
- expiresAtMs: Date.now() + 60_000,
224
- });
225
- await nextTick();
226
- expect(view.find('[role="alert"]').text()).toContain(
227
- "The assistant is waiting for you",
228
- );
229
- });
230
-
231
- it("says the assistant does not run in this tab without a session", () => {
232
- answer = mount(PaletteAnswer, {
233
- props: { prompt: PROMPT, close: vi.fn() },
234
- global: { provide: providedSession(null), stubs: PANEL_STUBS },
235
- });
236
- expect(answer.text()).toContain("isn't running in this tab");
237
- expect(answer.findAll("button").map((button) => button.text())).toEqual([
238
- "Close",
239
- ]);
240
- });
241
- });
@@ -1,226 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { nextTick } from "vue";
4
- import {
5
- buttonWithText,
6
- CONVERSATION_ID,
7
- createHarness,
8
- deliver,
9
- openPanel,
10
- sentOfType,
11
- unmountPanel,
12
- } from "./support/panel-harness";
13
- import {
14
- COMMAND_REQUEST,
15
- CONFIGURE_DIFF,
16
- CONFIGURE_REQUEST,
17
- DELETE_REQUEST,
18
- DIFF_REQUEST,
19
- keydown,
20
- MAP_REQUEST,
21
- } from "./support/panel-fixtures";
22
-
23
- beforeEach(() => {
24
- localStorage.setItem("dms-assistant-conversation-id", CONVERSATION_ID);
25
- });
26
-
27
- afterEach(() => {
28
- unmountPanel();
29
- localStorage.clear();
30
- vi.useRealTimers();
31
- });
32
-
33
- describe("the approvals dock", () => {
34
- it("previews a diff with line numbers and allows a scope with ↵", async () => {
35
- // The countdown reads the clock: frozen at the request's creation, it
36
- // shows the full grace period however slow the run is.
37
- vi.useFakeTimers({ toFake: ["Date"] });
38
- vi.setSystemTime(DIFF_REQUEST.createdAtMs);
39
- const harness = createHarness();
40
- const panel = await openPanel(harness);
41
- deliver(harness, DIFF_REQUEST);
42
- deliver(harness, COMMAND_REQUEST);
43
- await nextTick();
44
- const dock = panel.find(".cb-approve");
45
- expect(dock.attributes("role")).toBe("alertdialog");
46
- expect(dock.text()).toContain("Needs your approval · 1 of 2");
47
- expect(dock.text()).toContain("denies in 4:12");
48
- expect(panel.find(".perm.is-focused .perm__title").text()).toBe(
49
- "Edit customer.form.ts",
50
- );
51
- expect(panel.findAll(".ln").map((row) => row.text())).toEqual([
52
- "@@ −42 +42 @@",
53
- '42−label: "VAT",',
54
- '42+label: "VAT number",',
55
- ]);
56
- expect(dock.text()).toContain("Every edit under crm/customers/");
57
- await panel.findAll(".perm.is-focused .scope-opt input")[2].setValue(true);
58
- keydown(dock.element, "Enter");
59
- await nextTick();
60
- expect(sentOfType(harness, "permission_response")[0]).toEqual({
61
- type: "permission_response",
62
- conversationId: CONVERSATION_ID,
63
- requestId: "r1",
64
- decision: "allow_rule",
65
- rule: { kind: "directory", value: "crm/customers/" },
66
- });
67
- expect(panel.find(".perm.is-focused .perm__title").text()).toBe(
68
- "Run pnpm add jsvat",
69
- );
70
- expect(panel.find(".perm.is-focused").text()).toContain(
71
- "adds a dependency · package.json, pnpm-lock.yaml",
72
- );
73
- });
74
-
75
- it("moves with J and K, denies with N, and denies everything at once", async () => {
76
- const harness = createHarness();
77
- const panel = await openPanel(harness);
78
- deliver(harness, DIFF_REQUEST);
79
- deliver(harness, COMMAND_REQUEST);
80
- await nextTick();
81
- const dock = panel.find(".cb-approve");
82
- keydown(dock.element, "j");
83
- await nextTick();
84
- expect(dock.text()).toContain("2 of 2");
85
- keydown(dock.element, "k");
86
- await nextTick();
87
- expect(dock.text()).toContain("1 of 2");
88
- keydown(dock.element, "n");
89
- await nextTick();
90
- expect(sentOfType(harness, "permission_response")[0]).toMatchObject({
91
- requestId: "r1",
92
- decision: "deny",
93
- });
94
- deliver(harness, DIFF_REQUEST);
95
- await nextTick();
96
- await buttonWithText(
97
- panel.find(".cb-approve"),
98
- "Deny both and stop",
99
- ).trigger("click");
100
- expect(sentOfType(harness, "permission_response").at(-1)).toMatchObject({
101
- decision: "deny_all",
102
- });
103
- });
104
-
105
- it("denies with the user's suggestion", async () => {
106
- const harness = createHarness();
107
- const panel = await openPanel(harness);
108
- deliver(harness, DIFF_REQUEST);
109
- await nextTick();
110
- await buttonWithText(panel, "Suggest a change").trigger("click");
111
- await panel
112
- .find(".u-textarea")
113
- .setValue("Use the Builder's validation instead");
114
- await buttonWithText(panel, "Deny and send").trigger("click");
115
- expect(sentOfType(harness, "permission_response")[0]).toMatchObject({
116
- decision: "deny",
117
- feedback: "Use the Builder's validation instead",
118
- });
119
- });
120
-
121
- it("shows a held configuration change with the DMS's preview in full, in a box that scrolls (fails a card that cuts the preview or reads like a removal)", async () => {
122
- const harness = createHarness();
123
- const panel = await openPanel(harness);
124
- deliver(harness, CONFIGURE_REQUEST);
125
- await nextTick();
126
- const card = panel.find(".perm.is-focused");
127
- expect(card.find(".perm__why").text()).toBe(
128
- "Changes the project's configuration.",
129
- );
130
- const rows = card.find(".perm__kv.is-full");
131
- expect(rows.findAll("dt").map((cell) => cell.text())).toEqual([
132
- "plannedChanges[0].path",
133
- "plannedChanges[0].kind",
134
- "plannedChanges[0].diff",
135
- "steps[0].action",
136
- "steps[0].module",
137
- "steps[0].version",
138
- ]);
139
- expect(rows.findAll("dd")[2].text()).toBe(CONFIGURE_DIFF.trim());
140
- });
141
-
142
- it("names the pages a held mapping removes (fails a card that hides them)", async () => {
143
- const harness = createHarness();
144
- const panel = await openPanel(harness);
145
- deliver(harness, MAP_REQUEST);
146
- await nextTick();
147
- expect(panel.find(".perm.is-focused .perm__why").text()).toBe(
148
- "Maps the tables and removes the pages orders, customers.",
149
- );
150
- });
151
-
152
- it("makes a data loss typed, shows the call's own keepData without a way to change it, and never a chat-wide rule", async () => {
153
- const harness = createHarness();
154
- const panel = await openPanel(harness);
155
- deliver(harness, DELETE_REQUEST);
156
- await nextTick();
157
- const card = panel.find(".perm.is-danger");
158
- expect(card.text()).toContain("Data loss");
159
- expect(card.text()).not.toContain("this chat");
160
- expect(card.find('input[type="checkbox"]').exists()).toBe(false);
161
- expect(
162
- card.findAll(".perm__kv dt, .perm__kv dd").map((cell) => cell.text()),
163
- ).toEqual(["ref", "legacy_coupons", "keepData", "false"]);
164
- const confirm = buttonWithText(card, "Delete");
165
- expect(confirm.attributes("disabled")).toBeDefined();
166
- await card.find(".perm__confirm input").setValue("legacy_coupons");
167
- await buttonWithText(card, "Delete").trigger("click");
168
- expect(sentOfType(harness, "permission_response")[0]).toEqual({
169
- type: "permission_response",
170
- conversationId: CONVERSATION_ID,
171
- requestId: "r3",
172
- decision: "allow_once",
173
- });
174
- });
175
-
176
- it("turns an expired request into a card that asks again", async () => {
177
- const harness = createHarness();
178
- const panel = await openPanel(harness);
179
- deliver(harness, DIFF_REQUEST);
180
- deliver(harness, {
181
- type: "permission_expired",
182
- requestId: "r1",
183
- toolName: "Edit",
184
- summary: "Edit customer.form.ts",
185
- expiredAtMs: Date.now(),
186
- });
187
- await nextTick();
188
- expect(panel.find(".cb-approve").exists()).toBe(false);
189
- const card = panel.find(".cb-expired");
190
- expect(card.text()).toContain("Edit file request expired");
191
- await buttonWithText(card, "Ask again").trigger("click");
192
- expect(sentOfType(harness, "user_message")[0].content).toContain(
193
- "Edit customer.form.ts",
194
- );
195
- expect(panel.find(".cb-expired").exists()).toBe(false);
196
- });
197
-
198
- it("lists the rules allowed in this chat and revokes one", async () => {
199
- const harness = createHarness();
200
- const panel = await openPanel(harness);
201
- deliver(harness, DIFF_REQUEST);
202
- deliver(harness, {
203
- type: "rules_state",
204
- rules: [
205
- {
206
- id: "rule-1",
207
- kind: "command",
208
- value: "pnpm test",
209
- label: "Commands starting pnpm test",
210
- createdAtMs: 1,
211
- },
212
- ],
213
- });
214
- await nextTick();
215
- const rules = panel.find(".cb-approve .cb-rules");
216
- expect(rules.text()).toContain("Commands starting pnpm test");
217
- await buttonWithText(rules, "Revoke").trigger("click");
218
- expect(sentOfType(harness, "revoke_rule")).toEqual([
219
- {
220
- type: "revoke_rule",
221
- conversationId: CONVERSATION_ID,
222
- ruleId: "rule-1",
223
- },
224
- ]);
225
- });
226
- });
@@ -1,53 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
- import { nextTick } from "vue";
4
- import {
5
- CONVERSATION_ID,
6
- createHarness,
7
- deliver,
8
- openPanel,
9
- unmountPanel,
10
- } from "./support/panel-harness";
11
-
12
- const STORAGE_KEY = "dms-assistant-conversation-id";
13
- const DELETED_NOTICE =
14
- "This conversation was deleted. Start a new conversation.";
15
-
16
- beforeEach(() => {
17
- localStorage.setItem(STORAGE_KEY, CONVERSATION_ID);
18
- });
19
-
20
- afterEach(() => {
21
- unmountPanel();
22
- localStorage.clear();
23
- });
24
-
25
- describe("a chat panel whose conversation is closed", () => {
26
- it("starts a new conversation and says why (fails a panel that stays on the closed one)", async () => {
27
- const harness = createHarness();
28
- const panel = await openPanel(harness);
29
- deliver(harness, {
30
- type: "conversation_closed",
31
- conversationId: CONVERSATION_ID,
32
- message: DELETED_NOTICE,
33
- });
34
- await nextTick();
35
- const current = localStorage.getItem(STORAGE_KEY);
36
- expect(current).not.toBe(CONVERSATION_ID);
37
- expect(current).not.toBe("");
38
- expect(panel.text()).toContain(DELETED_NOTICE);
39
- });
40
-
41
- it("ignores a notice about another conversation (fails a panel that leaves on any closed id)", async () => {
42
- const harness = createHarness();
43
- const panel = await openPanel(harness);
44
- deliver(harness, {
45
- type: "conversation_closed",
46
- conversationId: "conv-elsewhere",
47
- message: DELETED_NOTICE,
48
- });
49
- await nextTick();
50
- expect(localStorage.getItem(STORAGE_KEY)).toBe(CONVERSATION_ID);
51
- expect(panel.text()).not.toContain(DELETED_NOTICE);
52
- });
53
- });