@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,34 +0,0 @@
1
- import { defineComponent, h, type PropType } from "vue";
2
-
3
- interface MenuItem {
4
- label?: string;
5
- description?: string;
6
- onSelect?: () => void;
7
- }
8
-
9
- /** A menu drawn open, each item a button, so tests can pick one. */
10
- export const UDropdownMenu = defineComponent({
11
- name: "UDropdownMenu",
12
- props: { items: { type: Array as PropType<unknown[]>, default: () => [] } },
13
- setup(props, { slots }) {
14
- const flat = (): MenuItem[] => props.items.flat(2) as MenuItem[];
15
- return () =>
16
- h("div", { class: "u-dropdown" }, [
17
- slots.default?.(),
18
- ...flat()
19
- .filter((item) => item.onSelect !== undefined)
20
- .map((item) =>
21
- h(
22
- "button",
23
- {
24
- class: "u-dropdown-item",
25
- type: "button",
26
- "data-description": item.description,
27
- onClick: item.onSelect,
28
- },
29
- item.label,
30
- ),
31
- ),
32
- ]);
33
- },
34
- });
@@ -1,9 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- export const UFormField = defineComponent({
4
- name: "UFormField",
5
- setup:
6
- (_, { slots }) =>
7
- () =>
8
- h("div", slots.default?.()),
9
- });
@@ -1,16 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- export const UInput = defineComponent({
4
- name: "UInput",
5
- props: { modelValue: { type: String, default: "" } },
6
- emits: ["update:modelValue"],
7
- setup:
8
- (props, { emit, attrs }) =>
9
- () =>
10
- h("input", {
11
- ...attrs,
12
- value: props.modelValue,
13
- onInput: (event: Event) =>
14
- emit("update:modelValue", (event.target as HTMLInputElement).value),
15
- }),
16
- });
@@ -1,7 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- export const UKbd = defineComponent({
4
- name: "UKbd",
5
- props: { value: { type: String, default: "" } },
6
- setup: (props) => () => h("kbd", props.value),
7
- });
@@ -1,20 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- /** A modal that draws its slots in place while open. */
4
- export const UModal = defineComponent({
5
- name: "UModal",
6
- props: {
7
- open: { type: Boolean, default: false },
8
- title: { type: String, default: "" },
9
- },
10
- setup(props, { slots }) {
11
- return () =>
12
- props.open
13
- ? h("div", { class: "u-modal", role: "dialog" }, [
14
- h("h2", props.title),
15
- slots.body?.(),
16
- slots.footer?.(),
17
- ])
18
- : null;
19
- },
20
- });
@@ -1,9 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- export const UPopover = defineComponent({
4
- name: "UPopover",
5
- setup:
6
- (_, { slots }) =>
7
- () =>
8
- h("div", { class: "u-popover" }, [slots.default?.(), slots.content?.()]),
9
- });
@@ -1,31 +0,0 @@
1
- import { defineComponent, h, type PropType } from "vue";
2
-
3
- export const UTabs = defineComponent({
4
- name: "UTabs",
5
- props: {
6
- modelValue: { type: String, default: "" },
7
- items: {
8
- type: Array as PropType<{ value: string; label: string }[]>,
9
- default: () => [],
10
- },
11
- },
12
- emits: ["update:modelValue"],
13
- setup:
14
- (props, { emit, attrs }) =>
15
- () =>
16
- h(
17
- "div",
18
- { role: "tablist", "aria-label": attrs["aria-label"] },
19
- props.items.map((item) =>
20
- h(
21
- "button",
22
- {
23
- role: "tab",
24
- "aria-selected": item.value === props.modelValue,
25
- onClick: () => emit("update:modelValue", item.value),
26
- },
27
- item.label,
28
- ),
29
- ),
30
- ),
31
- });
@@ -1,19 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
-
3
- export const UTextarea = defineComponent({
4
- name: "UTextarea",
5
- props: { modelValue: { type: String, default: "" } },
6
- emits: ["update:modelValue"],
7
- setup:
8
- (props, { emit }) =>
9
- () =>
10
- h("textarea", {
11
- class: "u-textarea",
12
- value: props.modelValue,
13
- onInput: (event: Event) =>
14
- emit(
15
- "update:modelValue",
16
- (event.target as HTMLTextAreaElement).value,
17
- ),
18
- }),
19
- });
@@ -1,28 +0,0 @@
1
- import { UButton } from "./stand-ins/UButton";
2
- import { UKbd } from "./stand-ins/UKbd";
3
- import { UBadge } from "./stand-ins/UBadge";
4
- import { UModal } from "./stand-ins/UModal";
5
- import { UDropdownMenu } from "./stand-ins/UDropdownMenu";
6
- import { UPopover } from "./stand-ins/UPopover";
7
- import { UInput } from "./stand-ins/UInput";
8
- import { UTextarea } from "./stand-ins/UTextarea";
9
- import { DmsSegmentedControl } from "./stand-ins/DmsSegmentedControl";
10
- import { DmsEmptyState } from "./stand-ins/DmsEmptyState";
11
- import { DmsStatusPill } from "./stand-ins/DmsStatusPill";
12
-
13
- /** Every Nuxt UI and DMS component the panel draws, as light stand-ins. */
14
- export const PANEL_STUBS = {
15
- UIcon: true,
16
- UButton,
17
- UKbd,
18
- UBadge,
19
- UModal,
20
- UDropdownMenu,
21
- UPopover,
22
- UInput,
23
- UTextarea,
24
- DmsSegmentedControl,
25
- DmsEmptyState,
26
- DmsStatusPill,
27
- DmsIconWell: true,
28
- };
@@ -1,451 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { flushPromises, shallowMount } from "@vue/test-utils";
3
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
- import {
5
- computed,
6
- defineComponent,
7
- h,
8
- reactive,
9
- ref,
10
- toValue,
11
- watch,
12
- type MaybeRefOrGetter,
13
- } from "vue";
14
- import ActivityDetail from "../../app/components/ActivityDetail.vue";
15
- import ChangesView from "../../app/components/ChangesView.vue";
16
- import ChangeSetPanel from "../../app/views/ChangeSetPanel.vue";
17
- import UnavailableState from "../../app/views/UnavailableState.vue";
18
- import { installApiErrorPresenter } from "../support/api-error-presenter";
19
-
20
- // The views read what they render with the DMS's `useApiData`, which a server
21
- // render hands to the browser (this repository has no renderer to run it:
22
- // the playground proves that part), and the Changes list page by page with
23
- // `useApiPagedData`; `$authFetch` is left to the writes. These fakes read as
24
- // the browser does.
25
-
26
- const route = reactive({ query: {} as Record<string, string> });
27
-
28
- vi.mock("#dms/frontend-module", () => ({
29
- useDmsRoute: () => route,
30
- useDmsRouter: () => ({ push: vi.fn() }),
31
- }));
32
-
33
- interface Read {
34
- url: string;
35
- query?: Record<string, unknown>;
36
- }
37
-
38
- type Backend = (read: Read) => unknown;
39
-
40
- let backend: Backend;
41
- const reads: Read[] = [];
42
- const authFetch = vi.fn();
43
- /** The reads the page's refreshes read again, as the DMS's `refreshPageBlocks()` does. */
44
- const pageReads = new Set<() => Promise<void>>();
45
- const refreshPageBlocks = vi.fn(async () => {
46
- await Promise.all([...pageReads].map((refresh) => refresh()));
47
- });
48
-
49
- interface FakeApiDataOptions {
50
- query?: MaybeRefOrGetter<Record<string, unknown>>;
51
- refreshOnPageRefresh?: boolean;
52
- }
53
-
54
- function useApiData<T>(
55
- url: MaybeRefOrGetter<string | null | undefined>,
56
- options: FakeApiDataOptions = {},
57
- ) {
58
- const data = ref<T | null>(null);
59
- const error = ref<unknown>(null);
60
- const status = ref<"idle" | "pending" | "success" | "error">("idle");
61
- const request = () => ({ url: toValue(url), query: toValue(options.query) });
62
- async function refresh(): Promise<void> {
63
- const { url: target, query } = request();
64
- if (target == null) return;
65
- const read = query ? { url: target, query } : { url: target };
66
- reads.push(read);
67
- status.value = "pending";
68
- try {
69
- // Each answer is a new value, as a parsed response is.
70
- data.value = structuredClone(await backend(read)) as T;
71
- error.value = null;
72
- status.value = "success";
73
- } catch (failure) {
74
- error.value = failure;
75
- status.value = "error";
76
- }
77
- }
78
- watch(request, () => void refresh(), { deep: true, immediate: true });
79
- if (options.refreshOnPageRefresh !== false) pageReads.add(refresh);
80
- return {
81
- data,
82
- error,
83
- status,
84
- pending: computed(() => status.value === "pending"),
85
- placeholder: ref(false),
86
- refresh,
87
- execute: refresh,
88
- clear: () => undefined,
89
- };
90
- }
91
-
92
- interface FakePagedOptions<TPage> {
93
- nextCursor: (page: TPage, pages: TPage[]) => number | null | undefined;
94
- }
95
-
96
- type PagedContext = {
97
- $authFetch: typeof authFetch;
98
- cursor: number | undefined;
99
- signal: AbortSignal;
100
- };
101
-
102
- /** `useApiPagedData` as the renderer runs it: one key, the pages it loaded, all read again on a refresh. */
103
- function useApiPagedData<TPage>(
104
- key: MaybeRefOrGetter<string>,
105
- handler: (context: PagedContext) => Promise<TPage>,
106
- options: FakePagedOptions<TPage>,
107
- ) {
108
- const pages = ref<TPage[]>([]) as { value: TPage[] };
109
- const next = ref<number | null>(null);
110
- const error = ref<unknown>(null);
111
- const status = ref<"idle" | "pending" | "success" | "error">("idle");
112
- const loadingMore = ref(false);
113
- const read = (cursor: number | undefined) =>
114
- handler({
115
- $authFetch: authFetch,
116
- cursor,
117
- signal: new AbortController().signal,
118
- });
119
- async function readPages(count: number): Promise<void> {
120
- status.value = "pending";
121
- const loaded: TPage[] = [];
122
- let cursor: number | undefined;
123
- try {
124
- for (let index = 0; index < count; index++) {
125
- const page = structuredClone(await read(cursor)) as TPage;
126
- loaded.push(page);
127
- const after = options.nextCursor(page, loaded) ?? null;
128
- next.value = after;
129
- if (after === null) break;
130
- cursor = after;
131
- }
132
- pages.value = loaded;
133
- error.value = null;
134
- status.value = "success";
135
- } catch (failure) {
136
- error.value = failure;
137
- status.value = "error";
138
- }
139
- }
140
- const refresh = () => readPages(Math.max(pages.value.length, 1));
141
- watch(
142
- () => toValue(key),
143
- () => void readPages(1),
144
- { immediate: true },
145
- );
146
- pageReads.add(refresh);
147
- async function loadMore(): Promise<void> {
148
- if (next.value === null) return;
149
- loadingMore.value = true;
150
- try {
151
- const page = structuredClone(await read(next.value)) as TPage;
152
- pages.value = [...pages.value, page];
153
- next.value = options.nextCursor(page, pages.value) ?? null;
154
- } catch (failure) {
155
- error.value = failure;
156
- } finally {
157
- loadingMore.value = false;
158
- }
159
- }
160
- return {
161
- pages,
162
- error,
163
- status,
164
- pending: computed(() => status.value === "pending"),
165
- hasMore: computed(() => next.value !== null),
166
- loadingMore,
167
- loadMore,
168
- refresh,
169
- };
170
- }
171
-
172
- const Stub = (name: string) =>
173
- defineComponent({
174
- name,
175
- inheritAttrs: false,
176
- setup:
177
- (_, { slots }) =>
178
- () =>
179
- h("div", { "data-stub": name }, slots.default?.()),
180
- });
181
-
182
- const GLOBAL_STUBS = Object.fromEntries(
183
- [
184
- "DmsCardPanel",
185
- "DmsEmptyState",
186
- "DmsMasterDetail",
187
- "DmsSegmentedControl",
188
- "DmsKeyValueList",
189
- "DmsIconWell",
190
- "DmsEyebrowLabel",
191
- "DmsCodeSnippet",
192
- "UButton",
193
- "UInput",
194
- "USkeleton",
195
- ].map((name) => [name, Stub(name)]),
196
- );
197
-
198
- const unavailable = () =>
199
- Object.assign(new Error("Service Unavailable"), {
200
- statusCode: 503,
201
- data: { message: "The assistant is not running" },
202
- });
203
-
204
- const ROW = {
205
- id: "act-1",
206
- timestampMs: Date.UTC(2026, 9, 15, 10),
207
- tool: "Edit",
208
- target: "src/pages/home.ts",
209
- agent: "claude",
210
- allowedBy: "approved",
211
- result: "done",
212
- conversationId: "conv-1",
213
- conversationTitle: "Rename the home page",
214
- isReadOnly: false,
215
- isAutoFix: false,
216
- };
217
-
218
- const summary = (id: string, number: number) => ({
219
- id,
220
- number,
221
- title: `Change ${number}`,
222
- state: "applied",
223
- createdAtMs: Date.UTC(2026, 9, 15, 10),
224
- added: 1,
225
- removed: 0,
226
- scope: "safe",
227
- agent: "claude",
228
- files: [],
229
- isAutoFix: false,
230
- approvalsNeeded: 0,
231
- builderOps: 0,
232
- typecheck: "passed",
233
- });
234
-
235
- beforeEach(() => {
236
- reads.length = 0;
237
- authFetch.mockReset();
238
- route.query = {};
239
- pageReads.clear();
240
- refreshPageBlocks.mockClear();
241
- vi.stubGlobal("useApiData", useApiData);
242
- vi.stubGlobal("useApiPagedData", useApiPagedData);
243
- vi.stubGlobal("refreshPageBlocks", refreshPageBlocks);
244
- vi.stubGlobal("useAuthFetch", () => ({ $authFetch: authFetch }));
245
- installApiErrorPresenter();
246
- vi.stubGlobal("useI18n", () => ({
247
- t: (key: string) => key,
248
- te: () => false,
249
- }));
250
- vi.stubGlobal("useRegionalFormat", () => ({
251
- dateTimeFormat: (options: Intl.DateTimeFormatOptions) =>
252
- new Intl.DateTimeFormat("en-GB", { ...options, timeZone: "UTC" }),
253
- }));
254
- vi.stubGlobal("useToast", () => ({ add: vi.fn() }));
255
- vi.stubGlobal("useConfirmFrom", () => ({ confirmFrom: vi.fn() }));
256
- });
257
-
258
- afterEach(() => {
259
- vi.unstubAllGlobals();
260
- });
261
-
262
- const mount = (component: Parameters<typeof shallowMount>[0], props = {}) =>
263
- shallowMount(component, {
264
- props,
265
- global: { stubs: { ...GLOBAL_STUBS, UnavailableState: false } },
266
- });
267
-
268
- describe("activity detail", () => {
269
- it("reads the entry its row names with the page, not with $authFetch", async () => {
270
- backend = () => ({ ...ROW, args: { file_path: "src/pages/home.ts" } });
271
- const wrapper = mount(ActivityDetail, { rowData: ROW });
272
- await flushPromises();
273
- expect(reads).toEqual([{ url: "/ai/activity/act-1" }]);
274
- expect(authFetch).not.toHaveBeenCalled();
275
- expect(wrapper.findComponent(UnavailableState).exists()).toBe(false);
276
- expect(wrapper.find('[data-stub="USkeleton"]').exists()).toBe(false);
277
- });
278
-
279
- it("says the assistant is not running on a 503, and reads again on retry", async () => {
280
- backend = () => {
281
- throw unavailable();
282
- };
283
- const wrapper = mount(ActivityDetail, { rowData: ROW });
284
- await flushPromises();
285
- const state = wrapper.findComponent(UnavailableState);
286
- expect(state.props("failure")).toBe("unavailable");
287
- backend = () => ROW;
288
- state.vm.$emit("retry");
289
- await flushPromises();
290
- expect(reads).toHaveLength(2);
291
- expect(wrapper.findComponent(UnavailableState).exists()).toBe(false);
292
- });
293
- });
294
-
295
- describe("changes view", () => {
296
- const PAGE = { results: [summary("cs-1", 1), summary("cs-2", 2)], total: 3 };
297
- const NEXT_PAGE = { results: [summary("cs-3", 3)], total: 3 };
298
-
299
- function changesBackend({ url, query }: Read): unknown {
300
- if (url === "/ai/status") return { checkpointsAvailable: true };
301
- if (url === "/ai/changes") return query?.offset ? NEXT_PAGE : PAGE;
302
- return { changeSet: summary("cs-1", 1), files: [] };
303
- }
304
-
305
- /** The paged list's requests, which go through the handler's `$authFetch`. */
306
- function listReads(): unknown[] {
307
- return authFetch.mock.calls.map(([url, options]) => [
308
- url,
309
- (options as { query: unknown }).query,
310
- ]);
311
- }
312
-
313
- beforeEach(() => {
314
- authFetch.mockImplementation(async (url: string, options: Read) =>
315
- changesBackend({ url, query: options.query }),
316
- );
317
- });
318
-
319
- it("reads the status and the first page with the page, and opens the set the URL names", async () => {
320
- backend = changesBackend;
321
- route.query = { set: "cs-2" };
322
- const wrapper = mount(ChangesView);
323
- await flushPromises();
324
- expect(reads).toEqual([{ url: "/ai/status" }]);
325
- expect(listReads()).toEqual([["/ai/changes", { offset: 0, limit: 30 }]]);
326
- expect(wrapper.findComponent(ChangeSetPanel).props("changeSetId")).toBe(
327
- "cs-2",
328
- );
329
- });
330
-
331
- it("selects the first set when the URL names none", async () => {
332
- backend = changesBackend;
333
- const wrapper = mount(ChangesView);
334
- await flushPromises();
335
- expect(wrapper.findComponent(ChangeSetPanel).props("changeSetId")).toBe(
336
- "cs-1",
337
- );
338
- });
339
-
340
- it("appends the next page on Load more, and reads every loaded page again on a page refresh", async () => {
341
- backend = changesBackend;
342
- const wrapper = mount(ChangesView);
343
- await flushPromises();
344
- const loadMoreButton = () =>
345
- wrapper
346
- .findAllComponents({ name: "UButton" })
347
- .find(
348
- (button) =>
349
- button.vm.$attrs.label === "dms_assistant.views.common.load_more",
350
- );
351
- loadMoreButton()!.vm.$emit("click");
352
- await flushPromises();
353
- expect(listReads().at(-1)).toEqual([
354
- "/ai/changes",
355
- { offset: 2, limit: 30 },
356
- ]);
357
- const items = () =>
358
- (
359
- wrapper.findComponent({ name: "DmsMasterDetail" }).vm.$attrs.items as {
360
- value: string;
361
- }[]
362
- ).map((item) => item.value);
363
- expect(items()).toEqual(["cs-1", "cs-2", "cs-3"]);
364
- expect(loadMoreButton()).toBeUndefined();
365
-
366
- // A change set undone in the panel refreshes the page, which reads the
367
- // pages loaded again rather than dropping the second one.
368
- authFetch.mockClear();
369
- await refreshPageBlocks();
370
- await flushPromises();
371
- expect(listReads()).toEqual([
372
- ["/ai/changes", { offset: 0, limit: 30 }],
373
- ["/ai/changes", { offset: 2, limit: 30 }],
374
- ]);
375
- expect(items()).toEqual(["cs-1", "cs-2", "cs-3"]);
376
- });
377
-
378
- it("reads the filtered first page when the scope changes", async () => {
379
- backend = changesBackend;
380
- const wrapper = mount(ChangesView);
381
- await flushPromises();
382
- wrapper
383
- .findComponent({ name: "DmsSegmentedControl" })
384
- .vm.$emit("update:modelValue", "vibe");
385
- await flushPromises();
386
- expect(listReads().at(-1)).toEqual([
387
- "/ai/changes",
388
- { offset: 0, limit: 30, scope: "vibe", filter_scope: "is:vibe" },
389
- ]);
390
- });
391
- });
392
-
393
- describe("change set panel", () => {
394
- it("refreshes the page once a set is redone, instead of reading on its own", async () => {
395
- backend = () => ({
396
- changeSet: { ...summary("cs-1", 1), state: "undone" },
397
- files: [],
398
- });
399
- authFetch.mockResolvedValue({});
400
- const wrapper = mount(ChangeSetPanel, { changeSetId: "cs-1" });
401
- await flushPromises();
402
- expect(reads).toEqual([{ url: "/ai/changes/cs-1" }]);
403
- const redo = wrapper
404
- .findAllComponents({ name: "UButton" })
405
- .find(
406
- (button) =>
407
- button.vm.$attrs.label === "dms_assistant.views.changes.redo",
408
- );
409
- redo!.vm.$emit("click");
410
- await flushPromises();
411
- expect(authFetch).toHaveBeenCalledWith("/ai/changes/cs-1/redo", {
412
- method: "POST",
413
- body: {},
414
- });
415
- expect(refreshPageBlocks).toHaveBeenCalledTimes(1);
416
- expect(reads).toEqual([
417
- { url: "/ai/changes/cs-1" },
418
- { url: "/ai/changes/cs-1" },
419
- ]);
420
- });
421
- });
422
-
423
- describe("change set actions", () => {
424
- it("stay busy until the page refresh a redo asks for is done", async () => {
425
- backend = () => ({
426
- changeSet: { ...summary("cs-1", 1), state: "undone" },
427
- files: [],
428
- });
429
- authFetch.mockResolvedValue({});
430
- let finishRefresh: () => void = () => undefined;
431
- refreshPageBlocks.mockImplementationOnce(
432
- () => new Promise<void>((resolve) => (finishRefresh = resolve)),
433
- );
434
- const wrapper = mount(ChangeSetPanel, { changeSetId: "cs-1" });
435
- await flushPromises();
436
- const redo = () =>
437
- wrapper
438
- .findAllComponents({ name: "UButton" })
439
- .find(
440
- (button) =>
441
- button.vm.$attrs.label === "dms_assistant.views.changes.redo",
442
- )!;
443
- redo().vm.$emit("click");
444
- await flushPromises();
445
- expect(refreshPageBlocks).toHaveBeenCalledTimes(1);
446
- expect(redo().vm.$attrs.loading).toBe(true);
447
- finishRefresh();
448
- await flushPromises();
449
- expect(redo().vm.$attrs.loading).toBe(false);
450
- });
451
- });