@antelopejs/dms-database 0.4.4 → 0.5.1
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/README.md +12 -10
- package/dist/automation/tableWatch.d.ts +2 -2
- package/dist/automation/tableWatch.js +3 -3
- package/dist/automation/tableWatch.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/connectionAccess.d.ts +3 -0
- package/dist/connectionAccess.js +20 -0
- package/dist/connectionAccess.js.map +1 -0
- package/dist/db/models/connection_selections.model.d.ts +27 -0
- package/dist/db/models/connection_selections.model.js +17 -0
- package/dist/db/models/connection_selections.model.js.map +1 -0
- package/dist/db/models/diagram_layouts.model.d.ts +4 -4
- package/dist/db/models/diagram_layouts.model.js +14 -12
- package/dist/db/models/diagram_layouts.model.js.map +1 -1
- package/dist/db/models/diagram_notes.model.d.ts +3 -3
- package/dist/db/models/index.d.ts +1 -0
- package/dist/db/models/index.js +1 -0
- package/dist/db/models/index.js.map +1 -1
- package/dist/db/models/query_history.model.d.ts +3 -3
- package/dist/db/models/saved_queries.model.d.ts +3 -3
- package/dist/db/tables/connection_selections.table.d.ts +6 -0
- package/dist/db/tables/connection_selections.table.js +30 -0
- package/dist/db/tables/connection_selections.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +1 -0
- package/dist/db/tables/index.js +1 -0
- package/dist/db/tables/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/externalLock.d.ts +8 -0
- package/dist/pages/externalLock.js +32 -0
- package/dist/pages/externalLock.js.map +1 -0
- package/dist/pages/overview.js +6 -3
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/schemas.js +6 -2
- package/dist/pages/schemas.js.map +1 -1
- package/dist/routes/connections.d.ts +14 -0
- package/dist/routes/connections.js +121 -0
- package/dist/routes/connections.js.map +1 -0
- package/dist/routes/data.d.ts +10 -9
- package/dist/routes/data.js +45 -61
- package/dist/routes/data.js.map +1 -1
- package/dist/routes/diagram.d.ts +6 -6
- package/dist/routes/diagram.js +16 -6
- package/dist/routes/diagram.js.map +1 -1
- package/dist/routes/health.d.ts +1 -1
- package/dist/routes/health.js +3 -2
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/overview.d.ts +2 -2
- package/dist/routes/overview.js +11 -4
- package/dist/routes/overview.js.map +1 -1
- package/dist/routes/query.d.ts +1 -1
- package/dist/routes/query.js +26 -10
- package/dist/routes/query.js.map +1 -1
- package/dist/routes/schemas.d.ts +1 -1
- package/dist/routes/schemas.js +4 -2
- package/dist/routes/schemas.js.map +1 -1
- package/dist/routes/tables.d.ts +2 -1
- package/dist/routes/tables.js +29 -21
- package/dist/routes/tables.js.map +1 -1
- package/dist/service/browse.d.ts +14 -6
- package/dist/service/browse.js +120 -18
- package/dist/service/browse.js.map +1 -1
- package/dist/service/builderRefusal.d.ts +2 -0
- package/dist/service/builderRefusal.js +28 -0
- package/dist/service/builderRefusal.js.map +1 -0
- package/dist/service/catalog.js +2 -1
- package/dist/service/catalog.js.map +1 -1
- package/dist/service/connectionRefusals.d.ts +17 -0
- package/dist/service/connectionRefusals.js +26 -0
- package/dist/service/connectionRefusals.js.map +1 -0
- package/dist/service/connectionState.d.ts +27 -0
- package/dist/service/connectionState.js +167 -0
- package/dist/service/connectionState.js.map +1 -0
- package/dist/service/connections.d.ts +12 -0
- package/dist/service/connections.js +73 -0
- package/dist/service/connections.js.map +1 -0
- package/dist/service/database.d.ts +12 -0
- package/dist/service/database.js +30 -0
- package/dist/service/database.js.map +1 -0
- package/dist/service/declaredFields.d.ts +3 -2
- package/dist/service/declaredFields.js +6 -7
- package/dist/service/declaredFields.js.map +1 -1
- package/dist/service/health.d.ts +2 -1
- package/dist/service/health.js +48 -21
- package/dist/service/health.js.map +1 -1
- package/dist/service/introspect.d.ts +7 -5
- package/dist/service/introspect.js +49 -41
- package/dist/service/introspect.js.map +1 -1
- package/dist/service/overview.d.ts +3 -2
- package/dist/service/overview.js +4 -4
- package/dist/service/overview.js.map +1 -1
- package/dist/service/queryInspection.js +6 -3
- package/dist/service/queryInspection.js.map +1 -1
- package/dist/service/references.d.ts +3 -2
- package/dist/service/references.js +9 -8
- package/dist/service/references.js.map +1 -1
- package/dist/service/rowEdit.d.ts +3 -0
- package/dist/service/rowEdit.js +36 -3
- package/dist/service/rowEdit.js.map +1 -1
- package/dist/service/types.d.ts +1 -1
- package/dist/utils/deadline.d.ts +2 -0
- package/dist/utils/deadline.js +18 -0
- package/dist/utils/deadline.js.map +1 -0
- package/dist/utils/guards.d.ts +2 -0
- package/dist/utils/guards.js +8 -0
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/query.js +5 -4
- package/dist/utils/query.js.map +1 -1
- package/frontend-vue/app/build/components/DataBrowserAccessBar.vue +88 -0
- package/frontend-vue/app/build/components/DataGridFooter.vue +16 -1
- package/frontend-vue/app/build/components/DataGridToolbar.vue +10 -5
- package/frontend-vue/app/build/components/FeatureLocked.vue +16 -0
- package/frontend-vue/app/build/components/QueryConsoleBoard.vue +601 -0
- package/frontend-vue/app/build/components/SchemaDiagramBoard.vue +691 -0
- package/frontend-vue/app/build/composables/registerDatabaseSwitcher.ts +16 -0
- package/frontend-vue/app/build/composables/reloadForSelection.ts +11 -0
- package/frontend-vue/app/build/composables/useDataBrowserGrid.ts +1 -0
- package/frontend-vue/app/build/composables/useDataBrowserTabs.ts +100 -15
- package/frontend-vue/app/build/composables/useDatabaseConnections.ts +164 -0
- package/frontend-vue/app/build/composables/useGridAccess.ts +25 -0
- package/frontend-vue/app/build/composables/useLockedPages.ts +53 -0
- package/frontend-vue/app/build/composables/useQueryRuntime.ts +4 -4
- package/frontend-vue/app/build/composables/useSelectionRecheck.ts +23 -0
- package/frontend-vue/app/build/data/assistantOnboarding.ts +12 -0
- package/frontend-vue/app/build/data/gridData.ts +22 -1
- package/frontend-vue/app/build/data/readOnlyReason.ts +30 -0
- package/frontend-vue/app/build/data/recentTables.ts +15 -8
- package/frontend-vue/app/build/data/useStagedSave.ts +7 -1
- package/frontend-vue/app/components/DataBrowser.vue +17 -14
- package/frontend-vue/app/components/DataBrowserSidebar.vue +24 -13
- package/frontend-vue/app/components/DataGrid.vue +22 -18
- package/frontend-vue/app/components/DataGridCell.vue +5 -2
- package/frontend-vue/app/components/DatabaseSwitcher.vue +101 -0
- package/frontend-vue/app/components/QueryBuilderPanel.vue +4 -4
- package/frontend-vue/app/components/QueryConsole.vue +11 -592
- package/frontend-vue/app/components/QueryLibrary.vue +3 -3
- package/frontend-vue/app/components/QueryResultPanel.vue +5 -5
- package/frontend-vue/app/components/RowDrawer.vue +21 -14
- package/frontend-vue/app/components/SchemaDiagram.vue +10 -683
- package/frontend-vue/app/components/SchemasFilterBar.vue +3 -0
- package/frontend-vue/app/components/TableInspector.vue +19 -10
- package/frontend-vue/build/backend-boundary.ts +8 -3
- package/frontend-vue/dms.frontend.ts +2 -0
- package/frontend-vue/eslint.config.mjs +0 -1
- package/frontend-vue/i18n/locales/database-en-GB.json +43 -1
- package/frontend-vue/i18n/locales/database-fr-FR.json +43 -1
- package/frontend-vue/package.json +3 -3
- package/frontend-vue/pnpm-lock.yaml +14 -11
- package/frontend-vue/tests/accessBar.test.ts +196 -0
- package/frontend-vue/tests/backend-boundary.test.ts +15 -7
- package/frontend-vue/tests/dataBrowserDatabase.test.ts +89 -0
- package/frontend-vue/tests/databaseSwitcher.test.ts +343 -0
- package/frontend-vue/tests/editRequest.test.ts +95 -0
- package/frontend-vue/tests/externalBrowser.test.ts +318 -0
- package/frontend-vue/tests/fixtures/connections.ts +73 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +135 -12
- package/frontend-vue/tests/lockedPages.test.ts +68 -0
- package/frontend-vue/tests/onDemandReads.test.ts +1 -1
- package/frontend-vue/tests/persistence.test.ts +254 -4
- package/frontend-vue/tests/recentTables.test.ts +70 -0
- package/frontend-vue/tests/registration.test.ts +15 -1
- package/frontend-vue/tests/serverRender.test.ts +80 -4
- package/frontend-vue/vitest.config.ts +11 -1
- package/package.json +19 -15
- package/dist/service/schemaRegistry.d.ts +0 -2
- package/dist/service/schemaRegistry.js +0 -8
- package/dist/service/schemaRegistry.js.map +0 -1
|
@@ -139,7 +139,7 @@ describe('server render: what only the browser reads', () => {
|
|
|
139
139
|
expect(row('status')).toContain('layout="form"')
|
|
140
140
|
expect(row('description')).toContain('layout="stack"')
|
|
141
141
|
expect(row('address')).toContain('layout="stack"')
|
|
142
|
-
expect(page.html.match(/data-stub="
|
|
142
|
+
expect(page.html.match(/data-stub="DmsInputTextarea"/g)).toHaveLength(2)
|
|
143
143
|
// Every editable field, the switch too, keeps the same end slot.
|
|
144
144
|
expect(page.html.match(/data-null-slot/g)).toHaveLength(4)
|
|
145
145
|
expect(page.html.match(/icon="i-ph-circle-dashed"/g)).toHaveLength(4)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { computed, reactive, ref } from 'vue'
|
|
3
3
|
import { useDataBrowserTabs } from '../app/build/composables/useDataBrowserTabs'
|
|
4
|
+
import { useStagedEdits } from '../app/build/data/stagedEdits'
|
|
4
5
|
|
|
5
6
|
afterEach(() => vi.unstubAllGlobals())
|
|
6
7
|
|
|
@@ -21,6 +22,7 @@ it('restores browser session tabs and persists a new permanent tab', () => {
|
|
|
21
22
|
sessionStorage: {
|
|
22
23
|
getItem: () =>
|
|
23
24
|
JSON.stringify({
|
|
25
|
+
database: 'own',
|
|
24
26
|
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
25
27
|
activeId: null,
|
|
26
28
|
}),
|
|
@@ -28,7 +30,7 @@ it('restores browser session tabs and persists a new permanent tab', () => {
|
|
|
28
30
|
},
|
|
29
31
|
})
|
|
30
32
|
const browser = useDataBrowserTabs()
|
|
31
|
-
browser.restore()
|
|
33
|
+
browser.restore('own')
|
|
32
34
|
expect(browser.activeId.value).toBe('sales::eu::orders')
|
|
33
35
|
browser.openTab('audit', 'us', 'events', false)
|
|
34
36
|
expect(browser.tabs.value.map((tab) => tab.id)).toEqual([
|
|
@@ -40,6 +42,253 @@ it('restores browser session tabs and persists a new permanent tab', () => {
|
|
|
40
42
|
expect(JSON.parse(payload).activeId).toBe('audit::us::events')
|
|
41
43
|
})
|
|
42
44
|
|
|
45
|
+
it('drops the tabs kept on another database', () => {
|
|
46
|
+
setup()
|
|
47
|
+
const setItem = vi.fn()
|
|
48
|
+
vi.stubGlobal('window', {
|
|
49
|
+
sessionStorage: {
|
|
50
|
+
getItem: () =>
|
|
51
|
+
JSON.stringify({
|
|
52
|
+
database: 'warehouse',
|
|
53
|
+
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
54
|
+
activeId: 'sales::eu::orders',
|
|
55
|
+
}),
|
|
56
|
+
setItem,
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
const browser = useDataBrowserTabs()
|
|
60
|
+
browser.restore('own')
|
|
61
|
+
expect(browser.tabs.value).toEqual([])
|
|
62
|
+
expect(browser.activeId.value).toBeNull()
|
|
63
|
+
browser.openTab('audit', 'us', 'events', false)
|
|
64
|
+
expect(JSON.parse(setItem.mock.lastCall![1])).toMatchObject({
|
|
65
|
+
database: 'own',
|
|
66
|
+
tabs: [expect.objectContaining({ id: 'audit::us::events' })],
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
function storing(saved: object) {
|
|
71
|
+
let raw = JSON.stringify(saved)
|
|
72
|
+
vi.stubGlobal('window', {
|
|
73
|
+
sessionStorage: {
|
|
74
|
+
getItem: () => raw,
|
|
75
|
+
setItem: (_key: string, value: string) => {
|
|
76
|
+
raw = value
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
it('drops a tab set saved with no database', () => {
|
|
83
|
+
setup()
|
|
84
|
+
storing({
|
|
85
|
+
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
86
|
+
activeId: null,
|
|
87
|
+
})
|
|
88
|
+
const browser = useDataBrowserTabs()
|
|
89
|
+
browser.restore('own')
|
|
90
|
+
expect(browser.tabs.value).toEqual([])
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('drops the open tabs of another database when the page comes back to it without a reload', () => {
|
|
94
|
+
setup()
|
|
95
|
+
const states = new Map<string, unknown>()
|
|
96
|
+
vi.stubGlobal('useDmsState', (key: string, init: () => unknown) => {
|
|
97
|
+
if (!states.has(key)) states.set(key, ref(init()))
|
|
98
|
+
return states.get(key)
|
|
99
|
+
})
|
|
100
|
+
storing({ database: 'own', tabs: [], activeId: null })
|
|
101
|
+
const before = useDataBrowserTabs()
|
|
102
|
+
before.restore('own')
|
|
103
|
+
before.openTab('shop', 'eu', 'orders', false)
|
|
104
|
+
const after = useDataBrowserTabs()
|
|
105
|
+
after.restore('warehouse')
|
|
106
|
+
expect(after.tabs.value).toEqual([])
|
|
107
|
+
after.openTab('audit', 'us', 'events', false)
|
|
108
|
+
expect(after.tabs.value.map((tab) => tab.id)).toEqual(['audit::us::events'])
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('discards the staged edits of the open tabs it drops', () => {
|
|
112
|
+
setup()
|
|
113
|
+
const states = new Map<string, unknown>()
|
|
114
|
+
vi.stubGlobal('useDmsState', (key: string, init: () => unknown) => {
|
|
115
|
+
if (!states.has(key)) states.set(key, ref(init()))
|
|
116
|
+
return states.get(key)
|
|
117
|
+
})
|
|
118
|
+
storing({ database: 'own', tabs: [], activeId: null })
|
|
119
|
+
const before = useDataBrowserTabs()
|
|
120
|
+
before.restore('own')
|
|
121
|
+
before.openTab('shop', 'eu', 'orders', false)
|
|
122
|
+
useStagedEdits().stage('shop::eu::orders', {
|
|
123
|
+
rowId: 'r1',
|
|
124
|
+
field: 'total',
|
|
125
|
+
before: 1,
|
|
126
|
+
after: 999,
|
|
127
|
+
})
|
|
128
|
+
const after = useDataBrowserTabs()
|
|
129
|
+
after.restore('warehouse')
|
|
130
|
+
after.openTab('shop', 'eu', 'orders', false)
|
|
131
|
+
expect(useStagedEdits().list('shop::eu::orders')).toEqual([])
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('forgets the dropped set, so a load with an unknown selection does not reopen it', () => {
|
|
135
|
+
setup()
|
|
136
|
+
storing({
|
|
137
|
+
database: 'own',
|
|
138
|
+
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
139
|
+
activeId: null,
|
|
140
|
+
})
|
|
141
|
+
useDataBrowserTabs().restore('warehouse')
|
|
142
|
+
setup()
|
|
143
|
+
const reloaded = useDataBrowserTabs()
|
|
144
|
+
reloaded.restore(undefined)
|
|
145
|
+
expect(reloaded.tabs.value).toEqual([])
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('drops the open tab, its saved set and its URL when the selection changes once mounted', () => {
|
|
149
|
+
setup()
|
|
150
|
+
const route = reactive({ query: {} as Record<string, string> })
|
|
151
|
+
const replace = vi.fn(({ query }: { query: Record<string, string> }) => {
|
|
152
|
+
route.query = query
|
|
153
|
+
})
|
|
154
|
+
vi.stubGlobal('useDmsRoute', () => route)
|
|
155
|
+
vi.stubGlobal('useDmsRouter', () => ({ replace }))
|
|
156
|
+
let raw = ''
|
|
157
|
+
vi.stubGlobal('window', {
|
|
158
|
+
sessionStorage: {
|
|
159
|
+
getItem: () => raw || null,
|
|
160
|
+
setItem: (_key: string, value: string) => {
|
|
161
|
+
raw = value
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
const browser = useDataBrowserTabs()
|
|
166
|
+
browser.restore('own')
|
|
167
|
+
browser.openTab('shop', 'eu', 'orders', false)
|
|
168
|
+
expect(route.query).toEqual({
|
|
169
|
+
schema: 'shop',
|
|
170
|
+
table: 'orders',
|
|
171
|
+
instance: 'eu',
|
|
172
|
+
})
|
|
173
|
+
browser.follow('warehouse')
|
|
174
|
+
expect(browser.tabs.value).toEqual([])
|
|
175
|
+
expect(route.query).toEqual({})
|
|
176
|
+
expect(JSON.parse(raw)).toEqual({
|
|
177
|
+
database: 'warehouse',
|
|
178
|
+
tabs: [],
|
|
179
|
+
activeId: null,
|
|
180
|
+
})
|
|
181
|
+
expect(browser.openFromRoute()).toBe(false)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('clears a URL that mirrors a tab of another database instead of opening it again on a reload', () => {
|
|
185
|
+
setup()
|
|
186
|
+
const route = reactive({
|
|
187
|
+
query: { schema: 'sales', table: 'orders', instance: 'eu' } as Record<
|
|
188
|
+
string,
|
|
189
|
+
string
|
|
190
|
+
>,
|
|
191
|
+
})
|
|
192
|
+
vi.stubGlobal('useDmsRoute', () => route)
|
|
193
|
+
vi.stubGlobal('useDmsRouter', () => ({
|
|
194
|
+
replace: ({ query }: { query: Record<string, string> }) => {
|
|
195
|
+
route.query = query
|
|
196
|
+
},
|
|
197
|
+
}))
|
|
198
|
+
let raw = JSON.stringify({
|
|
199
|
+
database: 'own',
|
|
200
|
+
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
201
|
+
activeId: 'sales::eu::orders',
|
|
202
|
+
})
|
|
203
|
+
vi.stubGlobal('window', {
|
|
204
|
+
sessionStorage: {
|
|
205
|
+
getItem: () => raw,
|
|
206
|
+
setItem: (_key: string, value: string) => {
|
|
207
|
+
raw = value
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
})
|
|
211
|
+
const browser = useDataBrowserTabs()
|
|
212
|
+
browser.restore('warehouse')
|
|
213
|
+
expect(browser.tabs.value).toEqual([])
|
|
214
|
+
expect(route.query).toEqual({})
|
|
215
|
+
expect(JSON.parse(raw)).toEqual({
|
|
216
|
+
database: 'warehouse',
|
|
217
|
+
tabs: [],
|
|
218
|
+
activeId: null,
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('keeps a tab opened while the selection was unknown once the selection is known, which a follow treating an unknown database as another one gets wrong', () => {
|
|
223
|
+
setup()
|
|
224
|
+
let raw = ''
|
|
225
|
+
vi.stubGlobal('window', {
|
|
226
|
+
sessionStorage: {
|
|
227
|
+
getItem: () => raw || null,
|
|
228
|
+
setItem: (_key: string, value: string) => {
|
|
229
|
+
raw = value
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
const browser = useDataBrowserTabs()
|
|
234
|
+
browser.restore(undefined)
|
|
235
|
+
browser.openTab('shop', 'eu', 'orders', false)
|
|
236
|
+
browser.follow('own')
|
|
237
|
+
expect(browser.tabs.value.map((tab) => tab.id)).toEqual(['shop::eu::orders'])
|
|
238
|
+
expect(JSON.parse(raw)).toMatchObject({
|
|
239
|
+
database: 'own',
|
|
240
|
+
tabs: [expect.objectContaining({ id: 'shop::eu::orders' })],
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('keeps a tab opened while the selection is unknown across a reload where it is still unknown, which a reader refusing a set of no known database gets wrong', () => {
|
|
245
|
+
setup()
|
|
246
|
+
let raw = ''
|
|
247
|
+
vi.stubGlobal('window', {
|
|
248
|
+
sessionStorage: {
|
|
249
|
+
getItem: () => raw || null,
|
|
250
|
+
setItem: (_key: string, value: string) => {
|
|
251
|
+
raw = value
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
const first = useDataBrowserTabs()
|
|
256
|
+
first.restore(undefined)
|
|
257
|
+
first.openTab('shop', '__DEFAULT__', 'orders', false)
|
|
258
|
+
setup()
|
|
259
|
+
const reloaded = useDataBrowserTabs()
|
|
260
|
+
reloaded.restore(undefined)
|
|
261
|
+
expect(reloaded.tabs.value.map((tab) => tab.id)).toEqual([
|
|
262
|
+
'shop::__DEFAULT__::orders',
|
|
263
|
+
])
|
|
264
|
+
setup()
|
|
265
|
+
const known = useDataBrowserTabs()
|
|
266
|
+
known.restore('own')
|
|
267
|
+
expect(known.tabs.value.map((tab) => tab.id)).toEqual([
|
|
268
|
+
'shop::__DEFAULT__::orders',
|
|
269
|
+
])
|
|
270
|
+
expect(JSON.parse(raw)).toMatchObject({ database: 'own' })
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
it('keeps the tabs when the selected database is unknown', () => {
|
|
274
|
+
setup()
|
|
275
|
+
storing({
|
|
276
|
+
database: 'warehouse',
|
|
277
|
+
tabs: [{ schema: 'sales', instance: 'eu', table: 'orders' }],
|
|
278
|
+
activeId: null,
|
|
279
|
+
})
|
|
280
|
+
const browser = useDataBrowserTabs()
|
|
281
|
+
browser.restore(undefined)
|
|
282
|
+
expect(browser.tabs.value.map((tab) => tab.id)).toEqual(['sales::eu::orders'])
|
|
283
|
+
browser.openTab('audit', 'us', 'events', false)
|
|
284
|
+
const reloaded = useDataBrowserTabs()
|
|
285
|
+
reloaded.restore('warehouse')
|
|
286
|
+
expect(reloaded.tabs.value.map((tab) => tab.id)).toEqual([
|
|
287
|
+
'sales::eu::orders',
|
|
288
|
+
'audit::us::events',
|
|
289
|
+
])
|
|
290
|
+
})
|
|
291
|
+
|
|
43
292
|
it('retains usable tabs when session storage is unavailable', () => {
|
|
44
293
|
setup()
|
|
45
294
|
const deny = () => {
|
|
@@ -47,7 +296,7 @@ it('retains usable tabs when session storage is unavailable', () => {
|
|
|
47
296
|
}
|
|
48
297
|
vi.stubGlobal('window', { sessionStorage: { getItem: deny, setItem: deny } })
|
|
49
298
|
const browser = useDataBrowserTabs()
|
|
50
|
-
browser.restore()
|
|
299
|
+
browser.restore('own')
|
|
51
300
|
browser.openTab('sales', 'eu', 'orders', false)
|
|
52
301
|
expect(browser.activeId.value).toBe('sales::eu::orders')
|
|
53
302
|
})
|
|
@@ -65,7 +314,7 @@ it('does not revisit an already selected deep link while restoring tabs', () =>
|
|
|
65
314
|
},
|
|
66
315
|
}))
|
|
67
316
|
const browser = useDataBrowserTabs()
|
|
68
|
-
browser.restore()
|
|
317
|
+
browser.restore('own')
|
|
69
318
|
expect(browser.activeId.value).toBe('sales::eu::orders')
|
|
70
319
|
expect(replace).not.toHaveBeenCalled()
|
|
71
320
|
browser.openTab('sales', 'us', 'orders', false)
|
|
@@ -90,6 +339,7 @@ it('restores the preview tab as a preview, the URL naming it included', () => {
|
|
|
90
339
|
sessionStorage: {
|
|
91
340
|
getItem: () =>
|
|
92
341
|
JSON.stringify({
|
|
342
|
+
database: 'own',
|
|
93
343
|
tabs: [
|
|
94
344
|
{ schema: 'sales', instance: 'eu', table: 'customers' },
|
|
95
345
|
{
|
|
@@ -105,7 +355,7 @@ it('restores the preview tab as a preview, the URL naming it included', () => {
|
|
|
105
355
|
},
|
|
106
356
|
})
|
|
107
357
|
const browser = useDataBrowserTabs()
|
|
108
|
-
browser.restore()
|
|
358
|
+
browser.restore('own')
|
|
109
359
|
expect(browser.activeId.value).toBe('sales::eu::orders')
|
|
110
360
|
expect(browser.tabs.value.map((tab) => tab.preview)).toEqual([false, true])
|
|
111
361
|
expect(replace).not.toHaveBeenCalled()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { useDataBrowserTabs } from '../app/build/composables/useDataBrowserTabs'
|
|
4
|
+
|
|
5
|
+
afterEach(() => vi.unstubAllGlobals())
|
|
6
|
+
|
|
7
|
+
/** A browser whose session and local storage keep what the page writes. */
|
|
8
|
+
function browsing() {
|
|
9
|
+
const storage = () => {
|
|
10
|
+
const items = new Map<string, string>()
|
|
11
|
+
return {
|
|
12
|
+
getItem: (key: string) => items.get(key) ?? null,
|
|
13
|
+
setItem: (key: string, value: string) => void items.set(key, value),
|
|
14
|
+
removeItem: (key: string) => void items.delete(key),
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
vi.stubGlobal('useDmsState', (_key: string, init: () => unknown) =>
|
|
18
|
+
ref(init()),
|
|
19
|
+
)
|
|
20
|
+
vi.stubGlobal('computed', computed)
|
|
21
|
+
vi.stubGlobal('useDmsRoute', () => ({ query: {} }))
|
|
22
|
+
vi.stubGlobal('useDmsRouter', () => ({ replace: vi.fn() }))
|
|
23
|
+
vi.stubGlobal('useDataBrowserGrid', () => ({ drop: vi.fn() }))
|
|
24
|
+
vi.stubGlobal('window', {
|
|
25
|
+
sessionStorage: storage(),
|
|
26
|
+
localStorage: storage(),
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The tables the empty state offers, as `schema.table`. */
|
|
31
|
+
function offered(browser: ReturnType<typeof useDataBrowserTabs>): string[] {
|
|
32
|
+
return browser.recent.value.map((entry) => `${entry.schema}.${entry.table}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
it('P2: after follow drops the old database tabs, the empty state offers none of its tables', () => {
|
|
36
|
+
browsing()
|
|
37
|
+
const browser = useDataBrowserTabs()
|
|
38
|
+
browser.restore('own')
|
|
39
|
+
browser.openTab('shop', 'eu', 'orders', false)
|
|
40
|
+
browser.closeTab('shop::eu::orders')
|
|
41
|
+
expect(offered(browser)).toEqual(['shop.orders'])
|
|
42
|
+
browser.follow('warehouse')
|
|
43
|
+
expect(offered(browser)).toEqual([])
|
|
44
|
+
browser.openTab('public', '__DEFAULT__', 'invoices', false)
|
|
45
|
+
expect(offered(browser)).toEqual(['public.invoices'])
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('offers on a reload only the tables of the selected database, and those of the previous one once it is selected again, which one list for every database gets wrong', () => {
|
|
49
|
+
browsing()
|
|
50
|
+
const before = useDataBrowserTabs()
|
|
51
|
+
before.restore('own')
|
|
52
|
+
before.openTab('shop', 'eu', 'orders', false)
|
|
53
|
+
const switched = useDataBrowserTabs()
|
|
54
|
+
switched.restore('warehouse')
|
|
55
|
+
expect(offered(switched)).toEqual([])
|
|
56
|
+
switched.openTab('public', '__DEFAULT__', 'invoices', false)
|
|
57
|
+
const back = useDataBrowserTabs()
|
|
58
|
+
back.restore('own')
|
|
59
|
+
expect(offered(back)).toEqual(['shop.orders'])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('offers no table while no database is known, which tables remembered under no database get wrong', () => {
|
|
63
|
+
browsing()
|
|
64
|
+
const browser = useDataBrowserTabs()
|
|
65
|
+
browser.restore(undefined)
|
|
66
|
+
browser.openTab('shop', 'eu', 'orders', false)
|
|
67
|
+
expect(offered(browser)).toEqual([])
|
|
68
|
+
browser.follow('warehouse')
|
|
69
|
+
expect(offered(browser)).toEqual([])
|
|
70
|
+
})
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { expect, it, vi } from 'vitest'
|
|
2
2
|
import frontendModule from '../dms.frontend'
|
|
3
|
+
import {
|
|
4
|
+
DATABASE_SWITCHER_WIDGET,
|
|
5
|
+
registerDatabaseSwitcher,
|
|
6
|
+
} from '../app/build/composables/registerDatabaseSwitcher'
|
|
3
7
|
|
|
4
8
|
it('registers every component under the module prefix the backend names', async () => {
|
|
5
9
|
const registerComponent = vi.fn()
|
|
6
10
|
const registerPage = vi.fn()
|
|
11
|
+
const registerPlugin = vi.fn()
|
|
7
12
|
await frontendModule.setup({
|
|
8
13
|
options: { public: {} },
|
|
9
14
|
registerComponent,
|
|
@@ -11,11 +16,14 @@ it('registers every component under the module prefix the backend names', async
|
|
|
11
16
|
registerDynamicPage: vi.fn(),
|
|
12
17
|
registerLayout: vi.fn(),
|
|
13
18
|
registerErrorPage: vi.fn(),
|
|
14
|
-
registerPlugin
|
|
19
|
+
registerPlugin,
|
|
15
20
|
registerMiddleware: vi.fn(),
|
|
16
21
|
provide: vi.fn(),
|
|
17
22
|
use: vi.fn(),
|
|
18
23
|
})
|
|
24
|
+
expect(registerPlugin).toHaveBeenCalledExactlyOnceWith(
|
|
25
|
+
registerDatabaseSwitcher,
|
|
26
|
+
)
|
|
19
27
|
expect(frontendModule.componentPrefix).toBe('DmsDatabase')
|
|
20
28
|
expect(registerPage).not.toHaveBeenCalled()
|
|
21
29
|
const names = registerComponent.mock.calls.map(([name]) => name)
|
|
@@ -29,6 +37,12 @@ it('registers every component under the module prefix the backend names', async
|
|
|
29
37
|
]) {
|
|
30
38
|
expect(names).toContain(name)
|
|
31
39
|
}
|
|
40
|
+
expect(names).toContain(
|
|
41
|
+
DATABASE_SWITCHER_WIDGET.component.replace(
|
|
42
|
+
frontendModule.componentPrefix ?? '',
|
|
43
|
+
'',
|
|
44
|
+
),
|
|
45
|
+
)
|
|
32
46
|
expect(names.every((name) => !name.startsWith('Dms'))).toBe(true)
|
|
33
47
|
expect(new Set(names).size).toBe(names.length)
|
|
34
48
|
})
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { defineComponent, h } from 'vue'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
menuLocks,
|
|
5
|
+
serverRender,
|
|
6
|
+
type BackendRead,
|
|
7
|
+
} from './fixtures/serverRender'
|
|
4
8
|
import ConnectionStatus from '../app/components/ConnectionStatus.vue'
|
|
5
9
|
import DataBrowser from '../app/components/DataBrowser.vue'
|
|
6
10
|
import DataGrid from '../app/components/DataGrid.vue'
|
|
@@ -8,11 +12,16 @@ import QueryConsole from '../app/components/QueryConsole.vue'
|
|
|
8
12
|
import SchemaDiagram from '../app/components/SchemaDiagram.vue'
|
|
9
13
|
import SchemasFilterBar from '../app/components/SchemasFilterBar.vue'
|
|
10
14
|
import TableInspector from '../app/components/TableInspector.vue'
|
|
15
|
+
import DatabaseSwitcher from '../app/components/DatabaseSwitcher.vue'
|
|
16
|
+
import { useDatabaseConnections } from '../app/build/composables/useDatabaseConnections'
|
|
17
|
+
import { WAREHOUSE, connectionsState } from './fixtures/connections'
|
|
11
18
|
|
|
12
19
|
// What a server render of each page reads, and that the browser is handed
|
|
13
20
|
// every response it read: a read the page does not hand over is made again
|
|
14
21
|
// by the browser, after a server request for nothing.
|
|
15
22
|
|
|
23
|
+
const CONNECTIONS_URL = '/api/database/connections'
|
|
24
|
+
|
|
16
25
|
const table = (name: string) => ({
|
|
17
26
|
name,
|
|
18
27
|
fields: {
|
|
@@ -100,11 +109,12 @@ const render = (
|
|
|
100
109
|
describe('server render: every read is handed to the browser', () => {
|
|
101
110
|
it('data browser: the table counts of the first schema', async () => {
|
|
102
111
|
const page = await render(DataBrowser, {}, '/modules/database/data')
|
|
103
|
-
|
|
112
|
+
const reads = page.reads.filter((read) => read.url !== CONNECTIONS_URL)
|
|
113
|
+
expect(reads.map((read) => read.url)).toEqual([
|
|
104
114
|
'/api/database/schemas',
|
|
105
115
|
'/api/database/browse/tables',
|
|
106
116
|
])
|
|
107
|
-
expect(
|
|
117
|
+
expect(reads[1]!.query).toEqual({ filter_schema: 'is:audit' })
|
|
108
118
|
expect(page.untransferred).toEqual([])
|
|
109
119
|
expect(page.html).toContain('4242')
|
|
110
120
|
})
|
|
@@ -115,7 +125,8 @@ describe('server render: every read is handed to the browser', () => {
|
|
|
115
125
|
{},
|
|
116
126
|
'/modules/database/data?schema=shop&table=orders&instance=eu',
|
|
117
127
|
)
|
|
118
|
-
|
|
128
|
+
const reads = page.reads.filter((read) => read.url !== CONNECTIONS_URL)
|
|
129
|
+
expect(reads[1]!.query).toEqual({
|
|
119
130
|
filter_schema: 'is:shop',
|
|
120
131
|
filter_instance: 'is:eu',
|
|
121
132
|
})
|
|
@@ -165,6 +176,7 @@ describe('server render: every read is handed to the browser', () => {
|
|
|
165
176
|
it('query console: the library, saved, shared and run', async () => {
|
|
166
177
|
const page = await render(QueryConsole, {}, '/modules/database/query')
|
|
167
178
|
expect(page.reads.map((read) => read.url).sort()).toEqual([
|
|
179
|
+
CONNECTIONS_URL,
|
|
168
180
|
'/api/database/query/history',
|
|
169
181
|
'/api/database/query/saved',
|
|
170
182
|
'/api/database/query/saved',
|
|
@@ -179,6 +191,7 @@ describe('server render: every read is handed to the browser', () => {
|
|
|
179
191
|
it('diagram: no layout or notes, which only the browser draws', async () => {
|
|
180
192
|
const page = await render(SchemaDiagram, {}, '/modules/database/diagram')
|
|
181
193
|
expect(page.reads.map((read) => read.url)).toEqual([
|
|
194
|
+
CONNECTIONS_URL,
|
|
182
195
|
'/api/database/schemas',
|
|
183
196
|
])
|
|
184
197
|
expect(page.untransferred).toEqual([])
|
|
@@ -195,6 +208,7 @@ describe('server render: every read is handed to the browser', () => {
|
|
|
195
208
|
const page = await render(SchemasFirst, {}, '/modules/database/diagram')
|
|
196
209
|
expect(page.reads.map((read) => read.url)).toEqual([
|
|
197
210
|
'/api/database/schemas',
|
|
211
|
+
CONNECTIONS_URL,
|
|
198
212
|
])
|
|
199
213
|
expect(page.untransferred).toEqual([])
|
|
200
214
|
})
|
|
@@ -207,12 +221,74 @@ describe('server render: every read is handed to the browser', () => {
|
|
|
207
221
|
)
|
|
208
222
|
expect(page.reads.map((read) => read.url).sort()).toEqual([
|
|
209
223
|
'/api/database/browse/count',
|
|
224
|
+
CONNECTIONS_URL,
|
|
210
225
|
'/api/database/schemas',
|
|
211
226
|
])
|
|
212
227
|
expect(page.untransferred).toEqual([])
|
|
213
228
|
expect(page.html).toContain('9876')
|
|
214
229
|
})
|
|
215
230
|
|
|
231
|
+
it('database switcher: sets no sidebar lock in a server render, even once the connections are read, which the sidebar it renders before would hydrate against a locked client state', async () => {
|
|
232
|
+
menuLocks.value = []
|
|
233
|
+
const ConnectionsFirst = defineComponent({
|
|
234
|
+
async setup() {
|
|
235
|
+
await useDatabaseConnections().ready
|
|
236
|
+
return () => h(DatabaseSwitcher)
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
await serverRender(
|
|
240
|
+
ConnectionsFirst,
|
|
241
|
+
{},
|
|
242
|
+
{
|
|
243
|
+
url: '/modules/database/data',
|
|
244
|
+
respond: (read) =>
|
|
245
|
+
read.url === CONNECTIONS_URL
|
|
246
|
+
? connectionsState(WAREHOUSE)
|
|
247
|
+
: backend(read),
|
|
248
|
+
},
|
|
249
|
+
)
|
|
250
|
+
expect(menuLocks.value).toEqual([])
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('table inspector on an external database: offers neither the query console nor the diagram, which an inspector linking to locked pages would not', async () => {
|
|
254
|
+
const external = connectionsState(WAREHOUSE)
|
|
255
|
+
const page = await serverRender(
|
|
256
|
+
TableInspector,
|
|
257
|
+
{ rowData: { schema: 'shop', name: 'orders' } },
|
|
258
|
+
{
|
|
259
|
+
url: '/modules/database/schemas',
|
|
260
|
+
respond: (read) =>
|
|
261
|
+
read.url === CONNECTIONS_URL ? external : backend(read),
|
|
262
|
+
},
|
|
263
|
+
)
|
|
264
|
+
expect(page.untransferred).toEqual([])
|
|
265
|
+
expect(page.html).toContain('dms_database.inspector.actions.browse')
|
|
266
|
+
expect(page.html).not.toContain('dms_database.inspector.actions.query')
|
|
267
|
+
expect(page.html).not.toContain('dms_database.inspector.actions.diagram')
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it('table inspector: counts instances on the project database only, which an inspector reading 1 instance on an external database gets wrong', async () => {
|
|
271
|
+
const INSTANCES = 'dms_database.inspector.instances'
|
|
272
|
+
const own = await render(
|
|
273
|
+
TableInspector,
|
|
274
|
+
{ rowData: { schema: 'shop', name: 'orders' } },
|
|
275
|
+
'/modules/database/schemas',
|
|
276
|
+
)
|
|
277
|
+
expect(own.html).toContain(INSTANCES)
|
|
278
|
+
const external = await serverRender(
|
|
279
|
+
TableInspector,
|
|
280
|
+
{ rowData: { schema: 'shop', name: 'orders' } },
|
|
281
|
+
{
|
|
282
|
+
url: '/modules/database/schemas',
|
|
283
|
+
respond: (read) =>
|
|
284
|
+
read.url === CONNECTIONS_URL
|
|
285
|
+
? connectionsState(WAREHOUSE)
|
|
286
|
+
: backend(read),
|
|
287
|
+
},
|
|
288
|
+
)
|
|
289
|
+
expect(external.html).not.toContain(INSTANCES)
|
|
290
|
+
})
|
|
291
|
+
|
|
216
292
|
it('table inspector: leaves the position and steps to the DMS header', async () => {
|
|
217
293
|
const page = await render(
|
|
218
294
|
TableInspector,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
2
|
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import { normalizePath } from 'vite'
|
|
3
4
|
import { defineConfig } from 'vitest/config'
|
|
4
5
|
import { backendBoundary } from './build/backend-boundary.ts'
|
|
5
6
|
|
|
@@ -10,7 +11,10 @@ const root = resolve(__dirname, '..', 'node_modules', '@antelopejs')
|
|
|
10
11
|
|
|
11
12
|
/** Matches one test file wherever the checkout lives, dot directories included. */
|
|
12
13
|
const testFile = (name: string) =>
|
|
13
|
-
resolve(__dirname, 'tests', name).replace(
|
|
14
|
+
normalizePath(resolve(__dirname, 'tests', name)).replace(
|
|
15
|
+
/[*?[\]{}()!+@|]/g,
|
|
16
|
+
'\\$&',
|
|
17
|
+
)
|
|
14
18
|
|
|
15
19
|
export default defineConfig({
|
|
16
20
|
plugins: [vue(), backendBoundary()],
|
|
@@ -21,6 +25,7 @@ export default defineConfig({
|
|
|
21
25
|
'dms-frontend/templates/vue/frontend-module.ts',
|
|
22
26
|
),
|
|
23
27
|
'#dms-core': resolve(root, 'dms/frontend-vue/layers/dms-core'),
|
|
28
|
+
'#dms-ui': resolve(root, 'dms/frontend-vue/layers/dms-ui'),
|
|
24
29
|
// The renderer's own imports, from this package's dependencies: one
|
|
25
30
|
// Vue for the renderer and the components.
|
|
26
31
|
vue: resolve(__dirname, 'node_modules/vue'),
|
|
@@ -41,6 +46,11 @@ export default defineConfig({
|
|
|
41
46
|
testFile('clientNavigation.test.ts'),
|
|
42
47
|
testFile('apiErrorPresentation.test.ts'),
|
|
43
48
|
testFile('connectionStatus.test.ts'),
|
|
49
|
+
testFile('databaseSwitcher.test.ts'),
|
|
50
|
+
testFile('accessBar.test.ts'),
|
|
51
|
+
testFile('lockedPages.test.ts'),
|
|
52
|
+
testFile('externalBrowser.test.ts'),
|
|
53
|
+
testFile('editRequest.test.ts'),
|
|
44
54
|
],
|
|
45
55
|
},
|
|
46
56
|
},
|