@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,112 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { draftFromProposal, settledInput } from '../app/runtime/database'
|
|
3
|
-
import type {
|
|
4
|
-
ColumnDisplay,
|
|
5
|
-
MappingProposal,
|
|
6
|
-
ProposedField,
|
|
7
|
-
ProposedResource,
|
|
8
|
-
} from '../app/runtime/database-types'
|
|
9
|
-
|
|
10
|
-
/** A column's display and a relation's tabs travel from the proposal to the call Apply sends. */
|
|
11
|
-
|
|
12
|
-
const STATUS: ColumnDisplay = {
|
|
13
|
-
kind: 'badge',
|
|
14
|
-
items: [
|
|
15
|
-
{ value: 'paid', label: 'Paid', tone: 'success' },
|
|
16
|
-
{ value: 'pending', label: 'Pending', tone: 'warning' },
|
|
17
|
-
],
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function proposed<T>(value: T, rule: string) {
|
|
21
|
-
return { value, rule, kind: 'default' as const }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function field(column: string, declared: string, display?: ColumnDisplay, filterable = true): ProposedField {
|
|
25
|
-
const base: ProposedField = {
|
|
26
|
-
column,
|
|
27
|
-
native: declared,
|
|
28
|
-
accepts: [declared],
|
|
29
|
-
declared: proposed(declared, 'F3'),
|
|
30
|
-
label: proposed(column, 'L2'),
|
|
31
|
-
listable: proposed(true, 'FL'),
|
|
32
|
-
filterable: proposed(filterable, 'FL'),
|
|
33
|
-
sortable: proposed(false, 'FL'),
|
|
34
|
-
searchable: proposed(false, 'FL'),
|
|
35
|
-
}
|
|
36
|
-
if (display) {
|
|
37
|
-
base.display = proposed(display, display.kind === 'badge' ? 'D1' : 'D2')
|
|
38
|
-
}
|
|
39
|
-
return base
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function orders(fields: ProposedField[]): ProposedResource {
|
|
43
|
-
return {
|
|
44
|
-
relation: 'shop.orders',
|
|
45
|
-
tableView: proposed(true, 'R6'),
|
|
46
|
-
writable: proposed(false, 'W1'),
|
|
47
|
-
label: proposed('reference', 'L1'),
|
|
48
|
-
title: proposed('Orders', 'L2'),
|
|
49
|
-
tabs: proposed({ column: 'status' }, 'T1'),
|
|
50
|
-
fields,
|
|
51
|
-
leftOut: [],
|
|
52
|
-
writes: { insert: false, update: false, delete: false },
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function proposalOf(resource: ProposedResource): MappingProposal {
|
|
57
|
-
return {
|
|
58
|
-
connection: 'shop',
|
|
59
|
-
module: 'shop-tables',
|
|
60
|
-
database: { engine: 'postgresql 17', role: 'reader', writes: 'none' },
|
|
61
|
-
resources: [resource],
|
|
62
|
-
excluded: [],
|
|
63
|
-
open: [],
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const FIELDS = [field('status', 'string', STATUS), field('total', 'number', { kind: 'price' }), field('note', 'string')]
|
|
68
|
-
|
|
69
|
-
describe('the display of columns and the tabs of a relation in the draft', () => {
|
|
70
|
-
it('sends the proposed badge, price and tabs to MapResources, and a plain column as plain', () => {
|
|
71
|
-
const proposal = proposalOf(orders(FIELDS))
|
|
72
|
-
const input = settledInput(proposal, draftFromProposal(proposal))
|
|
73
|
-
const [sent] = input.resources
|
|
74
|
-
expect(sent.tabs).toEqual({ column: 'status' })
|
|
75
|
-
expect(sent.fields.map((entry) => [entry.column, entry.display])).toEqual([
|
|
76
|
-
['status', STATUS],
|
|
77
|
-
['total', { kind: 'price' }],
|
|
78
|
-
['note', null],
|
|
79
|
-
])
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('sends no display for a column the draft redeclared, and no tabs over it', () => {
|
|
83
|
-
const proposal = proposalOf(orders(FIELDS))
|
|
84
|
-
const draft = draftFromProposal(proposal)
|
|
85
|
-
draft.resources[0].fields[0].declared = 'number'
|
|
86
|
-
const [sent] = settledInput(proposal, draft).resources
|
|
87
|
-
expect(sent.fields[0].display).toBeNull()
|
|
88
|
-
expect(sent.tabs).toBeNull()
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('sends no tabs over a column left out or not filterable, nor for a relation with no TableView', () => {
|
|
92
|
-
const proposal = proposalOf(orders(FIELDS))
|
|
93
|
-
const left = draftFromProposal(proposal)
|
|
94
|
-
left.resources[0].fields[0].include = false
|
|
95
|
-
expect(settledInput(proposal, left).resources[0].tabs).toBeNull()
|
|
96
|
-
const unfiltered = draftFromProposal(proposal)
|
|
97
|
-
unfiltered.resources[0].fields[0].filterable = false
|
|
98
|
-
expect(settledInput(proposal, unfiltered).resources[0].tabs).toBeNull()
|
|
99
|
-
const stats = draftFromProposal(proposal)
|
|
100
|
-
stats.resources[0].tableView = false
|
|
101
|
-
expect(settledInput(proposal, stats).resources[0].tabs).toBeNull()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('turns a display off when the draft sets it to null', () => {
|
|
105
|
-
const proposal = proposalOf(orders(FIELDS))
|
|
106
|
-
const draft = draftFromProposal(proposal)
|
|
107
|
-
draft.resources[0].fields[0].display = null
|
|
108
|
-
const [sent] = settledInput(proposal, draft).resources
|
|
109
|
-
expect(sent.fields[0].display).toBeNull()
|
|
110
|
-
expect(sent.tabs).toBeNull()
|
|
111
|
-
})
|
|
112
|
-
})
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { draftFromProposal, includeResource, settledInput } from '../app/runtime/database'
|
|
3
|
-
import type { MappingProposal, ProposedField, ProposedResource } from '../app/runtime/database-types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The builder's decision code over a mapping proposal: the draft the
|
|
7
|
-
* integrator edits, and the one `MapResources` call Apply sends.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
function proposed<T>(value: T, rule = 'R6') {
|
|
11
|
-
return { value, rule, kind: 'default' as const }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function field(column: string, relation?: string): ProposedField {
|
|
15
|
-
const base: ProposedField = {
|
|
16
|
-
column,
|
|
17
|
-
native: 'text',
|
|
18
|
-
accepts: ['string'],
|
|
19
|
-
declared: proposed('string', 'F3'),
|
|
20
|
-
label: proposed(column, 'L2'),
|
|
21
|
-
listable: proposed(true, 'FL'),
|
|
22
|
-
filterable: proposed(false, 'FL'),
|
|
23
|
-
sortable: proposed(false, 'FL'),
|
|
24
|
-
searchable: proposed(false, 'FL'),
|
|
25
|
-
}
|
|
26
|
-
if (relation) {
|
|
27
|
-
base.relation = { ...proposed(relation, 'F4'), implied: false }
|
|
28
|
-
}
|
|
29
|
-
return base
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function resource(relation: string, fields: ProposedField[], label: string | null): ProposedResource {
|
|
33
|
-
return {
|
|
34
|
-
relation,
|
|
35
|
-
tableView: proposed(true),
|
|
36
|
-
writable: proposed(false, 'W1'),
|
|
37
|
-
label: proposed(label, 'L1'),
|
|
38
|
-
title: proposed(relation.split('.')[1], 'L2'),
|
|
39
|
-
fields,
|
|
40
|
-
leftOut: [],
|
|
41
|
-
writes: { insert: false, update: false, delete: false },
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const PROPOSAL: MappingProposal = {
|
|
46
|
-
connection: 'erp',
|
|
47
|
-
module: 'erp-tables',
|
|
48
|
-
database: { engine: 'postgresql 17.5', role: 'erp_reader', writes: 'none' },
|
|
49
|
-
resources: [
|
|
50
|
-
resource('erp.customers', [field('code'), field('name')], 'name'),
|
|
51
|
-
resource('erp.orders', [field('id'), field('customer_code', 'erp.customers')], 'id'),
|
|
52
|
-
],
|
|
53
|
-
excluded: [{ relation: 'erp.schema_migrations', reason: 'a migration tool', rule: 'R4' }],
|
|
54
|
-
open: [
|
|
55
|
-
{
|
|
56
|
-
id: 'purpose:legacy.t_cst',
|
|
57
|
-
kind: 'purpose',
|
|
58
|
-
relation: 'legacy.t_cst',
|
|
59
|
-
question: 'What does legacy.t_cst hold?',
|
|
60
|
-
options: [],
|
|
61
|
-
proposed: null,
|
|
62
|
-
resource: resource('legacy.t_cst', [field('id'), field('c01')], 'id'),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: 'label:erp.orders',
|
|
66
|
-
kind: 'label',
|
|
67
|
-
relation: 'erp.orders',
|
|
68
|
-
question: 'Which column names an order?',
|
|
69
|
-
options: [],
|
|
70
|
-
proposed: 'id',
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
describe('a mapping draft', () => {
|
|
76
|
-
it('starts as the proposal: proposed relations in, a relation asked about out', () => {
|
|
77
|
-
const draft = draftFromProposal(PROPOSAL)
|
|
78
|
-
expect(draft.resources.map((entry) => [entry.relation, entry.include])).toEqual([
|
|
79
|
-
['erp.customers', true],
|
|
80
|
-
['erp.orders', true],
|
|
81
|
-
['legacy.t_cst', false],
|
|
82
|
-
])
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('sends the proposal as it stands, with the analysis exclusions recorded', () => {
|
|
86
|
-
const input = settledInput(PROPOSAL, draftFromProposal(PROPOSAL))
|
|
87
|
-
expect(input.resources.map((entry) => entry.relation)).toEqual(['erp.customers', 'erp.orders'])
|
|
88
|
-
expect(input.excluded).toEqual([{ relation: 'erp.schema_migrations', reason: 'a migration tool' }])
|
|
89
|
-
const orders = input.resources[1]
|
|
90
|
-
expect(orders.fields[1]).toEqual({
|
|
91
|
-
column: 'customer_code',
|
|
92
|
-
label: 'customer_code',
|
|
93
|
-
listable: true,
|
|
94
|
-
filterable: false,
|
|
95
|
-
sortable: false,
|
|
96
|
-
searchable: false,
|
|
97
|
-
relation: 'erp.customers',
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('maps a relation checked in, and records one checked out as decided against', () => {
|
|
102
|
-
const draft = draftFromProposal(PROPOSAL)
|
|
103
|
-
includeResource(draft, 'legacy.t_cst', true)
|
|
104
|
-
expect(settledInput(PROPOSAL, draft).resources.map((entry) => entry.relation)).toContain('legacy.t_cst')
|
|
105
|
-
includeResource(draft, 'erp.orders', false)
|
|
106
|
-
const input = settledInput(PROPOSAL, draft)
|
|
107
|
-
expect(input.resources.map((entry) => entry.relation)).not.toContain('erp.orders')
|
|
108
|
-
expect(input.excluded).toContainEqual({ relation: 'erp.orders', reason: 'decided against in the builder' })
|
|
109
|
-
includeResource(draft, 'erp.orders', true)
|
|
110
|
-
expect(settledInput(PROPOSAL, draft).excluded).not.toContainEqual(
|
|
111
|
-
expect.objectContaining({ relation: 'erp.orders' }),
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
it('keeps a relation column onto a TableView the module maps already, and drops one onto anything else', () => {
|
|
116
|
-
const invoices = resource('erp.invoices', [field('id'), field('order_ref', 'erp.archive')], 'id')
|
|
117
|
-
const proposal: MappingProposal = { ...PROPOSAL, resources: [invoices] }
|
|
118
|
-
const draft = draftFromProposal(proposal)
|
|
119
|
-
const dropped = settledInput(proposal, draft).resources[0]
|
|
120
|
-
expect(dropped.fields[1].relation).toBeUndefined()
|
|
121
|
-
const kept = settledInput(proposal, draft, new Set(['erp.archive'])).resources[0]
|
|
122
|
-
expect(kept.fields[1].relation).toBe('erp.archive')
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('sends no title for one emptied, so the page keeps its default', () => {
|
|
126
|
-
const draft = draftFromProposal(PROPOSAL)
|
|
127
|
-
draft.resources[0].title = ' '
|
|
128
|
-
expect(settledInput(PROPOSAL, draft).resources[0]).not.toHaveProperty('title')
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it('drops a relation column whose target is no longer a TableView of the mapping', () => {
|
|
132
|
-
const draft = draftFromProposal(PROPOSAL)
|
|
133
|
-
includeResource(draft, 'erp.customers', false)
|
|
134
|
-
const orders = settledInput(PROPOSAL, draft).resources.find((entry) => entry.relation === 'erp.orders')
|
|
135
|
-
expect(orders?.fields[1].relation).toBeUndefined()
|
|
136
|
-
expect(orders?.fields[1].declared).toBe('string')
|
|
137
|
-
})
|
|
138
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { isBuilderEnabled } from '../app/runtime/enabled'
|
|
3
|
-
|
|
4
|
-
describe('whether the backend turned the builder on', () => {
|
|
5
|
-
it('is on only for an explicit true under the builder key', () => {
|
|
6
|
-
expect(isBuilderEnabled({ dmsBuilder: { enabled: true } })).toBe(true)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it('is off for anything else the registration could carry', () => {
|
|
10
|
-
expect(isBuilderEnabled(undefined)).toBe(false)
|
|
11
|
-
expect(isBuilderEnabled({})).toBe(false)
|
|
12
|
-
expect(isBuilderEnabled({ dmsBuilder: null })).toBe(false)
|
|
13
|
-
expect(isBuilderEnabled({ dmsBuilder: { enabled: 'true' } })).toBe(false)
|
|
14
|
-
expect(isBuilderEnabled({ dmsBuilder: { enabled: 1 } })).toBe(false)
|
|
15
|
-
expect(isBuilderEnabled({ enabled: true })).toBe(false)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import { useBuilderApi } from '../app/runtime/api'
|
|
3
|
-
|
|
4
|
-
afterEach(() => vi.unstubAllGlobals())
|
|
5
|
-
|
|
6
|
-
function recordingApi() {
|
|
7
|
-
const calls: { path: string; options: { method?: string; headers?: Record<string, string> } }[] = []
|
|
8
|
-
vi.stubGlobal('useApiErrorPresenter', () => ({ presentError: () => undefined, resolveError: () => undefined }))
|
|
9
|
-
vi.stubGlobal('useAuthFetch', () => ({
|
|
10
|
-
$authFetch: async (path: string, options: { method?: string; headers?: Record<string, string> }) => {
|
|
11
|
-
calls.push({ path, options })
|
|
12
|
-
return { ok: true, data: {}, changes: [] }
|
|
13
|
-
},
|
|
14
|
-
}))
|
|
15
|
-
return { api: useBuilderApi(), calls }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe('the builder client', () => {
|
|
19
|
-
/** Fails on a client that sends a URL-taking request without the header the module requires, which the module would refuse. */
|
|
20
|
-
it('sends the assistant UI header on the connection check and on a builder POST', async () => {
|
|
21
|
-
const { api, calls } = recordingApi()
|
|
22
|
-
await api.checkConnection('postgres', 'postgres://u:p@h/db')
|
|
23
|
-
await api.analyseDatabase('erp', 'erp')
|
|
24
|
-
expect(calls.map((call) => [call.path, call.options.method, call.options.headers?.['x-dms-ui-assistant']])).toEqual([
|
|
25
|
-
['/api/builder/database/connections/check', 'POST', '1'],
|
|
26
|
-
['/api/builder/database/analyse', 'POST', '1'],
|
|
27
|
-
])
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stand-in for the host runtime the DMS frontend loader materializes as
|
|
3
|
-
* `#dms/frontend-module`. Only what this package imports from the host is
|
|
4
|
-
* declared.
|
|
5
|
-
*/
|
|
6
|
-
import englishMessages from '../../../i18n/locales/builder-en-GB.json'
|
|
7
|
-
import frenchMessages from '../../../i18n/locales/builder-fr-FR.json'
|
|
8
|
-
|
|
9
|
-
type Messages = { [key: string]: string | Messages }
|
|
10
|
-
|
|
11
|
-
function lookup(messages: Messages, path: string): string | undefined {
|
|
12
|
-
let node: string | Messages | undefined = messages
|
|
13
|
-
for (const part of path.split('.')) {
|
|
14
|
-
node = typeof node === 'object' ? node[part] : undefined
|
|
15
|
-
}
|
|
16
|
-
return typeof node === 'string' ? node : undefined
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** vue-i18n's default choice: `zero | one | many`, or `one | many`. */
|
|
20
|
-
function pluralForm(message: string, count: number | undefined): string {
|
|
21
|
-
const forms = message.split(' | ')
|
|
22
|
-
if (count === undefined || forms.length === 1) {
|
|
23
|
-
return message
|
|
24
|
-
}
|
|
25
|
-
const index =
|
|
26
|
-
forms.length === 2 ? (count === 1 ? 0 : 1) : Math.min(Math.abs(count), 2)
|
|
27
|
-
return forms[index] ?? message
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type TestLocale = 'en-GB' | 'fr-FR'
|
|
31
|
-
|
|
32
|
-
let locale: TestLocale = 'en-GB'
|
|
33
|
-
|
|
34
|
-
/** Switches the locale `translate` reads; a test restores `en-GB` when it is done. */
|
|
35
|
-
export function setTestLocale(next: TestLocale): void {
|
|
36
|
-
locale = next
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The application composer, reading the module's catalog in the test locale,
|
|
41
|
-
* English unless a test switches it: a test asserts the texts an
|
|
42
|
-
* English-speaking author sees, and a key the catalog lacks comes back as
|
|
43
|
-
* itself, as vue-i18n returns it.
|
|
44
|
-
*/
|
|
45
|
-
function translate(
|
|
46
|
-
key: string,
|
|
47
|
-
params: Record<string, unknown> = {},
|
|
48
|
-
count?: number,
|
|
49
|
-
): string {
|
|
50
|
-
const message =
|
|
51
|
-
lookup((locale === 'fr-FR' ? frenchMessages : englishMessages) as Messages, key) ??
|
|
52
|
-
lookup(englishMessages as Messages, key)
|
|
53
|
-
if (message === undefined) {
|
|
54
|
-
return key
|
|
55
|
-
}
|
|
56
|
-
return pluralForm(message, count).replace(/\{(\w+)\}/g, (match, name: string) =>
|
|
57
|
-
name in params ? String(params[name]) : match,
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function useDmsApp(): { $i18n: { t: typeof translate } } {
|
|
62
|
-
return { $i18n: { t: translate } }
|
|
63
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url'
|
|
2
|
-
import { defineConfig } from 'vitest/config'
|
|
3
|
-
import { backendBoundary } from '../build/backend-boundary.ts'
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
root: fileURLToPath(new URL('.', import.meta.url)),
|
|
7
|
-
plugins: [backendBoundary()],
|
|
8
|
-
resolve: {
|
|
9
|
-
alias: {
|
|
10
|
-
// The host runtime only exists inside a generated Inertia workspace; the
|
|
11
|
-
// tests substitute the slice of it this package imports.
|
|
12
|
-
'#dms/frontend-module': fileURLToPath(
|
|
13
|
-
new URL('./tests/stubs/frontend-module.ts', import.meta.url),
|
|
14
|
-
),
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
test: {
|
|
18
|
-
environment: 'node',
|
|
19
|
-
include: ['tests/**/*.test.ts'],
|
|
20
|
-
},
|
|
21
|
-
})
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { flushPromises } from "@vue/test-utils";
|
|
3
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
4
|
-
import { shallowRef } from "vue";
|
|
5
|
-
import { publicAssistantActions } from "../app/runtime/assistant-actions";
|
|
6
|
-
import {
|
|
7
|
-
createHarness,
|
|
8
|
-
openPanel,
|
|
9
|
-
sentOfType,
|
|
10
|
-
unmountPanel,
|
|
11
|
-
} from "./support/panel-harness";
|
|
12
|
-
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
unmountPanel();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const PROMPT =
|
|
18
|
-
"Use dms-external-database on connection roaster, module builder-db-roaster-tables.";
|
|
19
|
-
|
|
20
|
-
describe("the assistant actions another module's layer injects", () => {
|
|
21
|
-
it("start a new conversation with the composer prefilled and nothing sent", async () => {
|
|
22
|
-
const harness = createHarness();
|
|
23
|
-
const panel = await openPanel(harness);
|
|
24
|
-
const actions = publicAssistantActions(shallowRef(harness.session));
|
|
25
|
-
expect(actions.isAvailable).toBe(true);
|
|
26
|
-
actions.startConversation(PROMPT);
|
|
27
|
-
await flushPromises();
|
|
28
|
-
expect((panel.find("textarea").element as HTMLTextAreaElement).value).toBe(
|
|
29
|
-
PROMPT,
|
|
30
|
-
);
|
|
31
|
-
expect(sentOfType(harness, "user_message")).toEqual([]);
|
|
32
|
-
expect(sentOfType(harness, "set_conversation_mode")).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("set the new conversation to plan mode before prefilling it, when asked", async () => {
|
|
36
|
-
const harness = createHarness();
|
|
37
|
-
const panel = await openPanel(harness);
|
|
38
|
-
const actions = publicAssistantActions(shallowRef(harness.session));
|
|
39
|
-
actions.startConversation(PROMPT, { mode: "plan" });
|
|
40
|
-
await flushPromises();
|
|
41
|
-
const started = sentOfType(harness, "hello").at(-1)?.conversationId;
|
|
42
|
-
expect(sentOfType(harness, "set_conversation_mode")).toEqual([
|
|
43
|
-
expect.objectContaining({ conversationId: started, mode: "plan" }),
|
|
44
|
-
]);
|
|
45
|
-
expect((panel.find("textarea").element as HTMLTextAreaElement).value).toBe(
|
|
46
|
-
PROMPT,
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("set plan mode once the stream is up, when the panel opens before it", async () => {
|
|
51
|
-
const harness = createHarness();
|
|
52
|
-
await openPanel(harness);
|
|
53
|
-
harness.setChannelStatus("disconnected");
|
|
54
|
-
publicAssistantActions(shallowRef(harness.session)).startConversation(
|
|
55
|
-
PROMPT,
|
|
56
|
-
{ mode: "plan" },
|
|
57
|
-
);
|
|
58
|
-
await flushPromises();
|
|
59
|
-
expect(sentOfType(harness, "set_conversation_mode")).toEqual([]);
|
|
60
|
-
harness.setChannelStatus("connected");
|
|
61
|
-
await flushPromises();
|
|
62
|
-
expect(sentOfType(harness, "set_conversation_mode")).toEqual([
|
|
63
|
-
expect.objectContaining({ mode: "plan" }),
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("send the prompt as the first message, in plan mode, when asked to", async () => {
|
|
68
|
-
const harness = createHarness();
|
|
69
|
-
const panel = await openPanel(harness);
|
|
70
|
-
publicAssistantActions(shallowRef(harness.session)).startConversation(
|
|
71
|
-
PROMPT,
|
|
72
|
-
{ mode: "plan", send: true },
|
|
73
|
-
);
|
|
74
|
-
await flushPromises();
|
|
75
|
-
const started = sentOfType(harness, "hello").at(-1)?.conversationId;
|
|
76
|
-
expect(sentOfType(harness, "set_conversation_mode")).toEqual([
|
|
77
|
-
expect.objectContaining({ conversationId: started, mode: "plan" }),
|
|
78
|
-
]);
|
|
79
|
-
expect(sentOfType(harness, "user_message")).toEqual([
|
|
80
|
-
expect.objectContaining({ content: PROMPT }),
|
|
81
|
-
]);
|
|
82
|
-
expect((panel.find("textarea").element as HTMLTextAreaElement).value).toBe(
|
|
83
|
-
"",
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("send the prompt once the stream is up, when the panel opens before it", async () => {
|
|
88
|
-
const harness = createHarness();
|
|
89
|
-
await openPanel(harness);
|
|
90
|
-
harness.setChannelStatus("disconnected");
|
|
91
|
-
publicAssistantActions(shallowRef(harness.session)).startConversation(
|
|
92
|
-
PROMPT,
|
|
93
|
-
{ send: true },
|
|
94
|
-
);
|
|
95
|
-
await flushPromises();
|
|
96
|
-
expect(sentOfType(harness, "user_message")).toEqual([]);
|
|
97
|
-
harness.setChannelStatus("connected");
|
|
98
|
-
await flushPromises();
|
|
99
|
-
expect(sentOfType(harness, "user_message")).toEqual([
|
|
100
|
-
expect.objectContaining({ content: PROMPT }),
|
|
101
|
-
]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("are unavailable without a session, and starting then does nothing", () => {
|
|
105
|
-
const actions = publicAssistantActions(shallowRef(null));
|
|
106
|
-
expect(actions.isAvailable).toBe(false);
|
|
107
|
-
expect(() => actions.startConversation(PROMPT)).not.toThrow();
|
|
108
|
-
});
|
|
109
|
-
});
|