@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,176 +0,0 @@
|
|
|
1
|
-
import { vi } from "vitest";
|
|
2
|
-
import { shallowRef } from "vue";
|
|
3
|
-
import { CHAT_I18N_KEY } from "../../app/chat/composables/useChatI18n";
|
|
4
|
-
import type { OnboardingApi } from "../../app/onboarding/api";
|
|
5
|
-
import { NO_CONTENT, type ProjectContent } from "../../app/onboarding/content";
|
|
6
|
-
import {
|
|
7
|
-
type ConnectMemory,
|
|
8
|
-
connectMemory,
|
|
9
|
-
type WrittenConnection,
|
|
10
|
-
} from "../../app/onboarding/connect-memory";
|
|
11
|
-
import type {
|
|
12
|
-
OnboardingState,
|
|
13
|
-
ProviderLogin,
|
|
14
|
-
} from "../../app/onboarding/contract";
|
|
15
|
-
import {
|
|
16
|
-
createOnboarding,
|
|
17
|
-
type OnboardingController,
|
|
18
|
-
} from "../../app/onboarding/controller";
|
|
19
|
-
import type {
|
|
20
|
-
OnboardingPreferences,
|
|
21
|
-
PreferenceStore,
|
|
22
|
-
} from "../../app/onboarding/preferences";
|
|
23
|
-
import { ONBOARDING_CONTROLLER_KEY } from "../../app/onboarding/runtime";
|
|
24
|
-
import views from "../../i18n/locales/dms-assistant-views-en-GB.json";
|
|
25
|
-
import { createTestI18n } from "./i18n";
|
|
26
|
-
import { OnboardingModal } from "./stand-ins/OnboardingModal";
|
|
27
|
-
import { UCheckbox } from "./stand-ins/UCheckbox";
|
|
28
|
-
import { UFormField } from "./stand-ins/UFormField";
|
|
29
|
-
import { PANEL_STUBS } from "./stubs";
|
|
30
|
-
|
|
31
|
-
export const SIGNED_OUT: ProviderLogin = { status: "signed-out" };
|
|
32
|
-
|
|
33
|
-
export const CLAUDE_LOGIN: ProviderLogin = {
|
|
34
|
-
status: "signed-in",
|
|
35
|
-
source: "saved",
|
|
36
|
-
email: "owner@example.com",
|
|
37
|
-
plan: "max",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export function onboardingState(
|
|
41
|
-
logins: Partial<OnboardingState["logins"]> = {},
|
|
42
|
-
overrides: Partial<OnboardingState> = {},
|
|
43
|
-
): OnboardingState {
|
|
44
|
-
return {
|
|
45
|
-
bootId: "boot-1",
|
|
46
|
-
provider: "claude",
|
|
47
|
-
logins: { claude: SIGNED_OUT, codex: SIGNED_OUT, ...logins },
|
|
48
|
-
...overrides,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Preferences kept in memory, as `localStorage` keeps them across controllers. */
|
|
53
|
-
export function memoryPreferences(
|
|
54
|
-
initial: OnboardingPreferences = { dontShow: false, seenBootId: null },
|
|
55
|
-
): PreferenceStore & { saved: OnboardingPreferences } {
|
|
56
|
-
const store = {
|
|
57
|
-
saved: initial,
|
|
58
|
-
read: () => store.saved,
|
|
59
|
-
write: (next: OnboardingPreferences) => {
|
|
60
|
-
store.saved = next;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
return store;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** The tab's connect memory over a map, as `sessionStorage` keeps it across a reload of the tab. */
|
|
67
|
-
export function memoryConnects(
|
|
68
|
-
initial: WrittenConnection | null = null,
|
|
69
|
-
): ConnectMemory {
|
|
70
|
-
const items = new Map<string, string>();
|
|
71
|
-
const memory = connectMemory(
|
|
72
|
-
() => ({
|
|
73
|
-
getItem: (key) => items.get(key) ?? null,
|
|
74
|
-
setItem: (key, value) => {
|
|
75
|
-
items.set(key, value);
|
|
76
|
-
},
|
|
77
|
-
removeItem: (key) => {
|
|
78
|
-
items.delete(key);
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
() => "owner-1",
|
|
82
|
-
);
|
|
83
|
-
if (initial !== null) memory.write(memory.begin(), initial);
|
|
84
|
-
return memory;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface OnboardingHarness {
|
|
88
|
-
controller: OnboardingController;
|
|
89
|
-
api: {
|
|
90
|
-
readState: ReturnType<typeof vi.fn<OnboardingApi["readState"]>>;
|
|
91
|
-
checkClaudeToken: ReturnType<
|
|
92
|
-
typeof vi.fn<OnboardingApi["checkClaudeToken"]>
|
|
93
|
-
>;
|
|
94
|
-
setProvider: ReturnType<typeof vi.fn<OnboardingApi["setProvider"]>>;
|
|
95
|
-
finishCodexSignIn: ReturnType<
|
|
96
|
-
typeof vi.fn<OnboardingApi["finishCodexSignIn"]>
|
|
97
|
-
>;
|
|
98
|
-
};
|
|
99
|
-
assistant: {
|
|
100
|
-
startConversation: ReturnType<typeof vi.fn>;
|
|
101
|
-
openConversation: ReturnType<typeof vi.fn>;
|
|
102
|
-
navigate: ReturnType<typeof vi.fn>;
|
|
103
|
-
};
|
|
104
|
-
openTab: ReturnType<typeof vi.fn>;
|
|
105
|
-
/** Changes what the project holds, as the next read of its content answers. */
|
|
106
|
-
setContent: (next: ProjectContent) => void;
|
|
107
|
-
/** What a mounted view injects: the controller and the views' English strings. */
|
|
108
|
-
provide: Record<symbol, unknown>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface HarnessOptions {
|
|
112
|
-
state?: OnboardingState;
|
|
113
|
-
content?: ProjectContent;
|
|
114
|
-
preferences?: PreferenceStore;
|
|
115
|
-
canConnectDatabase?: boolean;
|
|
116
|
-
connecting?: ConnectMemory;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** A controller over a backend that answers `state` until a test says otherwise. */
|
|
120
|
-
export function createOnboardingHarness(
|
|
121
|
-
options: HarnessOptions = {},
|
|
122
|
-
): OnboardingHarness {
|
|
123
|
-
const state = options.state ?? onboardingState();
|
|
124
|
-
const api = {
|
|
125
|
-
readState: vi.fn<OnboardingApi["readState"]>(async () => state),
|
|
126
|
-
checkClaudeToken: vi.fn<OnboardingApi["checkClaudeToken"]>(async () => ({
|
|
127
|
-
ok: false,
|
|
128
|
-
reason: "rejected" as const,
|
|
129
|
-
})),
|
|
130
|
-
setProvider: vi.fn<OnboardingApi["setProvider"]>(async (provider) => ({
|
|
131
|
-
...state,
|
|
132
|
-
provider,
|
|
133
|
-
})),
|
|
134
|
-
finishCodexSignIn: vi.fn<OnboardingApi["finishCodexSignIn"]>(
|
|
135
|
-
async () => undefined,
|
|
136
|
-
),
|
|
137
|
-
};
|
|
138
|
-
const assistant = {
|
|
139
|
-
startConversation: vi.fn(),
|
|
140
|
-
openConversation: vi.fn(),
|
|
141
|
-
navigate: vi.fn(),
|
|
142
|
-
};
|
|
143
|
-
const openTab = vi.fn();
|
|
144
|
-
let content = options.content ?? NO_CONTENT;
|
|
145
|
-
const controller = createOnboarding({
|
|
146
|
-
api,
|
|
147
|
-
assistant,
|
|
148
|
-
readContent: async () => content,
|
|
149
|
-
preferences: options.preferences ?? memoryPreferences(),
|
|
150
|
-
canConnectDatabase: options.canConnectDatabase ?? true,
|
|
151
|
-
connecting: options.connecting ?? memoryConnects(),
|
|
152
|
-
openTab,
|
|
153
|
-
});
|
|
154
|
-
return {
|
|
155
|
-
controller,
|
|
156
|
-
api,
|
|
157
|
-
assistant,
|
|
158
|
-
openTab,
|
|
159
|
-
setContent: (next) => {
|
|
160
|
-
content = next;
|
|
161
|
-
},
|
|
162
|
-
provide: {
|
|
163
|
-
[ONBOARDING_CONTROLLER_KEY]: shallowRef(controller),
|
|
164
|
-
[CHAT_I18N_KEY]: createTestI18n(views),
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** The Nuxt UI and DMS components the onboarding draws, as light stand-ins. */
|
|
170
|
-
export const ONBOARDING_STUBS = {
|
|
171
|
-
...PANEL_STUBS,
|
|
172
|
-
UModal: OnboardingModal,
|
|
173
|
-
UCheckbox,
|
|
174
|
-
UFormField,
|
|
175
|
-
DmsIconWell: true,
|
|
176
|
-
};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { CONVERSATION_ID } from "./panel-harness";
|
|
2
|
-
|
|
3
|
-
export const DIFF_REQUEST = {
|
|
4
|
-
type: "permission_request",
|
|
5
|
-
requestId: "r1",
|
|
6
|
-
callId: "c1",
|
|
7
|
-
toolName: "Edit",
|
|
8
|
-
args: { file_path: "/repo/crm/customers/customer.form.ts" },
|
|
9
|
-
summary: "Edit customer.form.ts",
|
|
10
|
-
kind: "edit",
|
|
11
|
-
alwaysAsk: false,
|
|
12
|
-
preview: {
|
|
13
|
-
type: "diff",
|
|
14
|
-
path: "/repo/crm/customers/customer.form.ts",
|
|
15
|
-
relativePath: "crm/customers/customer.form.ts",
|
|
16
|
-
isNewFile: false,
|
|
17
|
-
added: 1,
|
|
18
|
-
removed: 1,
|
|
19
|
-
hunks: [
|
|
20
|
-
{
|
|
21
|
-
oldStart: 42,
|
|
22
|
-
newStart: 42,
|
|
23
|
-
lines: [
|
|
24
|
-
{ kind: "remove", text: 'label: "VAT",' },
|
|
25
|
-
{ kind: "add", text: 'label: "VAT number",' },
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
ruleOptions: [
|
|
31
|
-
{ kind: "file", value: "crm/customers/customer.form.ts" },
|
|
32
|
-
{ kind: "directory", value: "crm/customers/" },
|
|
33
|
-
],
|
|
34
|
-
createdAtMs: Date.now(),
|
|
35
|
-
expiresAtMs: Date.now() + 252_000,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const COMMAND_REQUEST = {
|
|
39
|
-
...DIFF_REQUEST,
|
|
40
|
-
requestId: "r2",
|
|
41
|
-
callId: "c2",
|
|
42
|
-
toolName: "Bash",
|
|
43
|
-
args: { command: "pnpm add jsvat" },
|
|
44
|
-
summary: "Run pnpm add jsvat",
|
|
45
|
-
kind: "command",
|
|
46
|
-
preview: {
|
|
47
|
-
type: "command",
|
|
48
|
-
command: "pnpm add jsvat",
|
|
49
|
-
cwd: "/repo",
|
|
50
|
-
effect: "adds_dependency",
|
|
51
|
-
touches: ["package.json", "pnpm-lock.yaml"],
|
|
52
|
-
},
|
|
53
|
-
ruleOptions: [{ kind: "command", value: "pnpm add" }],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const DELETE_REQUEST = {
|
|
57
|
-
...DIFF_REQUEST,
|
|
58
|
-
requestId: "r3",
|
|
59
|
-
callId: "c3",
|
|
60
|
-
toolName: "mcp__dms__builder_delete_resource",
|
|
61
|
-
args: { ref: "legacy_coupons", keepData: false },
|
|
62
|
-
summary: "Delete the table legacy_coupons",
|
|
63
|
-
kind: "destructive",
|
|
64
|
-
alwaysAsk: false,
|
|
65
|
-
preview: {
|
|
66
|
-
type: "destructive",
|
|
67
|
-
operation: "builder_delete_resource",
|
|
68
|
-
target: "legacy_coupons",
|
|
69
|
-
consequence: "deletes_data",
|
|
70
|
-
confirmText: "legacy_coupons",
|
|
71
|
-
},
|
|
72
|
-
ruleOptions: [],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const CONFIGURE_DIFF = `--- a/antelope.config.ts\n+++ b/antelope.config.ts\n${"+ shop: {},\n".repeat(30)}`;
|
|
76
|
-
|
|
77
|
-
const CONFIGURE_STEPS = [
|
|
78
|
-
{ action: "AddModule", module: "shop", version: "1.0.0" },
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
export const CONFIGURE_REQUEST = {
|
|
82
|
-
...DIFF_REQUEST,
|
|
83
|
-
requestId: "r4",
|
|
84
|
-
callId: "c4",
|
|
85
|
-
toolName: "mcp__dms__builder_configure_project",
|
|
86
|
-
args: { steps: CONFIGURE_STEPS },
|
|
87
|
-
summary: "Configure project",
|
|
88
|
-
kind: "builder",
|
|
89
|
-
preview: {
|
|
90
|
-
type: "held",
|
|
91
|
-
operation: "builder_configure_project",
|
|
92
|
-
details: {
|
|
93
|
-
plannedChanges: [
|
|
94
|
-
{ path: "antelope.config.ts", kind: "modify", diff: CONFIGURE_DIFF },
|
|
95
|
-
],
|
|
96
|
-
steps: CONFIGURE_STEPS,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
ruleOptions: [],
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export const MAP_REQUEST = {
|
|
103
|
-
...CONFIGURE_REQUEST,
|
|
104
|
-
requestId: "r5",
|
|
105
|
-
callId: "c5",
|
|
106
|
-
toolName: "mcp__dms__builder_map_resources",
|
|
107
|
-
args: { module: "shop", connection: "pg-main", resources: [] },
|
|
108
|
-
summary: "Map database tables",
|
|
109
|
-
preview: {
|
|
110
|
-
type: "held",
|
|
111
|
-
operation: "builder_map_resources",
|
|
112
|
-
details: {
|
|
113
|
-
connection: "pg-main",
|
|
114
|
-
module: "shop",
|
|
115
|
-
pagesToRemove: ["orders", "customers"],
|
|
116
|
-
resources: [],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const CHANGE_SET = {
|
|
122
|
-
id: "cs-14",
|
|
123
|
-
number: 14,
|
|
124
|
-
conversationId: CONVERSATION_ID,
|
|
125
|
-
title: "Top customers",
|
|
126
|
-
createdAtMs: Date.now(),
|
|
127
|
-
agent: "claude",
|
|
128
|
-
scope: "safe",
|
|
129
|
-
isAutoFix: false,
|
|
130
|
-
overlapped: false,
|
|
131
|
-
files: [
|
|
132
|
-
{
|
|
133
|
-
path: "sales/overview.page.ts",
|
|
134
|
-
status: "modified",
|
|
135
|
-
added: 14,
|
|
136
|
-
removed: 1,
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
path: "sales/queries/top-customers.ts",
|
|
140
|
-
status: "added",
|
|
141
|
-
added: 22,
|
|
142
|
-
removed: 0,
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
added: 36,
|
|
146
|
-
removed: 1,
|
|
147
|
-
typecheck: "passed",
|
|
148
|
-
state: "applied",
|
|
149
|
-
approvalsNeeded: 0,
|
|
150
|
-
builderOps: 2,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export function keydown(target: Element, key: string): void {
|
|
154
|
-
target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true }));
|
|
155
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
|
|
2
|
-
import { type Mock, vi } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
defineComponent,
|
|
5
|
-
h,
|
|
6
|
-
nextTick,
|
|
7
|
-
readonly,
|
|
8
|
-
ref,
|
|
9
|
-
type Ref,
|
|
10
|
-
shallowRef,
|
|
11
|
-
} from "vue";
|
|
12
|
-
import ChatPanel from "../../app/components/ChatPanel.vue";
|
|
13
|
-
import {
|
|
14
|
-
ASSISTANT_SESSION_KEY,
|
|
15
|
-
type AssistantSession,
|
|
16
|
-
type ChatPanelState,
|
|
17
|
-
} from "../../app/runtime/assistant-session";
|
|
18
|
-
import type { ChannelStatus } from "../../app/runtime/channel-client";
|
|
19
|
-
import {
|
|
20
|
-
type ChatTransportHub,
|
|
21
|
-
createChatTransport,
|
|
22
|
-
} from "../../app/runtime/chat-transport";
|
|
23
|
-
import type { LauncherState } from "../../app/runtime/launcher-state";
|
|
24
|
-
import { createPanelIntents } from "../../app/runtime/panel-intents";
|
|
25
|
-
import { CHAT_I18N_KEY } from "../../app/chat/composables/useChatI18n";
|
|
26
|
-
import { createTestI18n } from "./i18n";
|
|
27
|
-
import { PANEL_STUBS } from "./stubs";
|
|
28
|
-
import type { SidecarStatus } from "../../app/runtime/sidecar-status";
|
|
29
|
-
|
|
30
|
-
export const CONVERSATION_ID = "conv-native-1";
|
|
31
|
-
|
|
32
|
-
/** A panel mounted on a fake stream: what it sent, and handles to drive it. */
|
|
33
|
-
export interface Harness {
|
|
34
|
-
session: AssistantSession;
|
|
35
|
-
hub: ChatTransportHub;
|
|
36
|
-
sent: Array<Record<string, unknown>>;
|
|
37
|
-
reconnects: number;
|
|
38
|
-
sidecarStatus: Ref<SidecarStatus>;
|
|
39
|
-
setChannelStatus: (status: ChannelStatus) => void;
|
|
40
|
-
navigate: Mock<(path: string) => void>;
|
|
41
|
-
restart: Mock<() => Promise<void>>;
|
|
42
|
-
lastError: Ref<string | null>;
|
|
43
|
-
/** The state the session reports for the header launcher. */
|
|
44
|
-
launcherState: Ref<LauncherState>;
|
|
45
|
-
api: AssistantSession["api"];
|
|
46
|
-
/** How many holds keep the tab's stream open. */
|
|
47
|
-
streamHolds: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* What the DMS's `useSidePanel` hands the plugin: the open state it keeps in
|
|
52
|
-
* its cookie, and the ways to change it.
|
|
53
|
-
*/
|
|
54
|
-
export function createSidePanel(): ChatPanelState {
|
|
55
|
-
const isOpen = ref(false);
|
|
56
|
-
return {
|
|
57
|
-
isOpen: readonly(isOpen),
|
|
58
|
-
open: () => {
|
|
59
|
-
isOpen.value = true;
|
|
60
|
-
},
|
|
61
|
-
close: () => {
|
|
62
|
-
isOpen.value = false;
|
|
63
|
-
},
|
|
64
|
-
toggle: () => {
|
|
65
|
-
isOpen.value = !isOpen.value;
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function createHarness(): Harness {
|
|
71
|
-
let channelStatus: ChannelStatus = "connected";
|
|
72
|
-
const harness = {
|
|
73
|
-
sent: [] as Array<Record<string, unknown>>,
|
|
74
|
-
reconnects: 0,
|
|
75
|
-
sidecarStatus: ref<SidecarStatus>("connected"),
|
|
76
|
-
navigate: vi.fn(),
|
|
77
|
-
restart: vi.fn(async () => undefined),
|
|
78
|
-
lastError: ref<string | null>(null),
|
|
79
|
-
launcherState: ref<LauncherState>("connected"),
|
|
80
|
-
api: { get: vi.fn(async () => ({ conflicts: [] })), post: vi.fn() },
|
|
81
|
-
} as unknown as Harness;
|
|
82
|
-
harness.hub = createChatTransport({
|
|
83
|
-
send: (msg) => {
|
|
84
|
-
if (channelStatus !== "connected") return false;
|
|
85
|
-
harness.sent.push(msg as Record<string, unknown>);
|
|
86
|
-
return true;
|
|
87
|
-
},
|
|
88
|
-
reconnect: () => {
|
|
89
|
-
harness.reconnects += 1;
|
|
90
|
-
},
|
|
91
|
-
getStatus: () => channelStatus,
|
|
92
|
-
});
|
|
93
|
-
harness.streamHolds = 0;
|
|
94
|
-
harness.setChannelStatus = (status) => {
|
|
95
|
-
channelStatus = status;
|
|
96
|
-
harness.hub.announceStatus(status);
|
|
97
|
-
};
|
|
98
|
-
const panel = createSidePanel();
|
|
99
|
-
const intents = createPanelIntents();
|
|
100
|
-
harness.session = {
|
|
101
|
-
status: harness.sidecarStatus,
|
|
102
|
-
chat: harness.hub.transport,
|
|
103
|
-
panel,
|
|
104
|
-
navigate: harness.navigate,
|
|
105
|
-
openConversation: (conversationId) => {
|
|
106
|
-
intents.push({ kind: "open", conversationId });
|
|
107
|
-
panel.open();
|
|
108
|
-
},
|
|
109
|
-
startConversation: (prompt, mode, send) => {
|
|
110
|
-
intents.push({ kind: "start", prompt, mode, send });
|
|
111
|
-
panel.open();
|
|
112
|
-
},
|
|
113
|
-
holdStream: () => {
|
|
114
|
-
harness.streamHolds += 1;
|
|
115
|
-
return () => {
|
|
116
|
-
harness.streamHolds -= 1;
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
pendingApprovals: ref(0),
|
|
120
|
-
launcherState: readonly(harness.launcherState),
|
|
121
|
-
intents,
|
|
122
|
-
currentPage: ref({
|
|
123
|
-
path: "/sales/overview",
|
|
124
|
-
title: "Sales overview · DMS",
|
|
125
|
-
}),
|
|
126
|
-
api: harness.api,
|
|
127
|
-
lastError: harness.lastError,
|
|
128
|
-
restart: harness.restart,
|
|
129
|
-
};
|
|
130
|
-
return harness;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
let wrapper: VueWrapper | null = null;
|
|
134
|
-
|
|
135
|
-
/** Unmounts what the last test mounted. */
|
|
136
|
-
export function unmountPanel(): void {
|
|
137
|
-
wrapper?.unmount();
|
|
138
|
-
wrapper = null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* The DMS's side panel host: the panel's component is mounted while the panel
|
|
143
|
-
* is open, and unmounted when it closes.
|
|
144
|
-
*/
|
|
145
|
-
function sidePanelHost(panel: ChatPanelState) {
|
|
146
|
-
return defineComponent({
|
|
147
|
-
setup: () => () =>
|
|
148
|
-
h("aside", { "data-dms-side-panel": "" }, [
|
|
149
|
-
panel.isOpen.value ? h(ChatPanel) : null,
|
|
150
|
-
]),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** The providers the plugin installs, as a test mounts them. */
|
|
155
|
-
export function providedSession(session: AssistantSession | null) {
|
|
156
|
-
return {
|
|
157
|
-
[ASSISTANT_SESSION_KEY as symbol]: shallowRef(session),
|
|
158
|
-
[CHAT_I18N_KEY as symbol]: createTestI18n(),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function mountPanel(harness: Harness): VueWrapper {
|
|
163
|
-
wrapper = mount(sidePanelHost(harness.session.panel), {
|
|
164
|
-
attachTo: document.body,
|
|
165
|
-
global: {
|
|
166
|
-
provide: providedSession(harness.session),
|
|
167
|
-
stubs: PANEL_STUBS,
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
return wrapper;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export async function openPanel(harness: Harness): Promise<VueWrapper> {
|
|
174
|
-
const mounted = mountPanel(harness);
|
|
175
|
-
harness.session.panel.open();
|
|
176
|
-
await nextTick();
|
|
177
|
-
await flushPromises();
|
|
178
|
-
return mounted;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** A sidecar event for the panel's conversation. */
|
|
182
|
-
export function deliver(
|
|
183
|
-
harness: Harness,
|
|
184
|
-
event: Record<string, unknown>,
|
|
185
|
-
): void {
|
|
186
|
-
harness.hub.deliver({ conversationId: CONVERSATION_ID, ...event });
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function sentOfType(harness: Harness, type: string) {
|
|
190
|
-
return harness.sent.filter((msg) => msg.type === type);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export async function sendMessage(
|
|
194
|
-
panel: VueWrapper,
|
|
195
|
-
text: string,
|
|
196
|
-
): Promise<void> {
|
|
197
|
-
await panel.find("textarea").setValue(text);
|
|
198
|
-
await panel.find("form.composer").trigger("submit");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/** The first button whose text contains `label`. */
|
|
202
|
-
export function buttonWithText(
|
|
203
|
-
root: VueWrapper | ReturnType<VueWrapper["find"]>,
|
|
204
|
-
label: string,
|
|
205
|
-
) {
|
|
206
|
-
const button = root
|
|
207
|
-
.findAll("button")
|
|
208
|
-
.find((item) => item.text().includes(label));
|
|
209
|
-
if (button === undefined) throw new Error(`no button "${label}"`);
|
|
210
|
-
return button;
|
|
211
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
export const DmsBlockPreview = defineComponent({
|
|
4
|
-
name: "DmsBlockPreview",
|
|
5
|
-
props: {
|
|
6
|
-
tree: { type: [Object, Array], required: true },
|
|
7
|
-
blockTypes: { type: Object, default: undefined },
|
|
8
|
-
},
|
|
9
|
-
setup: (props) => () =>
|
|
10
|
-
h(
|
|
11
|
-
"div",
|
|
12
|
-
{
|
|
13
|
-
class: "dms-block-preview",
|
|
14
|
-
"data-fetches-block-types": String(props.blockTypes === undefined),
|
|
15
|
-
},
|
|
16
|
-
JSON.stringify(props.tree),
|
|
17
|
-
),
|
|
18
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
export const DmsEmptyState = defineComponent({
|
|
4
|
-
name: "DmsEmptyState",
|
|
5
|
-
props: {
|
|
6
|
-
title: { type: String, default: "" },
|
|
7
|
-
description: { type: String, default: "" },
|
|
8
|
-
},
|
|
9
|
-
setup:
|
|
10
|
-
(props, { slots }) =>
|
|
11
|
-
() =>
|
|
12
|
-
h("div", { class: "dms-empty" }, [
|
|
13
|
-
h("p", props.title),
|
|
14
|
-
h("p", props.description),
|
|
15
|
-
slots.actions?.(),
|
|
16
|
-
]),
|
|
17
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h, type PropType } from "vue";
|
|
2
|
-
|
|
3
|
-
interface SegmentItem {
|
|
4
|
-
value: string;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const DmsSegmentedControl = defineComponent({
|
|
9
|
-
name: "DmsSegmentedControl",
|
|
10
|
-
props: {
|
|
11
|
-
modelValue: { type: [String, Number], default: "" },
|
|
12
|
-
items: {
|
|
13
|
-
type: Array as PropType<SegmentItem[]>,
|
|
14
|
-
default: () => [],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
emits: ["update:modelValue"],
|
|
18
|
-
setup:
|
|
19
|
-
(props, { emit }) =>
|
|
20
|
-
() =>
|
|
21
|
-
h(
|
|
22
|
-
"div",
|
|
23
|
-
{ class: "dms-segmented" },
|
|
24
|
-
props.items.map((item) =>
|
|
25
|
-
h(
|
|
26
|
-
"button",
|
|
27
|
-
{
|
|
28
|
-
type: "button",
|
|
29
|
-
onClick: () => emit("update:modelValue", item.value),
|
|
30
|
-
},
|
|
31
|
-
item.label,
|
|
32
|
-
),
|
|
33
|
-
),
|
|
34
|
-
),
|
|
35
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
/** A modal that draws its content in place while open. */
|
|
4
|
-
export const OnboardingModal = defineComponent({
|
|
5
|
-
name: "UModal",
|
|
6
|
-
props: { open: { type: Boolean, default: false } },
|
|
7
|
-
setup(props, { slots }) {
|
|
8
|
-
return () =>
|
|
9
|
-
props.open
|
|
10
|
-
? h("div", { class: "u-modal", role: "dialog" }, slots.content?.())
|
|
11
|
-
: null;
|
|
12
|
-
},
|
|
13
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
/** Nuxt UI's button, drawn as a plain button with its label and slot. */
|
|
4
|
-
export const UButton = defineComponent({
|
|
5
|
-
name: "UButton",
|
|
6
|
-
inheritAttrs: false,
|
|
7
|
-
props: {
|
|
8
|
-
label: { type: String, default: "" },
|
|
9
|
-
disabled: { type: Boolean, default: false },
|
|
10
|
-
loading: { type: Boolean, default: false },
|
|
11
|
-
type: { type: String, default: "button" },
|
|
12
|
-
},
|
|
13
|
-
emits: ["click"],
|
|
14
|
-
setup(props, { slots, attrs, emit }) {
|
|
15
|
-
return () =>
|
|
16
|
-
h(
|
|
17
|
-
"button",
|
|
18
|
-
{
|
|
19
|
-
...attrs,
|
|
20
|
-
type: props.type,
|
|
21
|
-
disabled: props.disabled,
|
|
22
|
-
onClick: (event: MouseEvent) => emit("click", event),
|
|
23
|
-
},
|
|
24
|
-
[props.label, slots.default?.()],
|
|
25
|
-
);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
export const UCheckbox = defineComponent({
|
|
4
|
-
name: "UCheckbox",
|
|
5
|
-
props: {
|
|
6
|
-
modelValue: { type: Boolean, default: false },
|
|
7
|
-
label: { type: String, default: "" },
|
|
8
|
-
},
|
|
9
|
-
emits: ["update:modelValue"],
|
|
10
|
-
setup:
|
|
11
|
-
(props, { emit }) =>
|
|
12
|
-
() =>
|
|
13
|
-
h("label", [
|
|
14
|
-
h("input", {
|
|
15
|
-
type: "checkbox",
|
|
16
|
-
checked: props.modelValue,
|
|
17
|
-
onChange: (event: Event) =>
|
|
18
|
-
emit(
|
|
19
|
-
"update:modelValue",
|
|
20
|
-
(event.target as HTMLInputElement).checked,
|
|
21
|
-
),
|
|
22
|
-
}),
|
|
23
|
-
props.label,
|
|
24
|
-
]),
|
|
25
|
-
});
|