@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,307 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { shallowRef } from "vue";
|
|
3
|
-
import type { ProviderLogin } from "../app/onboarding/contract";
|
|
4
|
-
import { CODEX_POLL_MS } from "../app/onboarding/controller";
|
|
5
|
-
import type { OnboardingController } from "../app/onboarding/controller";
|
|
6
|
-
import { publicOnboarding } from "../app/onboarding/runtime";
|
|
7
|
-
import {
|
|
8
|
-
CLAUDE_LOGIN,
|
|
9
|
-
createOnboardingHarness,
|
|
10
|
-
memoryConnects,
|
|
11
|
-
memoryPreferences,
|
|
12
|
-
type OnboardingHarness,
|
|
13
|
-
onboardingState,
|
|
14
|
-
} from "./support/onboarding";
|
|
15
|
-
|
|
16
|
-
const CONVERSATION = {
|
|
17
|
-
conversations: [{ id: "c1", title: "Orders dashboard", updatedAtMs: 1 }],
|
|
18
|
-
mockups: [],
|
|
19
|
-
databases: [],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const harnesses: OnboardingHarness[] = [];
|
|
23
|
-
|
|
24
|
-
function harnessed(
|
|
25
|
-
options: Parameters<typeof createOnboardingHarness>[0],
|
|
26
|
-
): OnboardingHarness {
|
|
27
|
-
const harness = createOnboardingHarness(options);
|
|
28
|
-
harnesses.push(harness);
|
|
29
|
-
return harness;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
afterEach(() => {
|
|
33
|
-
harnesses.splice(0).forEach((harness) => harness.controller.stop());
|
|
34
|
-
vi.useRealTimers();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe("the onboarding another module opens", () => {
|
|
38
|
-
it("is not available before the backend answered, then opens the popup on the step asked for", async () => {
|
|
39
|
-
const { controller } = harnessed({
|
|
40
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
41
|
-
content: CONVERSATION,
|
|
42
|
-
preferences: memoryPreferences({ dontShow: true, seenBootId: "boot-1" }),
|
|
43
|
-
});
|
|
44
|
-
const onboarding = publicOnboarding(shallowRef(controller));
|
|
45
|
-
expect(onboarding.isAvailable).toBe(false);
|
|
46
|
-
|
|
47
|
-
onboarding.open("connect-database");
|
|
48
|
-
await controller.load();
|
|
49
|
-
expect(onboarding.isAvailable).toBe(true);
|
|
50
|
-
expect(controller.isOpen.value).toBe(true);
|
|
51
|
-
expect(controller.flow.value.view).toEqual({ kind: "connect-database" });
|
|
52
|
-
|
|
53
|
-
controller.close();
|
|
54
|
-
onboarding.open();
|
|
55
|
-
expect(controller.isOpen.value).toBe(true);
|
|
56
|
-
expect(controller.flow.value.view).toEqual({ kind: "continue" });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("answers unavailable and opens nothing where the assistant does not run", () => {
|
|
60
|
-
const onboarding = publicOnboarding(
|
|
61
|
-
shallowRef<OnboardingController | null>(null),
|
|
62
|
-
);
|
|
63
|
-
expect(onboarding.isAvailable).toBe(false);
|
|
64
|
-
expect(() => onboarding.open("connect-database")).not.toThrow();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe("opening on its own", () => {
|
|
69
|
-
it("opens once per server start on a finished project, remembered in this browser", async () => {
|
|
70
|
-
const preferences = memoryPreferences();
|
|
71
|
-
const options = {
|
|
72
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
73
|
-
content: CONVERSATION,
|
|
74
|
-
preferences,
|
|
75
|
-
};
|
|
76
|
-
const first = harnessed(options).controller;
|
|
77
|
-
await first.load();
|
|
78
|
-
expect(first.isOpen.value).toBe(true);
|
|
79
|
-
|
|
80
|
-
const reload = harnessed(options).controller;
|
|
81
|
-
await reload.load();
|
|
82
|
-
expect(reload.isOpen.value).toBe(false);
|
|
83
|
-
|
|
84
|
-
const restarted = harnessed({
|
|
85
|
-
...options,
|
|
86
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }, { bootId: "boot-2" }),
|
|
87
|
-
}).controller;
|
|
88
|
-
await restarted.load();
|
|
89
|
-
expect(restarted.isOpen.value).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("opens on the connect form after a reload while this tab follows a connection it wrote", async () => {
|
|
93
|
-
const { controller } = harnessed({
|
|
94
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
95
|
-
content: CONVERSATION,
|
|
96
|
-
preferences: memoryPreferences({ dontShow: true, seenBootId: "boot-1" }),
|
|
97
|
-
connecting: memoryConnects({
|
|
98
|
-
engine: "mongodb",
|
|
99
|
-
connection: "shop",
|
|
100
|
-
access: { reachable: true, canRead: true, canWrite: false },
|
|
101
|
-
}),
|
|
102
|
-
});
|
|
103
|
-
await controller.load();
|
|
104
|
-
expect(controller.isOpen.value).toBe(true);
|
|
105
|
-
expect(controller.flow.value.view).toEqual({ kind: "connect-database" });
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("reopens on the connect form while this tab follows a connection it wrote, and on its start once it does not", async () => {
|
|
109
|
-
const connecting = memoryConnects();
|
|
110
|
-
const { controller } = harnessed({
|
|
111
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
112
|
-
content: CONVERSATION,
|
|
113
|
-
connecting,
|
|
114
|
-
});
|
|
115
|
-
await controller.load();
|
|
116
|
-
controller.open("connect-database");
|
|
117
|
-
connecting.write(connecting.begin(), {
|
|
118
|
-
engine: "mongodb",
|
|
119
|
-
connection: "shop",
|
|
120
|
-
access: { reachable: true, canRead: true, canWrite: false },
|
|
121
|
-
});
|
|
122
|
-
controller.close();
|
|
123
|
-
|
|
124
|
-
controller.open();
|
|
125
|
-
expect(controller.flow.value.view).toEqual({ kind: "connect-database" });
|
|
126
|
-
|
|
127
|
-
connecting.clear();
|
|
128
|
-
controller.close();
|
|
129
|
-
controller.open();
|
|
130
|
-
expect(controller.flow.value.view).toEqual({ kind: "continue" });
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("stays closed on a remembered connection where the builder does not run", async () => {
|
|
134
|
-
const { controller } = harnessed({
|
|
135
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
136
|
-
content: CONVERSATION,
|
|
137
|
-
preferences: memoryPreferences({ dontShow: true, seenBootId: "boot-1" }),
|
|
138
|
-
canConnectDatabase: false,
|
|
139
|
-
connecting: memoryConnects({
|
|
140
|
-
engine: "mongodb",
|
|
141
|
-
connection: "shop",
|
|
142
|
-
access: { reachable: true, canRead: true, canWrite: false },
|
|
143
|
-
}),
|
|
144
|
-
});
|
|
145
|
-
await controller.load();
|
|
146
|
-
expect(controller.isOpen.value).toBe(false);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe("the project's content as this session left it", () => {
|
|
151
|
-
it("opens on Continue, and drops the widget's dot, once a conversation exists that the load did not see", async () => {
|
|
152
|
-
const harness = harnessed({
|
|
153
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
154
|
-
});
|
|
155
|
-
const { controller } = harness;
|
|
156
|
-
await controller.load();
|
|
157
|
-
expect(controller.flow.value.view.kind).toBe("ready");
|
|
158
|
-
expect(controller.needsAttention.value).toBe(true);
|
|
159
|
-
|
|
160
|
-
harness.setContent(CONVERSATION);
|
|
161
|
-
controller.close();
|
|
162
|
-
controller.open();
|
|
163
|
-
await vi.waitFor(() =>
|
|
164
|
-
expect(controller.flow.value.view.kind).toBe("continue"),
|
|
165
|
-
);
|
|
166
|
-
expect(controller.needsAttention.value).toBe(false);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("keeps the view the user already moved on from while the content is read again", async () => {
|
|
170
|
-
const harness = harnessed({
|
|
171
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
172
|
-
});
|
|
173
|
-
const { controller } = harness;
|
|
174
|
-
await controller.load();
|
|
175
|
-
harness.setContent(CONVERSATION);
|
|
176
|
-
controller.close();
|
|
177
|
-
controller.open();
|
|
178
|
-
controller.send({ type: "back" });
|
|
179
|
-
const moved = controller.flow.value;
|
|
180
|
-
await vi.waitFor(() => expect(controller.needsAttention.value).toBe(false));
|
|
181
|
-
expect(controller.flow.value).toBe(moved);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe("a backend that did not answer the first read", () => {
|
|
186
|
-
it("opens on a later open once the backend answers, on the step an earlier open asked for", async () => {
|
|
187
|
-
const harness = harnessed({
|
|
188
|
-
state: onboardingState({ claude: CLAUDE_LOGIN }),
|
|
189
|
-
content: CONVERSATION,
|
|
190
|
-
});
|
|
191
|
-
const { controller, api } = harness;
|
|
192
|
-
const answer = await api.readState();
|
|
193
|
-
api.readState.mockRejectedValueOnce(new Error("503"));
|
|
194
|
-
controller.open("connect-database");
|
|
195
|
-
await controller.load().catch(() => undefined);
|
|
196
|
-
expect(controller.isAvailable.value).toBe(false);
|
|
197
|
-
expect(controller.isOpen.value).toBe(false);
|
|
198
|
-
|
|
199
|
-
api.readState.mockResolvedValue(answer);
|
|
200
|
-
controller.open();
|
|
201
|
-
await vi.waitFor(() => expect(controller.isOpen.value).toBe(true));
|
|
202
|
-
expect(controller.isAvailable.value).toBe(true);
|
|
203
|
-
expect(controller.flow.value.view).toEqual({ kind: "connect-database" });
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("does not read before the first load has been tried", () => {
|
|
207
|
-
const { controller, api } = harnessed({});
|
|
208
|
-
controller.open();
|
|
209
|
-
expect(api.readState).not.toHaveBeenCalled();
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
async function waitingForChatGpt(): Promise<OnboardingHarness> {
|
|
214
|
-
const harness = harnessed({
|
|
215
|
-
state: onboardingState(
|
|
216
|
-
{},
|
|
217
|
-
{ codexLoginUrl: "https://auth.openai.com/authorize?state=1" },
|
|
218
|
-
),
|
|
219
|
-
});
|
|
220
|
-
await harness.controller.load();
|
|
221
|
-
harness.controller.send({ type: "get-started" });
|
|
222
|
-
harness.controller.send({ type: "sign-in", provider: "codex" });
|
|
223
|
-
harness.controller.signInWithChatGpt();
|
|
224
|
-
return harness;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function lateAnswer(api: OnboardingHarness["api"]): { signedIn: () => void } {
|
|
228
|
-
let answer: (state: ReturnType<typeof onboardingState>) => void = () =>
|
|
229
|
-
undefined;
|
|
230
|
-
api.readState.mockImplementation(
|
|
231
|
-
() => new Promise((resolve) => (answer = resolve)),
|
|
232
|
-
);
|
|
233
|
-
return {
|
|
234
|
-
signedIn: () =>
|
|
235
|
-
answer(
|
|
236
|
-
onboardingState({ codex: { status: "signed-in", source: "chatgpt" } }),
|
|
237
|
-
),
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
describe("signing in with ChatGPT", () => {
|
|
242
|
-
it("asks every two seconds whether the sign-in completed, then runs the assistant on Codex", async () => {
|
|
243
|
-
vi.useFakeTimers();
|
|
244
|
-
const signedOut = onboardingState(
|
|
245
|
-
{},
|
|
246
|
-
{ codexLoginUrl: "https://auth.openai.com/authorize?state=1" },
|
|
247
|
-
);
|
|
248
|
-
const harness = harnessed({ state: signedOut });
|
|
249
|
-
const { controller, api } = harness;
|
|
250
|
-
await controller.load();
|
|
251
|
-
controller.send({ type: "get-started" });
|
|
252
|
-
controller.send({ type: "sign-in", provider: "codex" });
|
|
253
|
-
controller.signInWithChatGpt();
|
|
254
|
-
expect(harness.openTab).toHaveBeenCalledWith(
|
|
255
|
-
"https://auth.openai.com/authorize?state=1",
|
|
256
|
-
);
|
|
257
|
-
api.readState.mockClear();
|
|
258
|
-
|
|
259
|
-
await vi.advanceTimersByTimeAsync(CODEX_POLL_MS);
|
|
260
|
-
expect(api.readState).toHaveBeenCalledTimes(1);
|
|
261
|
-
expect(controller.flow.value.view).toEqual({
|
|
262
|
-
kind: "codex",
|
|
263
|
-
mode: "waiting",
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
const codex: ProviderLogin = {
|
|
267
|
-
status: "signed-in",
|
|
268
|
-
source: "chatgpt",
|
|
269
|
-
email: "owner@example.com",
|
|
270
|
-
};
|
|
271
|
-
api.readState.mockResolvedValue(onboardingState({ codex }));
|
|
272
|
-
await vi.advanceTimersByTimeAsync(CODEX_POLL_MS);
|
|
273
|
-
expect(api.setProvider).toHaveBeenCalledWith("codex");
|
|
274
|
-
expect(controller.flow.value.view).toEqual({
|
|
275
|
-
kind: "connected",
|
|
276
|
-
provider: "codex",
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
await vi.advanceTimersByTimeAsync(CODEX_POLL_MS * 3);
|
|
280
|
-
expect(api.readState).toHaveBeenCalledTimes(2);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it("drops a poll answer that arrives after the user went back from the waiting view", async () => {
|
|
284
|
-
vi.useFakeTimers();
|
|
285
|
-
const { controller, api } = await waitingForChatGpt();
|
|
286
|
-
const late = lateAnswer(api);
|
|
287
|
-
await vi.advanceTimersByTimeAsync(CODEX_POLL_MS);
|
|
288
|
-
controller.send({ type: "back" });
|
|
289
|
-
controller.send({ type: "sign-in", provider: "claude" });
|
|
290
|
-
late.signedIn();
|
|
291
|
-
await vi.advanceTimersByTimeAsync(10);
|
|
292
|
-
expect(controller.flow.value.view.kind).toBe("claude");
|
|
293
|
-
expect(api.setProvider).not.toHaveBeenCalled();
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it("drops a poll answer that arrives after the popup was closed", async () => {
|
|
297
|
-
vi.useFakeTimers();
|
|
298
|
-
const { controller, api } = await waitingForChatGpt();
|
|
299
|
-
const late = lateAnswer(api);
|
|
300
|
-
await vi.advanceTimersByTimeAsync(CODEX_POLL_MS);
|
|
301
|
-
controller.close();
|
|
302
|
-
late.signedIn();
|
|
303
|
-
await vi.advanceTimersByTimeAsync(10);
|
|
304
|
-
expect(api.setProvider).not.toHaveBeenCalled();
|
|
305
|
-
expect(controller.state.value?.logins.codex.status).toBe("signed-out");
|
|
306
|
-
});
|
|
307
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
import OnboardingDatabase from "../app/views/onboarding/OnboardingDatabase.vue";
|
|
5
|
-
import views from "../i18n/locales/dms-assistant-views-en-GB.json";
|
|
6
|
-
import {
|
|
7
|
-
createOnboardingHarness,
|
|
8
|
-
ONBOARDING_STUBS,
|
|
9
|
-
} from "./support/onboarding";
|
|
10
|
-
|
|
11
|
-
const builder = vi.hoisted(() => ({
|
|
12
|
-
projectModules: vi.fn<() => Promise<unknown>>(),
|
|
13
|
-
checkConnection: vi.fn<(engine: string, url: string) => Promise<unknown>>(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
vi.mock("../builder/app/runtime/api", () => ({
|
|
17
|
-
useBuilderApi: () => ({
|
|
18
|
-
projectModules: builder.projectModules,
|
|
19
|
-
checkConnection: builder.checkConnection,
|
|
20
|
-
failure: (error: unknown) => ({ detail: String(error) }),
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
const PROJECT = {
|
|
25
|
-
modules: ["dms", "mongodb"],
|
|
26
|
-
self: "dms",
|
|
27
|
-
databasePins: [],
|
|
28
|
-
drivers: {
|
|
29
|
-
postgres: { package: "@antelopejs/postgres", version: ">=0.4.2 <0.5.0" },
|
|
30
|
-
mysql: { package: "@antelopejs/mysql", version: ">=0.2.4 <0.3.0" },
|
|
31
|
-
mongodb: { package: "@antelopejs/mongodb", version: "~1.8.5" },
|
|
32
|
-
rethinkdb: { package: "@antelopejs/rethinkdb", version: "~1.10.4" },
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const REASON = "Install @antelopejs/postgres to connect a PostgreSQL database.";
|
|
37
|
-
const COMMAND =
|
|
38
|
-
'pnpm add --save-prefix=~ "@antelopejs/postgres@>=0.4.2 <0.5.0"';
|
|
39
|
-
const MISSING_DRIVER = {
|
|
40
|
-
reachable: false,
|
|
41
|
-
canRead: false,
|
|
42
|
-
canWrite: false,
|
|
43
|
-
reason: REASON,
|
|
44
|
-
install: { package: "@antelopejs/postgres", command: COMMAND },
|
|
45
|
-
};
|
|
46
|
-
const TEXT = views.dms_assistant.views.onboarding.database;
|
|
47
|
-
|
|
48
|
-
let wrapper: VueWrapper | undefined;
|
|
49
|
-
|
|
50
|
-
async function checked(): Promise<VueWrapper> {
|
|
51
|
-
builder.projectModules.mockResolvedValue(PROJECT);
|
|
52
|
-
const harness = createOnboardingHarness();
|
|
53
|
-
wrapper = mount(OnboardingDatabase, {
|
|
54
|
-
global: { provide: harness.provide, stubs: ONBOARDING_STUBS },
|
|
55
|
-
});
|
|
56
|
-
await flushPromises();
|
|
57
|
-
await wrapper.find("input").setValue("postgres://app@db.example.com/shop");
|
|
58
|
-
await wrapper.find("input").trigger("keydown", { key: "Enter" });
|
|
59
|
-
await flushPromises();
|
|
60
|
-
return wrapper;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function connectButton(picker: VueWrapper): HTMLButtonElement {
|
|
64
|
-
const found = picker
|
|
65
|
-
.findAll<HTMLButtonElement>("button")
|
|
66
|
-
.find((candidate) => candidate.text() === TEXT.connect);
|
|
67
|
-
if (found === undefined) throw new Error("no Connect button");
|
|
68
|
-
return found.element;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
afterEach(() => {
|
|
72
|
-
wrapper?.unmount();
|
|
73
|
-
wrapper = undefined;
|
|
74
|
-
builder.projectModules.mockReset();
|
|
75
|
-
builder.checkConnection.mockReset();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("a check that finds no driver", () => {
|
|
79
|
-
/** Fails on a missing driver shown as an unreachable server, without the install command or the way to retry. */
|
|
80
|
-
it("shows the sentence, the install command and how to retry", async () => {
|
|
81
|
-
builder.checkConnection.mockResolvedValue(MISSING_DRIVER);
|
|
82
|
-
const picker = await checked();
|
|
83
|
-
const reachable = picker.find('[data-check="reachable"]');
|
|
84
|
-
expect(reachable.attributes("data-status")).toBe("failed");
|
|
85
|
-
expect(reachable.text()).toContain(REASON);
|
|
86
|
-
expect(reachable.text()).not.toContain("Server not reachable");
|
|
87
|
-
expect(picker.find("[data-driver-install] code").text()).toBe(COMMAND);
|
|
88
|
-
expect(picker.find("[data-driver-install]").text()).toContain(
|
|
89
|
-
TEXT.install_retry,
|
|
90
|
-
);
|
|
91
|
-
expect(connectButton(picker).disabled).toBe(false);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
/** Fails on a retry that does not run the check again, or keeps the install step once the driver loads. */
|
|
95
|
-
it("runs the check again on Connect and drops the install step once the driver loads", async () => {
|
|
96
|
-
builder.checkConnection.mockResolvedValueOnce(MISSING_DRIVER);
|
|
97
|
-
builder.checkConnection.mockResolvedValueOnce({
|
|
98
|
-
reachable: false,
|
|
99
|
-
canRead: false,
|
|
100
|
-
canWrite: false,
|
|
101
|
-
reason: "Nothing is listening at this host and port.",
|
|
102
|
-
});
|
|
103
|
-
const picker = await checked();
|
|
104
|
-
connectButton(picker).click();
|
|
105
|
-
await flushPromises();
|
|
106
|
-
expect(builder.checkConnection).toHaveBeenCalledTimes(2);
|
|
107
|
-
expect(picker.find("[data-driver-install]").exists()).toBe(false);
|
|
108
|
-
expect(picker.find('[data-check="reachable"]').text()).toContain(
|
|
109
|
-
"Nothing is listening at this host and port.",
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
import OnboardingDatabase from "../app/views/onboarding/OnboardingDatabase.vue";
|
|
5
|
-
import views from "../i18n/locales/dms-assistant-views-en-GB.json";
|
|
6
|
-
import {
|
|
7
|
-
createOnboardingHarness,
|
|
8
|
-
ONBOARDING_STUBS,
|
|
9
|
-
} from "./support/onboarding";
|
|
10
|
-
|
|
11
|
-
const builder = vi.hoisted(() => ({
|
|
12
|
-
projectModules: vi.fn<() => Promise<unknown>>(),
|
|
13
|
-
checkConnection: vi.fn<(engine: string, url: string) => Promise<unknown>>(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
vi.mock("../builder/app/runtime/i18n", async (importOriginal) => ({
|
|
17
|
-
...(await importOriginal<Record<string, unknown>>()),
|
|
18
|
-
t: (key: string, params?: Record<string, unknown>) =>
|
|
19
|
-
params === undefined ? key : `${key} ${JSON.stringify(params)}`,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock("../builder/app/runtime/api", () => ({
|
|
23
|
-
useBuilderApi: () => ({
|
|
24
|
-
projectModules: builder.projectModules,
|
|
25
|
-
checkConnection: builder.checkConnection,
|
|
26
|
-
failure: (error: unknown) => ({ detail: String(error) }),
|
|
27
|
-
}),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
const WITHOUT_MYSQL_DRIVER = {
|
|
31
|
-
modules: ["dms", "mongodb"],
|
|
32
|
-
self: "dms",
|
|
33
|
-
databasePins: [],
|
|
34
|
-
interfaceDatabase: "0.4.0",
|
|
35
|
-
drivers: {
|
|
36
|
-
postgres: { package: "@antelopejs/postgres", version: ">=0.4.0 <0.5.0" },
|
|
37
|
-
mongodb: { package: "@antelopejs/mongodb", version: ">=1.8.0 <1.9.0" },
|
|
38
|
-
rethinkdb: {
|
|
39
|
-
package: "@antelopejs/rethinkdb",
|
|
40
|
-
version: ">=1.10.0 <1.11.0",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
let wrapper: VueWrapper | undefined;
|
|
46
|
-
|
|
47
|
-
async function openPicker(): Promise<VueWrapper> {
|
|
48
|
-
const harness = createOnboardingHarness();
|
|
49
|
-
wrapper = mount(OnboardingDatabase, {
|
|
50
|
-
global: { provide: harness.provide, stubs: ONBOARDING_STUBS },
|
|
51
|
-
});
|
|
52
|
-
await flushPromises();
|
|
53
|
-
return wrapper;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const ENGINE_LABELS = ["PostgreSQL", "MongoDB", "RethinkDB", "MySQL / MariaDB"];
|
|
57
|
-
|
|
58
|
-
function button(picker: VueWrapper, label: string): HTMLButtonElement {
|
|
59
|
-
const found = picker
|
|
60
|
-
.findAll<HTMLButtonElement>("button")
|
|
61
|
-
.find((candidate) => candidate.text() === label);
|
|
62
|
-
if (found === undefined) throw new Error(`no button reads ${label}`);
|
|
63
|
-
return found.element;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function connectButton(picker: VueWrapper): HTMLButtonElement {
|
|
67
|
-
return button(picker, views.dms_assistant.views.onboarding.database.connect);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
afterEach(() => {
|
|
71
|
-
wrapper?.unmount();
|
|
72
|
-
wrapper = undefined;
|
|
73
|
-
builder.projectModules.mockReset();
|
|
74
|
-
builder.checkConnection.mockReset();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("the engine picker", () => {
|
|
78
|
-
/** Fails on a picker that offers an engine the project cannot install a driver for, turns off one it can, or hides why. */
|
|
79
|
-
it("turns off an engine the project has no driver for, and says why", async () => {
|
|
80
|
-
builder.projectModules.mockResolvedValue(WITHOUT_MYSQL_DRIVER);
|
|
81
|
-
const picker = await openPicker();
|
|
82
|
-
expect(
|
|
83
|
-
picker.findAll('[role="radio"]').map((option) => option.text()),
|
|
84
|
-
).toEqual(ENGINE_LABELS);
|
|
85
|
-
expect(button(picker, "MySQL / MariaDB").disabled).toBe(true);
|
|
86
|
-
for (const label of ["PostgreSQL", "MongoDB", "RethinkDB"]) {
|
|
87
|
-
expect(button(picker, label).disabled).toBe(false);
|
|
88
|
-
}
|
|
89
|
-
expect(
|
|
90
|
-
picker.findAll("[data-unavailable]").map((line) => line.text()),
|
|
91
|
-
).toEqual([
|
|
92
|
-
'database.engines.unavailable {"engine":"MySQL / MariaDB","version":"0.4.0"}',
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
/** Fails on a popup that lets a URL of an engine without a driver reach the live check. */
|
|
97
|
-
it("keeps Connect off for a URL of an engine without a driver", async () => {
|
|
98
|
-
builder.projectModules.mockResolvedValue(WITHOUT_MYSQL_DRIVER);
|
|
99
|
-
const picker = await openPicker();
|
|
100
|
-
await picker.find("input").setValue("mysql://app@db.example.com/shop");
|
|
101
|
-
expect(button(picker, "MySQL / MariaDB").getAttribute("aria-checked")).toBe(
|
|
102
|
-
"true",
|
|
103
|
-
);
|
|
104
|
-
expect(connectButton(picker).disabled).toBe(true);
|
|
105
|
-
await picker.find("input").setValue("postgres://app@db.example.com/shop");
|
|
106
|
-
expect(connectButton(picker).disabled).toBe(false);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
/** Fails on an Enter in the URL field that runs the live check of a URL whose engine has no driver, which the turned-off Connect button never runs. */
|
|
110
|
-
it("ignores Enter on a URL of an engine without a driver, as Connect does", async () => {
|
|
111
|
-
builder.projectModules.mockResolvedValue(WITHOUT_MYSQL_DRIVER);
|
|
112
|
-
builder.checkConnection.mockResolvedValue({
|
|
113
|
-
reachable: false,
|
|
114
|
-
canRead: false,
|
|
115
|
-
canWrite: false,
|
|
116
|
-
reason: "Nothing is listening at this host and port.",
|
|
117
|
-
});
|
|
118
|
-
const picker = await openPicker();
|
|
119
|
-
const input = picker.find("input");
|
|
120
|
-
await input.setValue("mysql://app@db.example.com/shop");
|
|
121
|
-
await input.trigger("keydown", { key: "Enter" });
|
|
122
|
-
await flushPromises();
|
|
123
|
-
expect(builder.checkConnection).not.toHaveBeenCalled();
|
|
124
|
-
await input.setValue("postgres://app@db.example.com/shop");
|
|
125
|
-
await input.trigger("keydown", { key: "Enter" });
|
|
126
|
-
await flushPromises();
|
|
127
|
-
expect(builder.checkConnection).toHaveBeenCalledWith(
|
|
128
|
-
"postgres",
|
|
129
|
-
"postgres://app@db.example.com/shop",
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
/** Fails on a picker that turns every engine off when the project cannot be read. */
|
|
134
|
-
it("offers every engine while it cannot read the project", async () => {
|
|
135
|
-
builder.projectModules.mockRejectedValue(new Error("refused"));
|
|
136
|
-
const picker = await openPicker();
|
|
137
|
-
for (const label of ENGINE_LABELS) {
|
|
138
|
-
expect(button(picker, label).disabled).toBe(false);
|
|
139
|
-
}
|
|
140
|
-
expect(picker.findAll("[data-unavailable]")).toHaveLength(0);
|
|
141
|
-
});
|
|
142
|
-
});
|