@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,622 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ref } from "vue";
3
- import { useConversation } from "../../app/chat/composables/useConversation";
4
- import { usePermissionQueue } from "../../app/chat/composables/usePermissionQueue";
5
- import { useQuestionQueue } from "../../app/chat/composables/useQuestionQueue";
6
- import { useQueueActions } from "../../app/chat/composables/useQueueActions";
7
- import type { ChangeSetSummary } from "../../app/chat/types/protocol";
8
-
9
- const CONVERSATION_ID = "conv-1";
10
-
11
- interface Bus {
12
- sent: Record<string, unknown>[];
13
- receive: (event: Record<string, unknown>) => void;
14
- options: {
15
- activeId: ReturnType<typeof ref<string>>;
16
- send: (msg: object) => boolean;
17
- onMessage: (handler: (msg: unknown) => void) => () => void;
18
- };
19
- }
20
-
21
- function bus(): Bus {
22
- const sent: Record<string, unknown>[] = [];
23
- const handlers: ((msg: unknown) => void)[] = [];
24
- return {
25
- sent,
26
- receive: (event) =>
27
- handlers.forEach((handler) =>
28
- handler({ conversationId: CONVERSATION_ID, ...event }),
29
- ),
30
- options: {
31
- activeId: ref(CONVERSATION_ID),
32
- send: (msg) => {
33
- sent.push(msg as Record<string, unknown>);
34
- return true;
35
- },
36
- onMessage: (handler) => {
37
- handlers.push(handler);
38
- return () => undefined;
39
- },
40
- },
41
- };
42
- }
43
-
44
- function changeSet(
45
- overrides: Partial<ChangeSetSummary> = {},
46
- ): ChangeSetSummary {
47
- return {
48
- id: "cs-14",
49
- number: 14,
50
- conversationId: CONVERSATION_ID,
51
- title: "Top customers",
52
- createdAtMs: 1,
53
- agent: "claude",
54
- scope: "safe",
55
- isAutoFix: false,
56
- overlapped: false,
57
- files: [
58
- {
59
- path: "sales/overview.page.ts",
60
- status: "modified",
61
- added: 14,
62
- removed: 1,
63
- },
64
- ],
65
- added: 14,
66
- removed: 1,
67
- typecheck: "passed",
68
- state: "applied",
69
- approvalsNeeded: 0,
70
- builderOps: 2,
71
- ...overrides,
72
- };
73
- }
74
-
75
- describe("the conversation folds the redesign's events", () => {
76
- it("closes a call with its outcome, how it was allowed and its change set", () => {
77
- const b = bus();
78
- const conversation = useConversation(b.options as never);
79
- b.receive({
80
- type: "tool_call_start",
81
- callId: "c1",
82
- toolName: "Edit",
83
- args: {},
84
- });
85
- b.receive({
86
- type: "tool_call_end",
87
- callId: "c1",
88
- status: "error",
89
- result: "denied",
90
- outcome: "denied",
91
- allowedBy: "denied",
92
- });
93
- expect(conversation.messages.value[0]).toMatchObject({
94
- outcome: "denied",
95
- allowedBy: "denied",
96
- status: "error",
97
- });
98
- expect(conversation.messages.value[0]).toHaveProperty("endedAtMs");
99
- });
100
-
101
- it("draws a change set card once and updates it when undone", () => {
102
- const b = bus();
103
- const conversation = useConversation(b.options as never);
104
- b.receive({ type: "change_set", changeSet: changeSet() });
105
- b.receive({
106
- type: "change_set",
107
- changeSet: changeSet({ state: "undone", stateChangedBy: "Camille" }),
108
- });
109
- const cards = conversation.messages.value.filter(
110
- (m) => m.role === "change_set",
111
- );
112
- expect(cards).toHaveLength(1);
113
- expect(conversation.changeSets.value["cs-14"]).toMatchObject({
114
- state: "undone",
115
- stateChangedBy: "Camille",
116
- });
117
- });
118
-
119
- it("keeps notices, the token count and the chat's mode", () => {
120
- const b = bus();
121
- const conversation = useConversation(b.options as never);
122
- b.receive({
123
- type: "notice",
124
- notice: {
125
- kind: "autofix",
126
- attempt: 1,
127
- maxAttempts: 2,
128
- errors: ["TS2339"],
129
- timestampMs: 5,
130
- },
131
- });
132
- b.receive({ type: "usage", totalTokens: 9_600 });
133
- b.receive({
134
- type: "conversation_mode",
135
- mode: "plan",
136
- generationMode: "vibe",
137
- });
138
- expect(conversation.messages.value[0]).toMatchObject({
139
- role: "notice",
140
- notice: { kind: "autofix", attempt: 1 },
141
- });
142
- expect(conversation.totalTokens.value).toBe(9_600);
143
- expect(conversation.mode.value).toEqual({
144
- mode: "plan",
145
- generationMode: "vibe",
146
- });
147
- });
148
-
149
- it("rebuilds the transcript from a snapshot with its new roles", () => {
150
- const b = bus();
151
- const conversation = useConversation(b.options as never);
152
- b.receive({
153
- type: "conversation_snapshot",
154
- messages: [
155
- { role: "user", content: "go", timestampMs: 1 },
156
- {
157
- role: "tool_use",
158
- content: '{"command":"pnpm test"}',
159
- toolName: "Bash",
160
- callId: "c1",
161
- allowedBy: "rule",
162
- timestampMs: 2,
163
- },
164
- {
165
- role: "tool_result",
166
- content: "ok",
167
- callId: "c1",
168
- status: "success",
169
- outcome: "done",
170
- changeSetId: "cs-14",
171
- timestampMs: 5,
172
- },
173
- {
174
- role: "notice",
175
- content: "",
176
- notice: { kind: "question_skipped", header: "Sort", timestampMs: 6 },
177
- timestampMs: 6,
178
- },
179
- {
180
- role: "question_answer",
181
- content: "",
182
- answers: [
183
- {
184
- header: "Where",
185
- question: "Where?",
186
- answer: "Finance",
187
- skipped: false,
188
- isCustom: false,
189
- },
190
- ],
191
- timestampMs: 7,
192
- },
193
- {
194
- role: "change_set",
195
- content: "",
196
- changeSetId: "cs-14",
197
- timestampMs: 8,
198
- },
199
- ],
200
- changeSets: [changeSet()],
201
- mode: { mode: "acceptEdits", generationMode: "safe" },
202
- totalTokens: 1_200,
203
- });
204
- expect(conversation.messages.value.map((m) => m.role)).toEqual([
205
- "user",
206
- "tool",
207
- "notice",
208
- "question_answer",
209
- "change_set",
210
- ]);
211
- expect(conversation.messages.value[1]).toMatchObject({
212
- outcome: "done",
213
- allowedBy: "rule",
214
- endedAtMs: 5,
215
- });
216
- expect(conversation.changeSets.value["cs-14"]?.number).toBe(14);
217
- expect(conversation.mode.value?.mode).toBe("acceptEdits");
218
- expect(conversation.totalTokens.value).toBe(1_200);
219
- });
220
-
221
- it("shows the model that answered, from a usage event or a snapshot", () => {
222
- const b = bus();
223
- const conversation = useConversation(b.options as never);
224
- expect(conversation.model.value).toBeNull();
225
- b.receive({ type: "usage", totalTokens: 10, model: "claude-opus-5-5" });
226
- expect(conversation.model.value).toBe("claude-opus-5-5");
227
- b.receive({
228
- type: "conversation_snapshot",
229
- messages: [],
230
- changeSets: [],
231
- totalTokens: 10,
232
- model: "claude-sonnet-4-6",
233
- });
234
- expect(conversation.model.value).toBe("claude-sonnet-4-6");
235
- });
236
-
237
- it("keeps the notice that the configured model was refused", () => {
238
- const b = bus();
239
- const conversation = useConversation(b.options as never);
240
- b.receive({
241
- type: "notice",
242
- notice: {
243
- kind: "model_fallback",
244
- requestedModel: "claude-opus-5-5",
245
- usedModel: "claude-sonnet-4-6",
246
- timestampMs: 7,
247
- },
248
- });
249
- expect(conversation.messages.value[0]).toMatchObject({
250
- role: "notice",
251
- notice: { kind: "model_fallback", usedModel: "claude-sonnet-4-6" },
252
- });
253
- });
254
-
255
- it("ignores another conversation's events", () => {
256
- const b = bus();
257
- const conversation = useConversation(b.options as never);
258
- b.receive({ type: "usage", totalTokens: 5, conversationId: "other" });
259
- expect(conversation.totalTokens.value).toBeNull();
260
- });
261
- });
262
-
263
- describe("a running turn reads the same live, after a re-attach and after a reload", () => {
264
- const TURN = [
265
- {
266
- type: "assistant_message_chunk",
267
- text: "I'll check two things in parallel.",
268
- },
269
- { type: "tool_call_start", callId: "t1", toolName: "Read", args: {} },
270
- {
271
- type: "tool_call_end",
272
- callId: "t1",
273
- status: "success",
274
- result: "",
275
- outcome: "done",
276
- },
277
- { type: "assistant_message_chunk", text: "The page has two blocks." },
278
- { type: "tool_call_start", callId: "t2", toolName: "Read", args: {} },
279
- {
280
- type: "tool_call_end",
281
- callId: "t2",
282
- status: "success",
283
- result: "",
284
- outcome: "done",
285
- },
286
- { type: "assistant_message_chunk", text: "All done." },
287
- ];
288
- const shape = (conversation: ReturnType<typeof useConversation>) =>
289
- conversation.messages.value.map((m) =>
290
- m.role === "assistant"
291
- ? `text:${m.content}`
292
- : m.role === "tool"
293
- ? `tool:${m.callId}`
294
- : m.role,
295
- );
296
- const EXPECTED = [
297
- "user",
298
- "text:I'll check two things in parallel.",
299
- "tool:t1",
300
- "text:The page has two blocks.",
301
- "tool:t2",
302
- "text:All done.",
303
- ];
304
-
305
- it("keeps chunk → tool → chunk → tool → chunk interleaved through run_done", () => {
306
- const b = bus();
307
- const conversation = useConversation(b.options as never);
308
- conversation.sendUserMessage("go");
309
- TURN.forEach(b.receive);
310
- b.receive({ type: "run_done" });
311
- expect(shape(conversation)).toEqual(EXPECTED);
312
- });
313
-
314
- it("does not append the replayed turn to its stored part on re-attach", () => {
315
- const b = bus();
316
- const conversation = useConversation(b.options as never);
317
- b.receive({
318
- type: "conversation_snapshot",
319
- messages: [
320
- { role: "assistant", content: "Earlier answer.", timestampMs: 1 },
321
- { role: "user", content: "go", timestampMs: 1_000 },
322
- {
323
- role: "assistant",
324
- content: "I'll check two things in parallel.",
325
- timestampMs: 1_100,
326
- },
327
- {
328
- role: "tool_use",
329
- content: "{}",
330
- toolName: "Read",
331
- callId: "t1",
332
- timestampMs: 1_200,
333
- },
334
- {
335
- role: "tool_result",
336
- content: "",
337
- callId: "t1",
338
- status: "success",
339
- outcome: "done",
340
- timestampMs: 1_500,
341
- },
342
- {
343
- role: "assistant",
344
- content: "The page has two blocks.",
345
- timestampMs: 1_600,
346
- },
347
- {
348
- role: "tool_use",
349
- content: "{}",
350
- toolName: "Read",
351
- callId: "t2",
352
- timestampMs: 1_700,
353
- },
354
- ],
355
- });
356
- b.receive({ type: "run_resumed" });
357
- TURN.forEach(b.receive);
358
- b.receive({ type: "run_done" });
359
- expect(shape(conversation)).toEqual(["text:Earlier answer.", ...EXPECTED]);
360
- });
361
-
362
- it("keeps each call's own start and end through a replay", () => {
363
- const b = bus();
364
- const conversation = useConversation(b.options as never);
365
- b.receive({
366
- type: "conversation_snapshot",
367
- messages: [
368
- { role: "user", content: "go", timestampMs: 1_000 },
369
- {
370
- role: "tool_use",
371
- content: "{}",
372
- toolName: "Read",
373
- callId: "t1",
374
- timestampMs: 1_200,
375
- },
376
- {
377
- role: "tool_result",
378
- content: "",
379
- callId: "t1",
380
- status: "success",
381
- outcome: "done",
382
- timestampMs: 1_300,
383
- },
384
- ],
385
- });
386
- b.receive({ type: "run_resumed" });
387
- TURN.slice(1, 3).forEach(b.receive);
388
- const tool = conversation.messages.value.find((m) => m.role === "tool");
389
- expect(tool).toMatchObject({ timestampMs: 1_200, endedAtMs: 1_300 });
390
- });
391
- });
392
-
393
- describe("approvals answer with the new vocabulary", () => {
394
- const request = {
395
- type: "permission_request",
396
- requestId: "r1",
397
- callId: "c1",
398
- toolName: "Edit",
399
- args: { file_path: "a.ts" },
400
- summary: "Edit a.ts",
401
- kind: "edit",
402
- alwaysAsk: false,
403
- preview: {
404
- type: "diff",
405
- path: "/a.ts",
406
- relativePath: "a.ts",
407
- isNewFile: false,
408
- added: 1,
409
- removed: 0,
410
- hunks: [],
411
- },
412
- ruleOptions: [{ kind: "file", value: "a.ts" }],
413
- createdAtMs: 1,
414
- expiresAtMs: 300_001,
415
- };
416
-
417
- it("allows with a rule, and denies with the user's suggestion", () => {
418
- const b = bus();
419
- const queue = usePermissionQueue(b.options as never);
420
- b.receive(request);
421
- b.receive({ ...request, requestId: "r2" });
422
- queue.respond("r1", {
423
- decision: "allow_rule",
424
- rule: { kind: "file", value: "a.ts" },
425
- });
426
- queue.respond("r2", {
427
- decision: "deny",
428
- feedback: " Use the Builder instead ",
429
- });
430
- expect(b.sent).toEqual([
431
- {
432
- type: "permission_response",
433
- conversationId: CONVERSATION_ID,
434
- requestId: "r1",
435
- decision: "allow_rule",
436
- rule: { kind: "file", value: "a.ts" },
437
- },
438
- {
439
- type: "permission_response",
440
- conversationId: CONVERSATION_ID,
441
- requestId: "r2",
442
- decision: "deny",
443
- feedback: "Use the Builder instead",
444
- },
445
- ]);
446
- expect(queue.queue.value).toEqual([]);
447
- });
448
-
449
- it("never offers rules for always-ask", () => {
450
- const b = bus();
451
- const queue = usePermissionQueue(b.options as never);
452
- b.receive({ ...request, alwaysAsk: true });
453
- expect(queue.queue.value[0].ruleOptions).toEqual([]);
454
- });
455
-
456
- it("drops a request another tab answered, and keeps an expired one as a card", () => {
457
- const b = bus();
458
- const queue = usePermissionQueue(b.options as never);
459
- b.receive(request);
460
- b.receive({ ...request, requestId: "r2" });
461
- b.receive({
462
- type: "permission_resolved",
463
- requestId: "r1",
464
- decision: "allow_once",
465
- });
466
- b.receive({
467
- type: "permission_expired",
468
- requestId: "r2",
469
- toolName: "Edit",
470
- summary: "Edit a.ts",
471
- expiredAtMs: 9,
472
- });
473
- expect(queue.queue.value).toEqual([]);
474
- expect(queue.expired.value).toEqual([
475
- {
476
- requestId: "r2",
477
- conversationId: CONVERSATION_ID,
478
- toolName: "Edit",
479
- summary: "Edit a.ts",
480
- expiredAtMs: 9,
481
- },
482
- ]);
483
- });
484
-
485
- it("denies everything at once, lists rules and revokes them", () => {
486
- const b = bus();
487
- const queue = usePermissionQueue(b.options as never);
488
- b.receive(request);
489
- b.receive({
490
- type: "rules_state",
491
- rules: [
492
- {
493
- id: "rule-1",
494
- kind: "command",
495
- value: "pnpm test",
496
- label: "Commands starting pnpm test",
497
- createdAtMs: 1,
498
- },
499
- ],
500
- });
501
- queue.denyAll();
502
- queue.revokeRule("rule-1");
503
- expect(b.sent).toEqual([
504
- {
505
- type: "permission_response",
506
- conversationId: CONVERSATION_ID,
507
- requestId: "r1",
508
- decision: "deny_all",
509
- },
510
- {
511
- type: "revoke_rule",
512
- conversationId: CONVERSATION_ID,
513
- ruleId: "rule-1",
514
- },
515
- ]);
516
- expect(queue.rules.value).toEqual([]);
517
- });
518
- });
519
-
520
- describe("questions can be skipped and leave a record", () => {
521
- it("sends answers with the skipped flags and returns the transcript record", () => {
522
- const b = bus();
523
- const questions = useQuestionQueue(b.options as never);
524
- b.receive({
525
- type: "ask_question",
526
- requestId: "q1",
527
- questions: [
528
- {
529
- question: "Where?",
530
- header: "Placement",
531
- options: [
532
- { label: "Finance", description: "" },
533
- { label: "Tab", description: "" },
534
- ],
535
- },
536
- {
537
- question: "Sort?",
538
- header: "Sort",
539
- options: [
540
- { label: "Days", description: "" },
541
- { label: "Amount", description: "" },
542
- ],
543
- },
544
- {
545
- question: "Action?",
546
- header: "Action",
547
- options: [
548
- { label: "Send", description: "" },
549
- { label: "Log", description: "" },
550
- ],
551
- },
552
- ],
553
- });
554
- const records = questions.respond("q1", [
555
- { answer: "Finance", isCustom: false, skipped: false },
556
- { answer: "", isCustom: false, skipped: true },
557
- { answer: "Send and log it", isCustom: true, skipped: false },
558
- ]);
559
- expect(b.sent[0]).toEqual({
560
- type: "question_response",
561
- conversationId: CONVERSATION_ID,
562
- requestId: "q1",
563
- answers: ["Finance", "", "Send and log it"],
564
- skipped: [false, true, false],
565
- });
566
- expect(
567
- records?.map((record) => [
568
- record.answer,
569
- record.skipped,
570
- record.isCustom,
571
- ]),
572
- ).toEqual([
573
- ["Finance", false, false],
574
- [null, true, false],
575
- ["Send and log it", false, true],
576
- ]);
577
- });
578
-
579
- it("drops a question the sidecar timed out", () => {
580
- const b = bus();
581
- const questions = useQuestionQueue(b.options as never);
582
- b.receive({ type: "ask_question", requestId: "q1", questions: [] });
583
- b.receive({ type: "question_expired", requestId: "q1" });
584
- expect(questions.queue.value).toEqual([]);
585
- });
586
- });
587
-
588
- describe("the follow-up queue is edited from the chat", () => {
589
- it("updates, reorders, cancels and clears, showing each change at once", () => {
590
- const b = bus();
591
- const queued = ref([
592
- { id: "a", content: "first", attachments: [] },
593
- { id: "b", content: "second", attachments: [] },
594
- ]);
595
- const actions = useQueueActions({
596
- activeId: b.options.activeId as never,
597
- queued,
598
- send: b.options.send,
599
- });
600
- actions.update("a", "first, edited");
601
- actions.move("b", 0);
602
- expect(queued.value.map((item) => item.content)).toEqual([
603
- "second",
604
- "first, edited",
605
- ]);
606
- actions.cancel("a");
607
- actions.clear();
608
- expect(queued.value).toEqual([]);
609
- expect(b.sent.map((msg) => msg.type)).toEqual([
610
- "queue_update",
611
- "queue_move",
612
- "queue_cancel",
613
- "queue_clear",
614
- ]);
615
- expect(b.sent[1]).toEqual({
616
- type: "queue_move",
617
- conversationId: CONVERSATION_ID,
618
- id: "b",
619
- toIndex: 0,
620
- });
621
- });
622
- });