@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.
- package/package.json +6 -2
- package/frontend-vue/builder/tests/database-build.test.ts +0 -232
- package/frontend-vue/builder/tests/database-connect.test.ts +0 -348
- package/frontend-vue/builder/tests/database-display.test.ts +0 -112
- package/frontend-vue/builder/tests/database.test.ts +0 -138
- package/frontend-vue/builder/tests/enabled.test.ts +0 -17
- package/frontend-vue/builder/tests/owner-ui.test.ts +0 -29
- package/frontend-vue/builder/tests/stubs/frontend-module.ts +0 -63
- package/frontend-vue/builder/vitest.config.ts +0 -21
- package/frontend-vue/tests/assistant-actions.test.ts +0 -109
- package/frontend-vue/tests/assistant-activity.test.ts +0 -281
- package/frontend-vue/tests/backend-boundary.test.ts +0 -130
- package/frontend-vue/tests/backoff.test.ts +0 -40
- package/frontend-vue/tests/block-health.test.ts +0 -142
- package/frontend-vue/tests/channel-client.test.ts +0 -246
- package/frontend-vue/tests/chat/block-preview.test.ts +0 -367
- package/frontend-vue/tests/chat/block-target.test.ts +0 -133
- package/frontend-vue/tests/chat/build-view.test.ts +0 -171
- package/frontend-vue/tests/chat/chat-scroll.test.ts +0 -251
- package/frontend-vue/tests/chat/conversation-events.test.ts +0 -622
- package/frontend-vue/tests/chat/diff-and-keys.test.ts +0 -178
- package/frontend-vue/tests/chat/held-card.test.ts +0 -133
- package/frontend-vue/tests/chat/markdown-content.test.ts +0 -86
- package/frontend-vue/tests/chat/markdown.test.ts +0 -352
- package/frontend-vue/tests/chat/provider-notice.test.ts +0 -33
- package/frontend-vue/tests/chat/tool-lexicon.test.ts +0 -212
- package/frontend-vue/tests/chat/useChatChannel.test.ts +0 -124
- package/frontend-vue/tests/chat/useConversation.test.ts +0 -288
- package/frontend-vue/tests/chat-panel.test.ts +0 -300
- package/frontend-vue/tests/chat-transport.test.ts +0 -94
- package/frontend-vue/tests/embedding.test.ts +0 -10
- package/frontend-vue/tests/formal/connection-analysis-scenarios.ts +0 -130
- package/frontend-vue/tests/formal/connection-analysis-world.ts +0 -497
- package/frontend-vue/tests/formal/connection-analysis.test.ts +0 -36
- package/frontend-vue/tests/host-commands.test.ts +0 -182
- package/frontend-vue/tests/launcher-icon.test.ts +0 -62
- package/frontend-vue/tests/launcher-label.test.ts +0 -40
- package/frontend-vue/tests/launcher-state.test.ts +0 -215
- package/frontend-vue/tests/mockup-fold.test.ts +0 -95
- package/frontend-vue/tests/navigation.test.ts +0 -142
- package/frontend-vue/tests/onboarding-api.test.ts +0 -29
- package/frontend-vue/tests/onboarding-claude.test.ts +0 -144
- package/frontend-vue/tests/onboarding-connect-memory.test.ts +0 -126
- package/frontend-vue/tests/onboarding-controller-restart.test.ts +0 -134
- package/frontend-vue/tests/onboarding-controller.test.ts +0 -307
- package/frontend-vue/tests/onboarding-database-driver-install.test.ts +0 -112
- package/frontend-vue/tests/onboarding-database-engines.test.ts +0 -142
- package/frontend-vue/tests/onboarding-database-new-url.test.ts +0 -174
- package/frontend-vue/tests/onboarding-database-reload.test.ts +0 -229
- package/frontend-vue/tests/onboarding-database-tabs.test.ts +0 -184
- package/frontend-vue/tests/onboarding-database.test.ts +0 -540
- package/frontend-vue/tests/onboarding-deep-link.test.ts +0 -51
- package/frontend-vue/tests/onboarding-flow.test.ts +0 -204
- package/frontend-vue/tests/onboarding-install.test.ts +0 -62
- package/frontend-vue/tests/onboarding-mockups.test.ts +0 -86
- package/frontend-vue/tests/onboarding-scratch.test.ts +0 -70
- package/frontend-vue/tests/onboarding-widget.test.ts +0 -97
- package/frontend-vue/tests/palette-assistant.test.ts +0 -241
- package/frontend-vue/tests/panel-approvals.test.ts +0 -226
- package/frontend-vue/tests/panel-closed-conversation.test.ts +0 -53
- package/frontend-vue/tests/panel-mockup-prompt.test.ts +0 -238
- package/frontend-vue/tests/panel-modes.test.ts +0 -131
- package/frontend-vue/tests/panel-questions.test.ts +0 -151
- package/frontend-vue/tests/panel-states.test.ts +0 -252
- package/frontend-vue/tests/panel-tools.test.ts +0 -219
- package/frontend-vue/tests/session-gate.test.ts +0 -66
- package/frontend-vue/tests/sidecar-guest.test.ts +0 -81
- package/frontend-vue/tests/sidecar-status.test.ts +0 -117
- package/frontend-vue/tests/support/api-error-presenter.ts +0 -30
- package/frontend-vue/tests/support/database-connect.ts +0 -129
- package/frontend-vue/tests/support/dms-frontend-module.ts +0 -9
- package/frontend-vue/tests/support/dms-state.ts +0 -12
- package/frontend-vue/tests/support/fake-layout.ts +0 -119
- package/frontend-vue/tests/support/i18n.ts +0 -49
- package/frontend-vue/tests/support/onboarding-host.ts +0 -104
- package/frontend-vue/tests/support/onboarding.ts +0 -176
- package/frontend-vue/tests/support/panel-fixtures.ts +0 -155
- package/frontend-vue/tests/support/panel-harness.ts +0 -211
- package/frontend-vue/tests/support/setup-layout.ts +0 -3
- package/frontend-vue/tests/support/stand-ins/DmsBlockPreview.ts +0 -18
- package/frontend-vue/tests/support/stand-ins/DmsEmptyState.ts +0 -17
- package/frontend-vue/tests/support/stand-ins/DmsSegmentedControl.ts +0 -35
- package/frontend-vue/tests/support/stand-ins/DmsStatusPill.ts +0 -7
- package/frontend-vue/tests/support/stand-ins/OnboardingModal.ts +0 -13
- package/frontend-vue/tests/support/stand-ins/UBadge.ts +0 -7
- package/frontend-vue/tests/support/stand-ins/UButton.ts +0 -27
- package/frontend-vue/tests/support/stand-ins/UCheckbox.ts +0 -25
- package/frontend-vue/tests/support/stand-ins/UDropdownMenu.ts +0 -34
- package/frontend-vue/tests/support/stand-ins/UFormField.ts +0 -9
- package/frontend-vue/tests/support/stand-ins/UInput.ts +0 -16
- package/frontend-vue/tests/support/stand-ins/UKbd.ts +0 -7
- package/frontend-vue/tests/support/stand-ins/UModal.ts +0 -20
- package/frontend-vue/tests/support/stand-ins/UPopover.ts +0 -9
- package/frontend-vue/tests/support/stand-ins/UTabs.ts +0 -31
- package/frontend-vue/tests/support/stand-ins/UTextarea.ts +0 -19
- package/frontend-vue/tests/support/stubs.ts +0 -28
- package/frontend-vue/tests/views/api-data-reads.test.ts +0 -451
- package/frontend-vue/tests/views/api-error-presentation.test.ts +0 -89
- package/frontend-vue/tests/views/diff-view.test.ts +0 -167
- package/frontend-vue/tests/views/use-assistant.test.ts +0 -53
- package/frontend-vue/tests/views/view-format.test.ts +0 -59
- package/frontend-vue/vitest.config.ts +0 -33
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import type {
|
|
4
|
-
ConversationMessage,
|
|
5
|
-
ToolCallMessage,
|
|
6
|
-
} from "../../app/chat/types/conversation";
|
|
7
|
-
import { blockOutlineRect } from "../../app/chat/utils/block-outline";
|
|
8
|
-
import {
|
|
9
|
-
blockTargetFromPath,
|
|
10
|
-
blockTargetOf,
|
|
11
|
-
changingBlock,
|
|
12
|
-
} from "../../app/chat/utils/block-target";
|
|
13
|
-
|
|
14
|
-
function tool(toolName: string, args: unknown): ToolCallMessage {
|
|
15
|
-
return {
|
|
16
|
-
id: `${toolName}-${JSON.stringify(args)}`,
|
|
17
|
-
role: "tool",
|
|
18
|
-
callId: "call",
|
|
19
|
-
toolName: `mcp__dms-assistant__${toolName}`,
|
|
20
|
-
args,
|
|
21
|
-
status: "pending",
|
|
22
|
-
timestampMs: 0,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const user: ConversationMessage = {
|
|
27
|
-
id: "user",
|
|
28
|
-
role: "user",
|
|
29
|
-
content: "Add a chart",
|
|
30
|
-
timestampMs: 0,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
describe("the block a Builder call changes", () => {
|
|
34
|
-
it("reads the Builder path as a page and the layout path it draws (fails when the page is dropped or the slashes are kept)", () => {
|
|
35
|
-
expect(blockTargetFromPath("/shop/board#grid/row/kpi")).toEqual({
|
|
36
|
-
page: "/shop/board",
|
|
37
|
-
layoutPath: "grid.row.kpi",
|
|
38
|
-
});
|
|
39
|
-
expect(blockTargetFromPath("/dashboard#")).toBeNull();
|
|
40
|
-
expect(blockTargetFromPath("chart")).toBeNull();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("takes the changed block of a configure, the parent of an add and the named table view (fails when an add outlines nothing or a read outlines)", () => {
|
|
44
|
-
expect(
|
|
45
|
-
blockTargetOf(
|
|
46
|
-
tool("builder_configure_block", { path: "/d#grid/kpi", patch: {} }),
|
|
47
|
-
),
|
|
48
|
-
).toEqual({ page: "/d", layoutPath: "grid.kpi" });
|
|
49
|
-
expect(
|
|
50
|
-
blockTargetOf(
|
|
51
|
-
tool("builder_add_block", { page: "/d", parent: "/d#grid" }),
|
|
52
|
-
),
|
|
53
|
-
).toEqual({ page: "/d", layoutPath: "grid" });
|
|
54
|
-
expect(
|
|
55
|
-
blockTargetOf(
|
|
56
|
-
tool("builder_configure_table_view", {
|
|
57
|
-
pageRef: "/d/",
|
|
58
|
-
block: "orders",
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
).toEqual({ page: "/d", layoutPath: "orders" });
|
|
62
|
-
expect(blockTargetOf(tool("builder_add_block", { page: "/d" }))).toBeNull();
|
|
63
|
-
expect(
|
|
64
|
-
blockTargetOf(tool("builder_page_structure", { page: "/d" })),
|
|
65
|
-
).toBeNull();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("the block a running turn is changing", () => {
|
|
70
|
-
it("is the latest target of the current turn while it runs (fails when an earlier call or an earlier turn wins)", () => {
|
|
71
|
-
const earlier = tool("builder_remove_block", { path: "/d#old" });
|
|
72
|
-
const first = tool("builder_configure_block", { path: "/d#a" });
|
|
73
|
-
const read = tool("builder_page_structure", { page: "/d" });
|
|
74
|
-
const latest = tool("builder_move_block", { path: "/d#grid/b" });
|
|
75
|
-
expect(
|
|
76
|
-
changingBlock([earlier, user, first, latest, read], true, "/d"),
|
|
77
|
-
).toBe("grid.b");
|
|
78
|
-
expect(changingBlock([earlier, user, read], true, "/d")).toBeNull();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("is none when the block is on another page than the one on screen (fails when a same-named block of another page is outlined)", () => {
|
|
82
|
-
const call = tool("builder_configure_block", {
|
|
83
|
-
path: "/dashboard#grid/kpi",
|
|
84
|
-
});
|
|
85
|
-
expect(changingBlock([user, call], true, "/orders")).toBeNull();
|
|
86
|
-
expect(changingBlock([user, call], true, "/dashboard/")).toBe("grid.kpi");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("is none once the turn ends (fails when the outline stays after the change)", () => {
|
|
90
|
-
const call = tool("builder_configure_block", { path: "/d#a" });
|
|
91
|
-
expect(changingBlock([user, call], false, "/d")).toBeNull();
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
function block(path: string, box: { top: number; left: number }): HTMLElement {
|
|
96
|
-
const element = document.createElement("div");
|
|
97
|
-
element.setAttribute("data-dms-block", path);
|
|
98
|
-
element.getBoundingClientRect = () =>
|
|
99
|
-
DOMRect.fromRect({ x: box.left, y: box.top, width: 100, height: 50 });
|
|
100
|
-
return element;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
describe("the outline on the page", () => {
|
|
104
|
-
it("surrounds the block and the blocks drawn under it, not its siblings (fails on a prefix match such as grid2)", () => {
|
|
105
|
-
document.body.replaceChildren(
|
|
106
|
-
block("grid.kpi", { top: 10, left: 10 }),
|
|
107
|
-
block("grid.chart", { top: 100, left: 200 }),
|
|
108
|
-
block("grid2", { top: 500, left: 500 }),
|
|
109
|
-
);
|
|
110
|
-
expect(blockOutlineRect(document, "grid")).toEqual({
|
|
111
|
-
top: 10,
|
|
112
|
-
left: 10,
|
|
113
|
-
width: 290,
|
|
114
|
-
height: 140,
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("draws nothing while a modal dialog covers the page (fails when the outline paints over the dialog)", () => {
|
|
119
|
-
const dialog = document.createElement("div");
|
|
120
|
-
dialog.setAttribute("role", "dialog");
|
|
121
|
-
dialog.setAttribute("data-state", "open");
|
|
122
|
-
document.body.replaceChildren(block("chart", { top: 0, left: 0 }), dialog);
|
|
123
|
-
expect(blockOutlineRect(document, "chart")).toBeNull();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("ignores a copy of the block drawn in the chat's preview (fails when the preview is outlined)", () => {
|
|
127
|
-
const preview = document.createElement("div");
|
|
128
|
-
preview.setAttribute("data-dms-block-preview", "");
|
|
129
|
-
preview.append(block("chart", { top: 0, left: 0 }));
|
|
130
|
-
document.body.replaceChildren(preview);
|
|
131
|
-
expect(blockOutlineRect(document, "chart")).toBeNull();
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type {
|
|
3
|
-
ConversationMessage,
|
|
4
|
-
ToolCallMessage,
|
|
5
|
-
} from "../../app/chat/types/conversation";
|
|
6
|
-
import { buildView } from "../../app/chat/utils/build-view";
|
|
7
|
-
|
|
8
|
-
const BIKES = { mockup: "bikes" };
|
|
9
|
-
|
|
10
|
-
function report(ok: boolean, failures: string[]) {
|
|
11
|
-
return { ok, pages: [{ page: "/rentals", ok, failures }] };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function verify(ok: boolean, failures: string[]): ToolCallMessage {
|
|
15
|
-
return {
|
|
16
|
-
...tool(`v-${String(ok)}`, "mcp__dms__page_verify", { page: "/rentals" }),
|
|
17
|
-
result: [{ type: "text", text: JSON.stringify(report(ok, failures)) }],
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const request: ConversationMessage = {
|
|
22
|
-
id: "u1",
|
|
23
|
-
role: "user",
|
|
24
|
-
content: "Build bikes",
|
|
25
|
-
timestampMs: 0,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function tool(
|
|
29
|
-
id: string,
|
|
30
|
-
toolName: string,
|
|
31
|
-
args: unknown,
|
|
32
|
-
status: ToolCallMessage["status"] = "success",
|
|
33
|
-
): ToolCallMessage {
|
|
34
|
-
return {
|
|
35
|
-
id,
|
|
36
|
-
role: "tool",
|
|
37
|
-
callId: id,
|
|
38
|
-
toolName,
|
|
39
|
-
args,
|
|
40
|
-
status,
|
|
41
|
-
timestampMs: 0,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe("the build dialog's view of a build turn", () => {
|
|
46
|
-
it("lists the build's todos when it keeps some, its tool calls otherwise (fails when the calls hide the plan)", () => {
|
|
47
|
-
const todos = tool("t1", "TodoWrite", {
|
|
48
|
-
todos: [
|
|
49
|
-
{
|
|
50
|
-
content: "Create the pages",
|
|
51
|
-
activeForm: "Creating the pages",
|
|
52
|
-
status: "completed",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
content: "Compare",
|
|
56
|
-
activeForm: "Comparing with the mockup",
|
|
57
|
-
status: "in_progress",
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
});
|
|
61
|
-
const call = tool("c1", "mcp__dms-assistant__builder_page_structure", {
|
|
62
|
-
page: "/rentals",
|
|
63
|
-
});
|
|
64
|
-
const withTodos = buildView(BIKES, [request, call, todos], true);
|
|
65
|
-
expect(
|
|
66
|
-
withTodos.steps.map((step) =>
|
|
67
|
-
step.kind === "todo" ? [step.text, step.state] : null,
|
|
68
|
-
),
|
|
69
|
-
).toEqual([
|
|
70
|
-
["Create the pages", "done"],
|
|
71
|
-
["Comparing with the mockup", "running"],
|
|
72
|
-
]);
|
|
73
|
-
const withCalls = buildView(BIKES, [request, call], true);
|
|
74
|
-
expect(withCalls.steps.map((step) => step.kind)).toEqual(["tool"]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("only counts the turn since the build request (fails when an earlier turn's calls show)", () => {
|
|
78
|
-
const earlier = tool("c0", "Read", { file_path: "/a.ts" });
|
|
79
|
-
const view = buildView(BIKES, [earlier, request], true);
|
|
80
|
-
expect(view.steps).toEqual([]);
|
|
81
|
-
expect(view.outcome).toBe("running");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("opens the last page the build worked on, once done (fails when a non-Builder path or the block part is kept)", () => {
|
|
85
|
-
const view = buildView(
|
|
86
|
-
BIKES,
|
|
87
|
-
[
|
|
88
|
-
request,
|
|
89
|
-
tool("c1", "mcp__dms-assistant__builder_add_block", {
|
|
90
|
-
page: "/rentals#grid",
|
|
91
|
-
}),
|
|
92
|
-
tool("c2", "mcp__dms-assistant__navigate", { page: "/elsewhere" }),
|
|
93
|
-
],
|
|
94
|
-
false,
|
|
95
|
-
);
|
|
96
|
-
expect(view.pagePath).toBe("/rentals");
|
|
97
|
-
expect(view.outcome).toBe("built");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("shows a failed call as failed, and a call left open by the end of the turn as stopped (fails when a stopped call reads as done)", () => {
|
|
101
|
-
const view = buildView(
|
|
102
|
-
BIKES,
|
|
103
|
-
[
|
|
104
|
-
request,
|
|
105
|
-
tool("c1", "Bash", { command: "tsc" }, "error"),
|
|
106
|
-
tool("c2", "Read", { file_path: "/a.ts" }, "pending"),
|
|
107
|
-
],
|
|
108
|
-
false,
|
|
109
|
-
);
|
|
110
|
-
expect(view.steps.map((step) => step.state)).toEqual(["failed", "stopped"]);
|
|
111
|
-
expect(view.outcome).toBe("stopped");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("reads a build that ended on an error as failed, not built (fails when any ended turn reads as built)", () => {
|
|
115
|
-
const error: ConversationMessage = {
|
|
116
|
-
id: "e1",
|
|
117
|
-
role: "error",
|
|
118
|
-
content: "The agent stopped: rate limited",
|
|
119
|
-
isRetryable: true,
|
|
120
|
-
timestampMs: 0,
|
|
121
|
-
};
|
|
122
|
-
expect(buildView(BIKES, [request, error], false).outcome).toBe("failed");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("reads the outcome from the last page check, not the last call (fails when a failed check after a clean call reads as built)", () => {
|
|
126
|
-
const failing = verify(false, ["the table drew no rows"]);
|
|
127
|
-
const failed = buildView(
|
|
128
|
-
BIKES,
|
|
129
|
-
[request, failing, tool("c9", "mcp__dms-assistant__builder_refresh", {})],
|
|
130
|
-
false,
|
|
131
|
-
);
|
|
132
|
-
expect(failed.outcome).toBe("failed");
|
|
133
|
-
expect(failed.failures).toEqual(["/rentals: the table drew no rows"]);
|
|
134
|
-
const fixed = buildView(
|
|
135
|
-
BIKES,
|
|
136
|
-
[
|
|
137
|
-
request,
|
|
138
|
-
failing,
|
|
139
|
-
tool("c2", "Bash", { command: "tsc" }, "error"),
|
|
140
|
-
verify(true, []),
|
|
141
|
-
],
|
|
142
|
-
false,
|
|
143
|
-
);
|
|
144
|
-
expect(fixed.outcome).toBe("built");
|
|
145
|
-
expect(fixed.failures).toEqual([]);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("reads a report stored as text the way a reloaded chat keeps it (fails when only live content blocks are read)", () => {
|
|
149
|
-
const stored = {
|
|
150
|
-
...verify(false, ["blank page"]),
|
|
151
|
-
result: JSON.stringify(report(false, ["blank page"])),
|
|
152
|
-
};
|
|
153
|
-
expect(buildView(BIKES, [request, stored], false).failures).toEqual([
|
|
154
|
-
"/rentals: blank page",
|
|
155
|
-
]);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("opens the page built into when the build has one (fails when the dialog opens the last page touched instead)", () => {
|
|
159
|
-
const view = buildView(
|
|
160
|
-
{ mockup: "bikes", pageRef: "/shop/board" },
|
|
161
|
-
[
|
|
162
|
-
request,
|
|
163
|
-
tool("c1", "mcp__dms-assistant__builder_add_block", {
|
|
164
|
-
page: "/rentals#grid",
|
|
165
|
-
}),
|
|
166
|
-
],
|
|
167
|
-
false,
|
|
168
|
-
);
|
|
169
|
-
expect(view.pagePath).toBe("/shop/board");
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { flushPromises, type VueWrapper } from "@vue/test-utils";
|
|
3
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
4
|
-
import { nextTick } from "vue";
|
|
5
|
-
import {
|
|
6
|
-
CONVERSATION_ID,
|
|
7
|
-
createHarness,
|
|
8
|
-
deliver,
|
|
9
|
-
type Harness,
|
|
10
|
-
openPanel,
|
|
11
|
-
sendMessage,
|
|
12
|
-
unmountPanel,
|
|
13
|
-
} from "../support/panel-harness";
|
|
14
|
-
import {
|
|
15
|
-
type FakeScroller,
|
|
16
|
-
fakeScroller,
|
|
17
|
-
settleLayout,
|
|
18
|
-
} from "../support/fake-layout";
|
|
19
|
-
|
|
20
|
-
const BOTTOM_TOLERANCE_PX = 4;
|
|
21
|
-
|
|
22
|
-
interface OpenChat {
|
|
23
|
-
harness: Harness;
|
|
24
|
-
panel: VueWrapper;
|
|
25
|
-
scroller: FakeScroller;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function transcript(rows: number) {
|
|
29
|
-
return Array.from({ length: rows }, (_, index) => ({
|
|
30
|
-
role: index % 2 === 0 ? "user" : "assistant",
|
|
31
|
-
content: `message ${index}`,
|
|
32
|
-
timestampMs: 1_700_000_000_000 + index,
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** One browser frame: Vue renders, then layout is reported. */
|
|
37
|
-
async function frame(): Promise<void> {
|
|
38
|
-
await nextTick();
|
|
39
|
-
await flushPromises();
|
|
40
|
-
settleLayout();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function openChat(rows = 30): Promise<OpenChat> {
|
|
44
|
-
const harness = createHarness();
|
|
45
|
-
const panel = await openPanel(harness);
|
|
46
|
-
const scroller = fakeScroller(
|
|
47
|
-
panel.find<HTMLElement>(".chat-view-body").element,
|
|
48
|
-
);
|
|
49
|
-
deliver(harness, {
|
|
50
|
-
type: "conversation_snapshot",
|
|
51
|
-
messages: transcript(rows),
|
|
52
|
-
});
|
|
53
|
-
await frame();
|
|
54
|
-
return { harness, panel, scroller };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function growTranscript(chat: OpenChat, rows: number): Promise<void> {
|
|
58
|
-
deliver(chat.harness, {
|
|
59
|
-
type: "conversation_snapshot",
|
|
60
|
-
messages: transcript(rows),
|
|
61
|
-
});
|
|
62
|
-
await frame();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
beforeEach(() => {
|
|
66
|
-
localStorage.setItem("dms-assistant-conversation-id", CONVERSATION_ID);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
afterEach(() => {
|
|
70
|
-
unmountPanel();
|
|
71
|
-
localStorage.clear();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("the chat follows the conversation", () => {
|
|
75
|
-
it("shows the end of a chat opened from its snapshot", async () => {
|
|
76
|
-
const { scroller } = await openChat(60);
|
|
77
|
-
expect(scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
78
|
-
BOTTOM_TOLERANCE_PX,
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("stays at the bottom when the view loses height without any message arriving", async () => {
|
|
83
|
-
const { scroller } = await openChat();
|
|
84
|
-
scroller.viewportPx -= 250;
|
|
85
|
-
await frame();
|
|
86
|
-
expect(scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
87
|
-
BOTTOM_TOLERANCE_PX,
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("stays at the bottom when content grows without any message arriving", async () => {
|
|
92
|
-
const { scroller } = await openChat();
|
|
93
|
-
scroller.extraContentPx += 600;
|
|
94
|
-
await frame();
|
|
95
|
-
expect(scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
96
|
-
BOTTOM_TOLERANCE_PX,
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("stays at the bottom through one message taller than the old 80px margin", async () => {
|
|
101
|
-
const { scroller, harness } = await openChat();
|
|
102
|
-
deliver(harness, { type: "assistant_message_chunk", text: "answer" });
|
|
103
|
-
scroller.extraContentPx += 900;
|
|
104
|
-
await frame();
|
|
105
|
-
expect(scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
106
|
-
BOTTOM_TOLERANCE_PX,
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("does not pull the person back down once they scroll up", async () => {
|
|
111
|
-
const chat = await openChat();
|
|
112
|
-
chat.scroller.scrollTo(500);
|
|
113
|
-
await growTranscript(chat, 40);
|
|
114
|
-
chat.scroller.extraContentPx += 300;
|
|
115
|
-
await frame();
|
|
116
|
-
expect(
|
|
117
|
-
chat.panel.find<HTMLElement>(".chat-view-body").element.scrollTop,
|
|
118
|
-
).toBe(500);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("jumps to the bottom when a message is sent from far up", async () => {
|
|
122
|
-
const chat = await openChat();
|
|
123
|
-
chat.scroller.scrollTo(200);
|
|
124
|
-
await sendMessage(chat.panel, "and now this");
|
|
125
|
-
await frame();
|
|
126
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
127
|
-
BOTTOM_TOLERANCE_PX,
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("follows again once the person scrolls back to the bottom", async () => {
|
|
132
|
-
const chat = await openChat();
|
|
133
|
-
chat.scroller.scrollTo(500);
|
|
134
|
-
const bottom = chat.scroller.viewportPx;
|
|
135
|
-
chat.scroller.scrollTo(
|
|
136
|
-
chat.panel.find<HTMLElement>(".chat-view-body").element.scrollHeight -
|
|
137
|
-
bottom,
|
|
138
|
-
);
|
|
139
|
-
await growTranscript(chat, 40);
|
|
140
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
141
|
-
BOTTOM_TOLERANCE_PX,
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("stops following on an upward scroll that carries no input", async () => {
|
|
146
|
-
const chat = await openChat();
|
|
147
|
-
chat.scroller.scrollTo(500);
|
|
148
|
-
await growTranscript(chat, 40);
|
|
149
|
-
chat.scroller.extraContentPx += 300;
|
|
150
|
-
await frame();
|
|
151
|
-
expect(
|
|
152
|
-
chat.panel.find<HTMLElement>(".chat-view-body").element.scrollTop,
|
|
153
|
-
).toBe(500);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("keeps following when content above the view collapses and scroll anchoring moves the view up", async () => {
|
|
157
|
-
const chat = await openChat();
|
|
158
|
-
chat.scroller.extraContentPx += 800;
|
|
159
|
-
await frame();
|
|
160
|
-
chat.scroller.collapseAbove(600);
|
|
161
|
-
await frame();
|
|
162
|
-
await frame();
|
|
163
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
164
|
-
BOTTOM_TOLERANCE_PX,
|
|
165
|
-
);
|
|
166
|
-
chat.scroller.extraContentPx += 400;
|
|
167
|
-
await frame();
|
|
168
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
169
|
-
BOTTOM_TOLERANCE_PX,
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("keeps following when a collapse above the view comes with growth below it", async () => {
|
|
174
|
-
const chat = await openChat();
|
|
175
|
-
chat.scroller.extraContentPx += 800;
|
|
176
|
-
await frame();
|
|
177
|
-
chat.scroller.collapseAbove(600);
|
|
178
|
-
chat.scroller.extraContentPx += 700;
|
|
179
|
-
await frame();
|
|
180
|
-
await frame();
|
|
181
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
182
|
-
BOTTOM_TOLERANCE_PX,
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("keeps following when the view gains height and the browser clamps the scroll", async () => {
|
|
187
|
-
const chat = await openChat();
|
|
188
|
-
chat.scroller.viewportPx += 250;
|
|
189
|
-
await frame();
|
|
190
|
-
await frame();
|
|
191
|
-
chat.scroller.extraContentPx += 500;
|
|
192
|
-
await frame();
|
|
193
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
194
|
-
BOTTOM_TOLERANCE_PX,
|
|
195
|
-
);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("keeps following after the content shrinks under the view", async () => {
|
|
199
|
-
const chat = await openChat(60);
|
|
200
|
-
await growTranscript(chat, 20);
|
|
201
|
-
await growTranscript(chat, 30);
|
|
202
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
203
|
-
BOTTOM_TOLERANCE_PX,
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("ends at the bottom for a chat started from outside that sends its prompt", async () => {
|
|
208
|
-
const chat = await openChat();
|
|
209
|
-
chat.scroller.scrollTo(200);
|
|
210
|
-
chat.harness.session.startConversation("build me a page", undefined, true);
|
|
211
|
-
await frame();
|
|
212
|
-
await frame();
|
|
213
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
214
|
-
BOTTOM_TOLERANCE_PX,
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("opens another chat at its bottom, even after scrolling up in this one", async () => {
|
|
219
|
-
const chat = await openChat();
|
|
220
|
-
chat.scroller.scrollTo(200);
|
|
221
|
-
chat.harness.session.openConversation("conv-other");
|
|
222
|
-
await frame();
|
|
223
|
-
deliver(chat.harness, {
|
|
224
|
-
conversationId: "conv-other",
|
|
225
|
-
type: "conversation_snapshot",
|
|
226
|
-
messages: transcript(50),
|
|
227
|
-
});
|
|
228
|
-
await frame();
|
|
229
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
230
|
-
BOTTOM_TOLERANCE_PX,
|
|
231
|
-
);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("keeps following in a shorter chat opened from the bottom of a long one", async () => {
|
|
235
|
-
const chat = await openChat(60);
|
|
236
|
-
chat.harness.session.openConversation("conv-other");
|
|
237
|
-
await frame();
|
|
238
|
-
deliver(chat.harness, {
|
|
239
|
-
conversationId: "conv-other",
|
|
240
|
-
type: "conversation_snapshot",
|
|
241
|
-
messages: transcript(8),
|
|
242
|
-
});
|
|
243
|
-
await frame();
|
|
244
|
-
await frame();
|
|
245
|
-
chat.scroller.extraContentPx += 500;
|
|
246
|
-
await frame();
|
|
247
|
-
expect(chat.scroller.distanceFromBottom()).toBeLessThanOrEqual(
|
|
248
|
-
BOTTOM_TOLERANCE_PX,
|
|
249
|
-
);
|
|
250
|
-
});
|
|
251
|
-
});
|