@antcde/component-library 0.1.14-rc.6cfaa28 → 0.1.14-rc.703ea01
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 +2 -2
- package/dist/index.js +41110 -35105
- package/dist/types/{components → src/components}/BaseDeleteDialog.vue.d.ts +8 -1
- package/dist/types/src/components/DmsFilePicker/composables/usePickerNavigation.d.ts +196 -0
- package/dist/types/src/components/DmsFilePicker/composables/usePickerUpload.d.ts +22 -0
- package/dist/types/src/components/DmsFilePicker/index.vue.d.ts +28 -0
- package/dist/types/src/components/DmsFilePicker/utils/fileFormatting.d.ts +6 -0
- package/dist/types/src/components/FilePreviewContent/index.vue.d.ts +31 -0
- package/dist/types/src/components/FlowWindowContent/index.vue.d.ts +113 -0
- package/dist/types/src/components/RichTextEditor/index.vue.d.ts +51 -0
- package/dist/types/{components → src/components}/StackedLabels/_LabelsMenuCard.vue.d.ts +1 -1
- package/dist/types/src/components/TasksFlow/components/_FlowBreadcrumb.vue.d.ts +17 -0
- package/dist/types/src/components/TasksFlow/components/_FlowEdgeConditionsDialog.vue.d.ts +10 -0
- package/dist/types/{components/TasksFlow/components/nodes/_triggerNode.vue.d.ts → src/components/TasksFlow/components/_FlowSearch.vue.d.ts} +4 -3
- package/dist/types/src/components/TasksFlow/components/_FlowStats.vue.d.ts +5 -0
- package/dist/types/src/components/TasksFlow/components/_InsertTemplateDialog.vue.d.ts +17 -0
- package/dist/types/src/components/TasksFlow/components/_SubflowPanel.vue.d.ts +125 -0
- package/dist/types/src/components/TasksFlow/components/_VersionDiffView.vue.d.ts +14 -0
- package/dist/types/src/components/TasksFlow/components/_VersionPublishDialog.vue.d.ts +14 -0
- package/dist/types/{components → src/components}/TasksFlow/components/_flowEditor.vue.d.ts +6 -7
- package/dist/types/src/components/TasksFlow/components/nodes/_DurationEditor.vue.d.ts +33 -0
- package/dist/types/src/components/TasksFlow/components/nodes/_NodeContextMenu.vue.d.ts +35 -0
- package/dist/types/src/components/TasksFlow/components/nodes/_UserPicker.vue.d.ts +32 -0
- package/dist/types/{components → src/components}/TasksFlow/components/nodes/_taskNode.vue.d.ts +2 -2
- package/dist/types/src/components/TasksFlow/components/nodes/_triggerNode.vue.d.ts +10 -0
- package/dist/types/src/components/TasksFlow/composables/useAutoLayout.d.ts +22 -0
- package/dist/types/src/components/TasksFlow/composables/useCriticalPath.d.ts +8 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowCache.d.ts +17 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowKeyboard.d.ts +15 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowOperations.d.ts +8 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowSearch.d.ts +14 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowUsers.d.ts +27 -0
- package/dist/types/src/components/TasksFlow/composables/useFlowViewport.d.ts +28 -0
- package/dist/types/src/components/TasksFlow/composables/useTaskFlow.d.ts +335 -0
- package/dist/types/{components → src/components}/TasksFlow/composables/useTaskFlowDragDrop.d.ts +0 -1
- package/dist/types/src/components/TasksFlow/composables/useTaskFlowEdges.d.ts +18 -0
- package/dist/types/src/components/TasksFlow/composables/useTaskFlowTypes.d.ts +75 -0
- package/dist/types/src/components/TasksFlow/composables/useTemplateVersioning.d.ts +188 -0
- package/dist/types/src/components/TasksFlow/composables/useTriggerExecution.d.ts +21 -0
- package/dist/types/src/components/TasksFlow/index.vue.d.ts +39 -0
- package/dist/types/src/components/UnifiedWindow/index.vue.d.ts +67 -0
- package/dist/types/src/components/UnifiedWindow/useWindowDrag.d.ts +28 -0
- package/dist/types/src/components/VersionPublishDialog.vue.d.ts +24 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +11 -1
- package/lib/GisViewer/GisViewer.vue +3 -2
- package/lib/build/layer-order.css +33 -0
- package/lib/build/uno.ts +117 -0
- package/lib/build/vite.ts +104 -0
- package/lib/build/vuetify-overrides.css +14 -0
- package/lib/build/vuetify.ts +230 -0
- package/lib/test/TESTING.claude.md +225 -0
- package/lib/test/createMockAppContext.ts +211 -0
- package/lib/test/createTestPinia.ts +31 -0
- package/lib/test/createTestRouter.ts +31 -0
- package/lib/test/index.ts +41 -0
- package/lib/test/mockVueRouter.ts +93 -0
- package/lib/test/mocks/createMockApi.ts +43 -0
- package/lib/test/mocks/createMockContext.ts +109 -0
- package/lib/test/mocks/createMockSignal.ts +30 -0
- package/lib/test/mocks/createMockUser.ts +87 -0
- package/lib/test/mocks/index.ts +11 -0
- package/lib/test/mountApp.ts +47 -0
- package/lib/test/mountWithContext.ts +94 -0
- package/lib/test/setup.ts +151 -0
- package/lib/test/testAppSetup.ts +110 -0
- package/lib/test/vitest.ts +69 -0
- package/package.json +127 -30
- package/dist/types/components/TasksFlow/composables/useTaskFlow.d.ts +0 -103
- package/dist/types/components/TasksFlow/index.vue.d.ts +0 -51
- /package/dist/types/{components → src/components}/BaseAntButton.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAntCard.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAntCreateCard.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAntDatePicker.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAntInput.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAntLoading.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAppCard.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseAppCardSkeleton.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseClickableIcon.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseConfirmDialog.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseDialog.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseLimitedButton.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BaseResizePanel.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/BulkLabelsMenu.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/GlobalLabelBadge.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/RBAC/Permissions/PermissionCard.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/StackedLabels/index.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/TasksFlow/components/_dropzoneBackground.vue.d.ts +0 -0
- /package/dist/types/{components → src/components}/TasksFlow/components/_flowEdge.vue.d.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MountingOptions } from '@vue/test-utils'
|
|
2
|
+
import type { Component, Plugin } from 'vue'
|
|
3
|
+
import { mount } from '@vue/test-utils'
|
|
4
|
+
|
|
5
|
+
export interface MountAppOptions {
|
|
6
|
+
props?: Record<string, any>
|
|
7
|
+
slots?: MountingOptions<any>['slots']
|
|
8
|
+
plugins?: Plugin[]
|
|
9
|
+
stubs?: Record<string, any>
|
|
10
|
+
global?: Omit<NonNullable<MountingOptions<any>['global']>, 'plugins' | 'stubs'>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Thin wrapper around `mount()` for iframe app component tests.
|
|
15
|
+
* Vuetify + i18n come from `config.global.plugins` (registered in `setup.ts`).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { mountApp } from '@antcde/component-library/test'
|
|
20
|
+
* import Main from '@/components/Main.vue'
|
|
21
|
+
*
|
|
22
|
+
* const wrapper = mountApp(Main)
|
|
23
|
+
* const wrapper = mountApp(Main, { props: { id: '1' } })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function mountApp(
|
|
27
|
+
component: Component,
|
|
28
|
+
options: MountAppOptions = {},
|
|
29
|
+
) {
|
|
30
|
+
const {
|
|
31
|
+
props,
|
|
32
|
+
slots,
|
|
33
|
+
plugins = [],
|
|
34
|
+
stubs = {},
|
|
35
|
+
global: globalOverrides = {},
|
|
36
|
+
} = options
|
|
37
|
+
|
|
38
|
+
return mount(component, {
|
|
39
|
+
props,
|
|
40
|
+
slots,
|
|
41
|
+
global: {
|
|
42
|
+
plugins,
|
|
43
|
+
stubs: { Transition: false, TransitionGroup: false, ...stubs },
|
|
44
|
+
...globalOverrides,
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { MountingOptions } from '@vue/test-utils'
|
|
2
|
+
import type { App, Component, Plugin } from 'vue'
|
|
3
|
+
import type { MockAppContext } from './createMockAppContext'
|
|
4
|
+
import type { MockContext } from './mocks/createMockContext'
|
|
5
|
+
import type { UserPreset } from './mocks/createMockUser'
|
|
6
|
+
import { mount } from '@vue/test-utils'
|
|
7
|
+
import { createMockAppContext } from './createMockAppContext'
|
|
8
|
+
import { createMockLicense } from './mocks/createMockContext'
|
|
9
|
+
import { createMockUser } from './mocks/createMockUser'
|
|
10
|
+
|
|
11
|
+
export interface MountWithContextOptions {
|
|
12
|
+
user?: UserPreset | ReturnType<typeof createMockUser>
|
|
13
|
+
/** Domain context overrides (license/project/task). Used to build the default mock context. */
|
|
14
|
+
context?: Partial<MockContext>
|
|
15
|
+
/**
|
|
16
|
+
* Pre-built mock app context (from `createMockAppContext`). Provided under the
|
|
17
|
+
* `appContext` injection key so components calling `injectContext()` resolve it
|
|
18
|
+
* without needing a per-test `vi.mock('@/plugins/context')`.
|
|
19
|
+
*/
|
|
20
|
+
mockContext?: MockAppContext
|
|
21
|
+
/** Pinia instance — typically from `createTestPinia()`. Opt-in. */
|
|
22
|
+
pinia?: Plugin
|
|
23
|
+
/** Router instance — typically from `createTestRouter()`. Opt-in. */
|
|
24
|
+
router?: Plugin
|
|
25
|
+
props?: Record<string, any>
|
|
26
|
+
slots?: MountingOptions<any>['slots']
|
|
27
|
+
stubs?: MountingOptions<any>['global'] extends { stubs?: infer S } ? S : never
|
|
28
|
+
mountOptions?: MountingOptions<any>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function provideAppContext(ctx: MockAppContext): Plugin {
|
|
32
|
+
return {
|
|
33
|
+
install(app: App) {
|
|
34
|
+
const value = { comms: ctx.comms, i18n: ctx.i18n, colorMode: ctx.colorMode }
|
|
35
|
+
// Matches `useSingleton('appContext', factory)` shape: inject(name)() returns the value.
|
|
36
|
+
app.provide<() => typeof value>('appContext', () => value)
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function mountWithContext(
|
|
42
|
+
component: Component,
|
|
43
|
+
options: MountWithContextOptions = {},
|
|
44
|
+
) {
|
|
45
|
+
const {
|
|
46
|
+
user: userOption = 'admin',
|
|
47
|
+
context: contextOverrides = {},
|
|
48
|
+
mockContext,
|
|
49
|
+
pinia,
|
|
50
|
+
router,
|
|
51
|
+
props = {},
|
|
52
|
+
slots,
|
|
53
|
+
stubs = {},
|
|
54
|
+
mountOptions = {},
|
|
55
|
+
} = options
|
|
56
|
+
|
|
57
|
+
const user = typeof userOption === 'string'
|
|
58
|
+
? createMockUser(userOption)
|
|
59
|
+
: userOption
|
|
60
|
+
|
|
61
|
+
const ctx = mockContext ?? createMockAppContext({
|
|
62
|
+
license: contextOverrides.license ?? createMockLicense({
|
|
63
|
+
is_admin: user.is_admin,
|
|
64
|
+
user_is_admin: user.is_admin,
|
|
65
|
+
}),
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const plugins: Plugin[] = [provideAppContext(ctx)]
|
|
69
|
+
if (router)
|
|
70
|
+
plugins.unshift(router)
|
|
71
|
+
if (pinia)
|
|
72
|
+
plugins.unshift(pinia)
|
|
73
|
+
|
|
74
|
+
const wrapper = mount(component, {
|
|
75
|
+
props,
|
|
76
|
+
slots,
|
|
77
|
+
...mountOptions,
|
|
78
|
+
global: {
|
|
79
|
+
plugins,
|
|
80
|
+
stubs: {
|
|
81
|
+
Transition: false,
|
|
82
|
+
TransitionGroup: false,
|
|
83
|
+
...stubs,
|
|
84
|
+
},
|
|
85
|
+
...mountOptions.global,
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
wrapper,
|
|
91
|
+
user,
|
|
92
|
+
context: ctx,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { I18nOptions } from 'vue-i18n'
|
|
2
|
+
import { config, enableAutoUnmount } from '@vue/test-utils'
|
|
3
|
+
import { afterEach, vi } from 'vitest'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
import { createI18n } from 'vue-i18n'
|
|
6
|
+
import { createVuetify } from 'vuetify'
|
|
7
|
+
import * as components from 'vuetify/components'
|
|
8
|
+
import * as directives from 'vuetify/directives'
|
|
9
|
+
|
|
10
|
+
interface HappyDOMWindow {
|
|
11
|
+
Response: typeof Response
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface HappyDOMHandle {
|
|
15
|
+
settings?: {
|
|
16
|
+
fetch?: {
|
|
17
|
+
interceptor?: {
|
|
18
|
+
beforeAsyncRequest?: (ctx: { window: HappyDOMWindow }) => Promise<unknown>
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare global {
|
|
25
|
+
interface Window {
|
|
26
|
+
happyDOM?: HappyDOMHandle
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line vars-on-top
|
|
29
|
+
var __antTestMockComms: Record<string, unknown> | undefined
|
|
30
|
+
// eslint-disable-next-line vars-on-top
|
|
31
|
+
var __antTestMockColorMode: unknown
|
|
32
|
+
// eslint-disable-next-line vars-on-top
|
|
33
|
+
var __antTestMockI18n: unknown
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Builds an i18n instance with ANT test defaults. Missing keys fall back to the
|
|
38
|
+
* key itself so tests can assert `expect(html).toContain('foo.bar')`.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const i18n = createTestI18n({ messages: { en: { greeting: 'Hi' } } })
|
|
43
|
+
* mount(MyComponent, { global: { plugins: [i18n] } })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function createTestI18n(overrides: Partial<I18nOptions> = {}) {
|
|
47
|
+
return createI18n({
|
|
48
|
+
legacy: false,
|
|
49
|
+
locale: 'en',
|
|
50
|
+
fallbackLocale: 'en',
|
|
51
|
+
missing: (_locale, key) => key,
|
|
52
|
+
messages: { en: {} },
|
|
53
|
+
...overrides,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
config.global.plugins = [
|
|
58
|
+
createVuetify({ components, directives }),
|
|
59
|
+
createTestI18n(),
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
enableAutoUnmount(afterEach)
|
|
63
|
+
|
|
64
|
+
const happyDOM = window.happyDOM
|
|
65
|
+
if (happyDOM?.settings?.fetch) {
|
|
66
|
+
happyDOM.settings.fetch.interceptor = {
|
|
67
|
+
beforeAsyncRequest: async ({ window: w }) => new w.Response('', { status: 200 }),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Object.defineProperty(window, 'scrollTo', { value: () => null, writable: true })
|
|
72
|
+
|
|
73
|
+
if (!globalThis.ResizeObserver) {
|
|
74
|
+
globalThis.ResizeObserver = class ResizeObserver {
|
|
75
|
+
observe() {}
|
|
76
|
+
unobserve() {}
|
|
77
|
+
disconnect() {}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!globalThis.visualViewport) {
|
|
82
|
+
Object.defineProperty(globalThis, 'visualViewport', {
|
|
83
|
+
value: {
|
|
84
|
+
width: 1024,
|
|
85
|
+
height: 768,
|
|
86
|
+
offsetLeft: 0,
|
|
87
|
+
offsetTop: 0,
|
|
88
|
+
pageLeft: 0,
|
|
89
|
+
pageTop: 0,
|
|
90
|
+
scale: 1,
|
|
91
|
+
addEventListener: () => {},
|
|
92
|
+
removeEventListener: () => {},
|
|
93
|
+
dispatchEvent: () => true,
|
|
94
|
+
},
|
|
95
|
+
writable: true,
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
vi.mock('@antcde/vue-utils', async (importOriginal) => {
|
|
100
|
+
const imported = await importOriginal<Record<string, any>>()
|
|
101
|
+
const real = { ...imported, ...(imported.default ?? {}) }
|
|
102
|
+
|
|
103
|
+
if (!real.useSingleton) {
|
|
104
|
+
for (const key of Object.getOwnPropertyNames(imported)) {
|
|
105
|
+
if (!(key in real))
|
|
106
|
+
real[key] = imported[key]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
...real,
|
|
112
|
+
|
|
113
|
+
useApi: (serviceFn: (...args: any[]) => Promise<any>, defaultValue: any) => {
|
|
114
|
+
const state = ref(structuredClone(defaultValue))
|
|
115
|
+
const isLoading = ref(false)
|
|
116
|
+
const error = ref(null)
|
|
117
|
+
const execute = vi.fn(async (...args: any[]) => {
|
|
118
|
+
isLoading.value = true
|
|
119
|
+
try {
|
|
120
|
+
const result = await serviceFn(...args)
|
|
121
|
+
state.value = result ?? structuredClone(defaultValue)
|
|
122
|
+
error.value = null
|
|
123
|
+
return result
|
|
124
|
+
}
|
|
125
|
+
catch (e: any) {
|
|
126
|
+
error.value = e
|
|
127
|
+
return undefined
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
isLoading.value = false
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
return { state, isLoading, error, execute, isReady: ref(true), executeDelayed: vi.fn() }
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
useCommsClient: () => {
|
|
137
|
+
const mocks = globalThis.__antTestMockComms
|
|
138
|
+
if (!mocks)
|
|
139
|
+
throw new Error('createMockAppContext() must be called before mounting. It sets up mock comms for the real context plugin.')
|
|
140
|
+
return mocks
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
useAntColorMode: () => {
|
|
144
|
+
return globalThis.__antTestMockColorMode ?? ref('light')
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
useAntI18n: () => {
|
|
148
|
+
return globalThis.__antTestMockI18n ?? { t: (k: string) => k, locale: ref('en') }
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
})
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Component, Plugin } from 'vue'
|
|
2
|
+
import type { MockAppContext } from './createMockAppContext'
|
|
3
|
+
import { flushPromises, mount } from '@vue/test-utils'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
import { nextTick } from 'vue'
|
|
6
|
+
|
|
7
|
+
export interface TestAppSetupOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The real `provideContext` plugin from your app's `@/plugins/context`.
|
|
10
|
+
* Tests use real Vue provide/inject — if context plugin is missing, tests fail.
|
|
11
|
+
*/
|
|
12
|
+
provideContext: Plugin
|
|
13
|
+
plugins?: Plugin[]
|
|
14
|
+
props?: Record<string, any>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Verifies the app correctly integrates with ANT-OS:
|
|
19
|
+
* 1. Mounts with real context (provide/inject)
|
|
20
|
+
* 2. Fails without context plugin (catches wiring bugs)
|
|
21
|
+
* 3. Implements dark mode from host colorMode preference
|
|
22
|
+
* 4. Has working i18n from context
|
|
23
|
+
* 5. useApi works with connect service mocks
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { createMockAppContext, testAppSetup } from '@antcde/component-library/test'
|
|
28
|
+
* import { provideContext } from '@/plugins/context'
|
|
29
|
+
* import App from '@/App.vue'
|
|
30
|
+
*
|
|
31
|
+
* const mockContext = createMockAppContext({
|
|
32
|
+
* connect: { myService: { getItems: vi.fn().mockResolvedValue([]) } },
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* testAppSetup(App, mockContext, { provideContext })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function testAppSetup(
|
|
39
|
+
App: Component,
|
|
40
|
+
mockContext: MockAppContext,
|
|
41
|
+
options: TestAppSetupOptions,
|
|
42
|
+
) {
|
|
43
|
+
const mountApp = () => {
|
|
44
|
+
return mount(App, {
|
|
45
|
+
global: {
|
|
46
|
+
plugins: [options.provideContext, ...(options.plugins ?? [])],
|
|
47
|
+
stubs: { Transition: false, TransitionGroup: false },
|
|
48
|
+
config: { warnHandler: () => {} },
|
|
49
|
+
},
|
|
50
|
+
props: options.props,
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('app setup', () => {
|
|
55
|
+
it('mounts with context provided', () => {
|
|
56
|
+
const wrapper = mountApp()
|
|
57
|
+
expect(wrapper.vm).toBeTruthy()
|
|
58
|
+
wrapper.unmount()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('fails without provideContext plugin', () => {
|
|
62
|
+
expect(() => mount(App, {
|
|
63
|
+
global: {
|
|
64
|
+
plugins: [...(options.plugins ?? [])],
|
|
65
|
+
stubs: { Transition: false, TransitionGroup: false },
|
|
66
|
+
config: { warnHandler: () => {} },
|
|
67
|
+
},
|
|
68
|
+
props: options.props,
|
|
69
|
+
})).toThrow()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('responds to dark mode preference from host', async () => {
|
|
73
|
+
const wrapper = mountApp()
|
|
74
|
+
await nextTick()
|
|
75
|
+
const lightOutput = wrapper.html()
|
|
76
|
+
|
|
77
|
+
mockContext.colorMode.value = 'dark'
|
|
78
|
+
await nextTick()
|
|
79
|
+
const darkOutput = wrapper.html()
|
|
80
|
+
|
|
81
|
+
expect(darkOutput).not.toBe(lightOutput)
|
|
82
|
+
|
|
83
|
+
mockContext.colorMode.value = 'light'
|
|
84
|
+
await nextTick()
|
|
85
|
+
|
|
86
|
+
expect(wrapper.html()).not.toBe(darkOutput)
|
|
87
|
+
wrapper.unmount()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('has working i18n from context', () => {
|
|
91
|
+
const wrapper = mountApp()
|
|
92
|
+
const text = wrapper.text().trim()
|
|
93
|
+
expect(text.length).toBeGreaterThan(0)
|
|
94
|
+
expect(mockContext.i18n.t('test.key')).toBe('test.key')
|
|
95
|
+
wrapper.unmount()
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('useApi resolves connect service mocks', async () => {
|
|
99
|
+
const wrapper = mountApp()
|
|
100
|
+
await flushPromises()
|
|
101
|
+
expect(wrapper.vm).toBeTruthy()
|
|
102
|
+
|
|
103
|
+
const services = Object.entries(mockContext.comms.connect)
|
|
104
|
+
.filter(([key]) => key !== 'httpClient')
|
|
105
|
+
expect(services.length).toBeGreaterThan(0)
|
|
106
|
+
|
|
107
|
+
wrapper.unmount()
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import vuetify from 'vite-plugin-vuetify'
|
|
4
|
+
import { defineConfig, mergeConfig } from 'vitest/config'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Vitest config pre-configured for ANT platform packages.
|
|
8
|
+
*
|
|
9
|
+
* Includes: vue plugin, vuetify auto-import, happy-dom environment,
|
|
10
|
+
* vuetify dep inlining, path alias resolution, and the shared setup file
|
|
11
|
+
* that registers Vuetify + i18n on `config.global.plugins` and mocks
|
|
12
|
+
* `@antcde/vue-utils`.
|
|
13
|
+
*
|
|
14
|
+
* @param appRoot - Pass `import.meta.url` from your vitest.config.ts.
|
|
15
|
+
* @param overrides - Additional config merged via `mergeConfig()`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createAntVitestConfig } from '@antcde/component-library/test/vitest'
|
|
20
|
+
* export default createAntVitestConfig(import.meta.url)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function createAntVitestConfig(appRoot: string | URL, overrides: Record<string, any> = {}) {
|
|
24
|
+
const rootDir = fileURLToPath(new URL('.', appRoot))
|
|
25
|
+
const sharedSetup = fileURLToPath(new URL('./setup.ts', import.meta.url))
|
|
26
|
+
|
|
27
|
+
const base = defineConfig({
|
|
28
|
+
plugins: [
|
|
29
|
+
vue(),
|
|
30
|
+
vuetify({ autoImport: true }),
|
|
31
|
+
],
|
|
32
|
+
resolve: {
|
|
33
|
+
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue'],
|
|
34
|
+
alias: {
|
|
35
|
+
'@': fileURLToPath(new URL('./src', appRoot)),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
test: {
|
|
39
|
+
globals: true,
|
|
40
|
+
environment: 'happy-dom',
|
|
41
|
+
environmentOptions: {
|
|
42
|
+
happyDOM: {
|
|
43
|
+
settings: {
|
|
44
|
+
navigator: {
|
|
45
|
+
maxTouchPoints: 0,
|
|
46
|
+
},
|
|
47
|
+
disableCSSFileLoading: true,
|
|
48
|
+
disableJavaScriptFileLoading: true,
|
|
49
|
+
handleDisabledFileLoadingAsSuccess: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
root: rootDir,
|
|
54
|
+
include: [
|
|
55
|
+
'src/**/*.{test,spec}.ts',
|
|
56
|
+
'tests/**/*.{test,spec}.ts',
|
|
57
|
+
],
|
|
58
|
+
exclude: ['node_modules'],
|
|
59
|
+
server: {
|
|
60
|
+
deps: {
|
|
61
|
+
inline: ['vuetify'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
setupFiles: [sharedSetup],
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return mergeConfig(base, overrides)
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antcde/component-library",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.14-rc.
|
|
4
|
+
"version": "0.1.14-rc.703ea01",
|
|
5
5
|
"description": "Helper to use ant components in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"types": "./dist/types/src/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"require": "./dist/index.cjs.js"
|
|
12
12
|
},
|
|
13
13
|
"./composables/*": {
|
|
14
|
-
"types": "./dist/types/composables/*.d.ts"
|
|
14
|
+
"types": "./dist/types/src/composables/*.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./build/uno": {
|
|
17
|
+
"import": "./lib/build/uno.ts"
|
|
18
|
+
},
|
|
19
|
+
"./build/vite": {
|
|
20
|
+
"import": "./lib/build/vite.ts"
|
|
21
|
+
},
|
|
22
|
+
"./build/vuetify": {
|
|
23
|
+
"import": "./lib/build/vuetify.ts"
|
|
24
|
+
},
|
|
25
|
+
"./build/layer-order.css": "./lib/build/layer-order.css",
|
|
26
|
+
"./test": {
|
|
27
|
+
"import": "./lib/test/index.ts"
|
|
28
|
+
},
|
|
29
|
+
"./test/vitest": {
|
|
30
|
+
"import": "./lib/test/vitest.ts"
|
|
31
|
+
},
|
|
32
|
+
"./test/mocks": {
|
|
33
|
+
"import": "./lib/test/mocks/index.ts"
|
|
34
|
+
},
|
|
35
|
+
"./test/mount": {
|
|
36
|
+
"import": "./lib/test/mountWithContext.ts"
|
|
37
|
+
},
|
|
38
|
+
"./test/mockVueRouter": {
|
|
39
|
+
"import": "./lib/test/mockVueRouter.ts"
|
|
15
40
|
},
|
|
16
41
|
"./lib/ForgeViewer": {
|
|
17
42
|
"import": "./lib/ForgeViewer/index.ts"
|
|
@@ -40,7 +65,7 @@
|
|
|
40
65
|
},
|
|
41
66
|
"main": "./dist/index.js",
|
|
42
67
|
"module": "./dist/index.js",
|
|
43
|
-
"types": "./dist/types/index.d.ts",
|
|
68
|
+
"types": "./dist/types/src/index.d.ts",
|
|
44
69
|
"files": [
|
|
45
70
|
"/dist",
|
|
46
71
|
"/lib",
|
|
@@ -60,48 +85,120 @@
|
|
|
60
85
|
"format": "prettier --write src/"
|
|
61
86
|
},
|
|
62
87
|
"peerDependencies": {
|
|
88
|
+
"@iconify/vue": ">=5.0.0",
|
|
89
|
+
"@intlify/unplugin-vue-i18n": ">=11.0.0",
|
|
90
|
+
"@pinia/testing": ">=1.0.0",
|
|
91
|
+
"@unocss/preset-rem-to-px": "*",
|
|
92
|
+
"@unocss/preset-wind4": "*",
|
|
93
|
+
"@vitejs/plugin-vue": ">=6.0.0",
|
|
94
|
+
"@vue/test-utils": ">=2.4.0",
|
|
95
|
+
"happy-dom": ">=20.0.0",
|
|
96
|
+
"pinia": ">=3.0.0",
|
|
97
|
+
"unocss": "*",
|
|
98
|
+
"unplugin-auto-import": "*",
|
|
99
|
+
"unplugin-icons": "*",
|
|
100
|
+
"unplugin-vue-components": "*",
|
|
101
|
+
"vite": ">=8.0.0",
|
|
102
|
+
"vite-plugin-vuetify": ">=2.0.0",
|
|
103
|
+
"vitest": ">=4.0.0",
|
|
63
104
|
"vue": "^3.5.29",
|
|
64
|
-
"
|
|
105
|
+
"vue-router": ">=4.0.0",
|
|
106
|
+
"vuetify": "^4.0.4"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"@iconify/vue": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"@intlify/unplugin-vue-i18n": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"@unocss/preset-rem-to-px": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"@unocss/preset-wind4": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"@vitejs/plugin-vue": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"unocss": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"unplugin-auto-import": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"unplugin-icons": {
|
|
131
|
+
"optional": true
|
|
132
|
+
},
|
|
133
|
+
"unplugin-vue-components": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"vite": {
|
|
137
|
+
"optional": true
|
|
138
|
+
},
|
|
139
|
+
"vite-plugin-vuetify": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"@vue/test-utils": {
|
|
143
|
+
"optional": true
|
|
144
|
+
},
|
|
145
|
+
"vitest": {
|
|
146
|
+
"optional": true
|
|
147
|
+
},
|
|
148
|
+
"happy-dom": {
|
|
149
|
+
"optional": true
|
|
150
|
+
},
|
|
151
|
+
"pinia": {
|
|
152
|
+
"optional": true
|
|
153
|
+
},
|
|
154
|
+
"@pinia/testing": {
|
|
155
|
+
"optional": true
|
|
156
|
+
},
|
|
157
|
+
"vue-router": {
|
|
158
|
+
"optional": true
|
|
159
|
+
}
|
|
65
160
|
},
|
|
66
161
|
"dependencies": {
|
|
67
|
-
"@antcde/connect-ts": "0.4.
|
|
68
|
-
"@antcde/vue-utils": "0.2.
|
|
162
|
+
"@antcde/connect-ts": "0.4.18-rc.703ea01",
|
|
163
|
+
"@antcde/vue-utils": "0.2.14-rc.703ea01",
|
|
69
164
|
"@arcgis/core": "^4.34.8",
|
|
70
165
|
"@mdi/font": "^7.4.47",
|
|
166
|
+
"@tiptap/extension-link": "^3.23.6",
|
|
167
|
+
"@tiptap/extension-mention": "^3.23.6",
|
|
168
|
+
"@tiptap/extension-placeholder": "^3.23.6",
|
|
169
|
+
"@tiptap/starter-kit": "^3.23.6",
|
|
170
|
+
"@tiptap/suggestion": "^3.23.6",
|
|
171
|
+
"@tiptap/vue-3": "^3.23.6",
|
|
71
172
|
"@vue-flow/background": "^1.3.2",
|
|
72
173
|
"@vue-flow/core": "^1.48.2",
|
|
73
174
|
"@vue-flow/minimap": "^1.5.4",
|
|
74
|
-
"@vueuse/core": "^14.
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"vue-i18n": "^11.3.2",
|
|
79
|
-
"vue-router": "^5.0.4"
|
|
175
|
+
"@vueuse/core": "^14.3.0",
|
|
176
|
+
"qs": "^6.15.2",
|
|
177
|
+
"sanitize-html": "^2.17.4",
|
|
178
|
+
"vue-i18n": "^11.4.4"
|
|
80
179
|
},
|
|
81
180
|
"devDependencies": {
|
|
82
181
|
"@arcgis/core": "^4.30.9",
|
|
83
182
|
"@iconify-json/mdi": "^1.2.3",
|
|
84
|
-
"@iconify/vue": "^5.0.
|
|
85
|
-
"@intlify/unplugin-vue-i18n": "^11.
|
|
183
|
+
"@iconify/vue": "^5.0.1",
|
|
184
|
+
"@intlify/unplugin-vue-i18n": "^11.2.3",
|
|
86
185
|
"@mdi/font": "^7.2.96",
|
|
87
|
-
"@tsconfig/
|
|
88
|
-
"@types/node": "^
|
|
89
|
-
"@types/qs": "^6.15.
|
|
90
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
91
|
-
"@vue/
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"glob": "^13.0.6",
|
|
95
|
-
"npm-run-all2": "^6.2.6",
|
|
186
|
+
"@tsconfig/node22": "^22.0.5",
|
|
187
|
+
"@types/node": "^25.9.1",
|
|
188
|
+
"@types/qs": "^6.15.1",
|
|
189
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
190
|
+
"@vue/test-utils": "^2.4.10",
|
|
191
|
+
"@vue/tsconfig": "^0.9.1",
|
|
192
|
+
"happy-dom": "^20.9.0",
|
|
96
193
|
"pinia": "^3.0.4",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"typescript": "~5.9.3",
|
|
194
|
+
"sass": "^1.100.0",
|
|
195
|
+
"typescript": "~6.0.3",
|
|
100
196
|
"unplugin-icons": "^23.0.1",
|
|
101
|
-
"vite": "^
|
|
102
|
-
"vite-plugin-css-injected-by-js": "^
|
|
197
|
+
"vite": "^8.0.14",
|
|
198
|
+
"vite-plugin-css-injected-by-js": "^5.0.1",
|
|
103
199
|
"vite-plugin-dts": "^4.5.4",
|
|
104
200
|
"vite-plugin-vuetify": "^2.1.3",
|
|
105
|
-
"
|
|
201
|
+
"vitest": "^4.1.7",
|
|
202
|
+
"vue-tsc": "^3.3.2"
|
|
106
203
|
}
|
|
107
204
|
}
|