@antcde/component-library 0.1.11 → 0.1.14-rc.00a441c

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.
Files changed (107) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +41293 -32254
  3. package/dist/types/{components → src/components}/BaseAppCard.vue.d.ts +18 -1
  4. package/dist/types/{components → src/components}/BaseConfirmDialog.vue.d.ts +4 -3
  5. package/dist/types/{components → src/components}/BaseDeleteDialog.vue.d.ts +9 -2
  6. package/dist/types/src/components/BaseLimitedButton.vue.d.ts +45 -0
  7. package/dist/types/src/components/BulkLabelsMenu.vue.d.ts +33 -0
  8. package/dist/types/src/components/DmsFilePicker/composables/usePickerNavigation.d.ts +196 -0
  9. package/dist/types/src/components/DmsFilePicker/composables/usePickerUpload.d.ts +22 -0
  10. package/dist/types/src/components/DmsFilePicker/index.vue.d.ts +28 -0
  11. package/dist/types/src/components/DmsFilePicker/utils/fileFormatting.d.ts +6 -0
  12. package/dist/types/src/components/FilePreviewContent/index.vue.d.ts +31 -0
  13. package/dist/types/src/components/FlowWindowContent/index.vue.d.ts +113 -0
  14. package/dist/types/src/components/GlobalLabelBadge.vue.d.ts +11 -0
  15. package/dist/types/src/components/RichTextEditor/index.vue.d.ts +51 -0
  16. package/dist/types/src/components/StackedLabels/_LabelsMenuCard.vue.d.ts +15 -0
  17. package/dist/types/src/components/StackedLabels/index.vue.d.ts +26 -0
  18. package/dist/types/src/components/TasksFlow/components/_FlowBreadcrumb.vue.d.ts +17 -0
  19. package/dist/types/src/components/TasksFlow/components/_FlowEdgeConditionsDialog.vue.d.ts +10 -0
  20. package/dist/types/{components/TasksFlow/components/nodes/_triggerNode.vue.d.ts → src/components/TasksFlow/components/_FlowSearch.vue.d.ts} +4 -3
  21. package/dist/types/src/components/TasksFlow/components/_FlowStats.vue.d.ts +5 -0
  22. package/dist/types/src/components/TasksFlow/components/_InsertTemplateDialog.vue.d.ts +17 -0
  23. package/dist/types/src/components/TasksFlow/components/_SubflowPanel.vue.d.ts +125 -0
  24. package/dist/types/src/components/TasksFlow/components/_VersionDiffView.vue.d.ts +14 -0
  25. package/dist/types/src/components/TasksFlow/components/_VersionPublishDialog.vue.d.ts +14 -0
  26. package/dist/types/src/components/TasksFlow/components/_flowEditor.vue.d.ts +13 -0
  27. package/dist/types/src/components/TasksFlow/components/nodes/_DurationEditor.vue.d.ts +33 -0
  28. package/dist/types/src/components/TasksFlow/components/nodes/_NodeContextMenu.vue.d.ts +35 -0
  29. package/dist/types/src/components/TasksFlow/components/nodes/_UserPicker.vue.d.ts +32 -0
  30. package/dist/types/{components → src/components}/TasksFlow/components/nodes/_taskNode.vue.d.ts +2 -2
  31. package/dist/types/src/components/TasksFlow/components/nodes/_triggerNode.vue.d.ts +10 -0
  32. package/dist/types/src/components/TasksFlow/composables/useAutoLayout.d.ts +22 -0
  33. package/dist/types/src/components/TasksFlow/composables/useCriticalPath.d.ts +8 -0
  34. package/dist/types/src/components/TasksFlow/composables/useFlowCache.d.ts +17 -0
  35. package/dist/types/src/components/TasksFlow/composables/useFlowCrud.d.ts +21 -0
  36. package/dist/types/src/components/TasksFlow/composables/useFlowEditor.d.ts +54 -0
  37. package/dist/types/src/components/TasksFlow/composables/useFlowFetch.d.ts +33 -0
  38. package/dist/types/src/components/TasksFlow/composables/useFlowKeyboard.d.ts +15 -0
  39. package/dist/types/src/components/TasksFlow/composables/useFlowNotifications.d.ts +15 -0
  40. package/dist/types/src/components/TasksFlow/composables/useFlowOperations.d.ts +8 -0
  41. package/dist/types/src/components/TasksFlow/composables/useFlowRealtime.d.ts +23 -0
  42. package/dist/types/src/components/TasksFlow/composables/useFlowSearch.d.ts +14 -0
  43. package/dist/types/src/components/TasksFlow/composables/useFlowSubflows.d.ts +22 -0
  44. package/dist/types/src/components/TasksFlow/composables/useFlowUsers.d.ts +27 -0
  45. package/dist/types/src/components/TasksFlow/composables/useFlowViewport.d.ts +28 -0
  46. package/dist/types/src/components/TasksFlow/composables/useTaskFlow.d.ts +321 -0
  47. package/dist/types/{components → src/components}/TasksFlow/composables/useTaskFlowDragDrop.d.ts +0 -1
  48. package/dist/types/src/components/TasksFlow/composables/useTaskFlowEdgeConditions.d.ts +10 -0
  49. package/dist/types/src/components/TasksFlow/composables/useTaskFlowEdges.d.ts +18 -0
  50. package/dist/types/src/components/TasksFlow/composables/useTaskFlowMappers.d.ts +4 -0
  51. package/dist/types/src/components/TasksFlow/composables/useTaskFlowTypes.d.ts +76 -0
  52. package/dist/types/src/components/TasksFlow/composables/useTemplateVersioning.d.ts +188 -0
  53. package/dist/types/src/components/TasksFlow/composables/useTemplateVersioningState.d.ts +176 -0
  54. package/dist/types/src/components/TasksFlow/composables/useTriggerExecution.d.ts +21 -0
  55. package/dist/types/src/components/TasksFlow/index.vue.d.ts +39 -0
  56. package/dist/types/src/components/UnifiedWindow/index.vue.d.ts +67 -0
  57. package/dist/types/src/components/UnifiedWindow/useWindowDrag.d.ts +28 -0
  58. package/dist/types/src/components/VersionPublishDialog.vue.d.ts +24 -0
  59. package/dist/types/{index.d.ts → src/index.d.ts} +16 -1
  60. package/lib/GisViewer/GisViewer.vue +3 -2
  61. package/lib/build/layer-order.css +33 -0
  62. package/lib/build/uno.ts +117 -0
  63. package/lib/build/vite.ts +104 -0
  64. package/lib/build/vuetify-overrides.css +14 -0
  65. package/lib/build/vuetify.ts +230 -0
  66. package/lib/test/TESTING.claude.md +225 -0
  67. package/lib/test/createMockAppContext.ts +211 -0
  68. package/lib/test/createTestPinia.ts +31 -0
  69. package/lib/test/createTestRouter.ts +31 -0
  70. package/lib/test/index.ts +41 -0
  71. package/lib/test/mockVueRouter.ts +93 -0
  72. package/lib/test/mocks/createMockApi.ts +43 -0
  73. package/lib/test/mocks/createMockContext.ts +109 -0
  74. package/lib/test/mocks/createMockSignal.ts +30 -0
  75. package/lib/test/mocks/createMockUser.ts +87 -0
  76. package/lib/test/mocks/index.ts +11 -0
  77. package/lib/test/mountApp.ts +47 -0
  78. package/lib/test/mountWithContext.ts +94 -0
  79. package/lib/test/setup.ts +151 -0
  80. package/lib/test/testAppSetup.ts +110 -0
  81. package/lib/test/vitest.ts +69 -0
  82. package/package.json +147 -58
  83. package/dist/component-library.css +0 -1
  84. package/dist/types/components/TasksFlow/components/_flowEditor.vue.d.ts +0 -16
  85. package/dist/types/components/TasksFlow/composables/useTaskFlow.d.ts +0 -103
  86. package/dist/types/components/TasksFlow/index.vue.d.ts +0 -51
  87. package/lib/DocumentManager/DocumentDrop.vue +0 -74
  88. package/lib/DocumentManager/DocumentManager.vue +0 -590
  89. package/lib/DocumentManager/hooks/useDms.ts +0 -180
  90. package/lib/DocumentManager/index.ts +0 -3
  91. package/lib/DocumentManager/lang/translations/de.json +0 -36
  92. package/lib/DocumentManager/lang/translations/en.json +0 -38
  93. package/lib/DocumentManager/lang/translations/nl.json +0 -36
  94. package/lib/DocumentManager/utils.ts +0 -16
  95. /package/dist/types/{components → src/components}/BaseAntButton.vue.d.ts +0 -0
  96. /package/dist/types/{components → src/components}/BaseAntCard.vue.d.ts +0 -0
  97. /package/dist/types/{components → src/components}/BaseAntCreateCard.vue.d.ts +0 -0
  98. /package/dist/types/{components → src/components}/BaseAntDatePicker.vue.d.ts +0 -0
  99. /package/dist/types/{components → src/components}/BaseAntInput.vue.d.ts +0 -0
  100. /package/dist/types/{components → src/components}/BaseAntLoading.vue.d.ts +0 -0
  101. /package/dist/types/{components → src/components}/BaseAppCardSkeleton.vue.d.ts +0 -0
  102. /package/dist/types/{components → src/components}/BaseClickableIcon.vue.d.ts +0 -0
  103. /package/dist/types/{components → src/components}/BaseDialog.vue.d.ts +0 -0
  104. /package/dist/types/{components → src/components}/BaseResizePanel.vue.d.ts +0 -0
  105. /package/dist/types/{components → src/components}/RBAC/Permissions/PermissionCard.vue.d.ts +0 -0
  106. /package/dist/types/{components → src/components}/TasksFlow/components/_dropzoneBackground.vue.d.ts +0 -0
  107. /package/dist/types/{components → src/components}/TasksFlow/components/_flowEdge.vue.d.ts +0 -0
@@ -0,0 +1,211 @@
1
+ import type { Signal } from '@antcde/connect-ts'
2
+ import type { Mock } from 'vitest'
3
+ import type { Ref } from 'vue'
4
+ import { vi } from 'vitest'
5
+ import { computed, ref } from 'vue'
6
+ import { createMockContext, createMockLicense } from './mocks/createMockContext'
7
+
8
+ type MockFn = Mock & ((...args: any[]) => any)
9
+
10
+ export type MockColorMode = Ref<string> & {
11
+ isDark: Ref<boolean>
12
+ host: Ref<boolean | null | undefined>
13
+ state: Ref<string>
14
+ system: Ref<string>
15
+ store: Ref<string>
16
+ }
17
+
18
+ export interface MockAppContext {
19
+ comms: {
20
+ context: Ref<{ license?: any, project?: any, task?: any, [key: string]: any }>
21
+ toolbar: {
22
+ title: Ref<string | undefined>
23
+ subtitle: Ref<string | undefined>
24
+ searchEnabled: Ref<boolean>
25
+ search: Ref<string>
26
+ menu: Ref<any[]>
27
+ isLoading: Ref<boolean>
28
+ }
29
+ signal: ((...signals: Signal[]) => Promise<unknown>) & {
30
+ send: (...signals: Signal[]) => Promise<unknown>
31
+ receive: (cb: (s: Signal) => void) => () => void
32
+ with: (...args: any[]) => { receive: (cb: (s: any) => void) => () => void }
33
+ append: (...signals: Signal[]) => any
34
+ }
35
+ notifications: {
36
+ success: MockFn
37
+ error: MockFn
38
+ warning: MockFn
39
+ info: MockFn
40
+ }
41
+ notepad: {
42
+ show: MockFn
43
+ hide: MockFn
44
+ showTask: MockFn
45
+ selectSbs: MockFn
46
+ }
47
+ connect: Record<string, any>
48
+ request: MockFn
49
+ appState: Ref<string>
50
+ unsubscribe: () => void
51
+ }
52
+ i18n: {
53
+ t: (key: string, params?: Record<string, any>) => string
54
+ locale: Ref<string>
55
+ }
56
+ colorMode: MockColorMode
57
+ /** Simulate receiving a signal from host */
58
+ emitSignal: (signal: Signal) => void
59
+ /** All signals sent by the app */
60
+ sentSignals: Signal[]
61
+ }
62
+
63
+ function resolveKey(messages: Record<string, any>, key: string): string | undefined {
64
+ const parts = key.split('.')
65
+ let current: any = messages
66
+ for (const part of parts) {
67
+ if (current == null || typeof current !== 'object')
68
+ return undefined
69
+ current = current[part]
70
+ }
71
+ return typeof current === 'string' ? current : undefined
72
+ }
73
+
74
+ export function createTranslator(messages?: Record<string, any>) {
75
+ return (key: string, params?: Record<string, any>) => {
76
+ let text = messages ? resolveKey(messages, key) : undefined
77
+ if (!text)
78
+ return params ? `${key}:${JSON.stringify(params)}` : key
79
+ if (params) {
80
+ for (const [k, v] of Object.entries(params))
81
+ text = text.split(`{${k}}`).join(String(v))
82
+ }
83
+ return text
84
+ }
85
+ }
86
+
87
+ function createMockSignalHandler(sentSignals: Signal[], signalCallbacks: Set<(s: Signal) => void>) {
88
+ const receive = (cb: (s: Signal) => void) => {
89
+ signalCallbacks.add(cb)
90
+ return () => {
91
+ signalCallbacks.delete(cb)
92
+ }
93
+ }
94
+
95
+ const send = (...signals: Signal[]) => {
96
+ sentSignals.push(...signals)
97
+ return Promise.resolve()
98
+ }
99
+
100
+ const withFilter = (..._args: any[]): { receive: typeof receive } => ({ receive })
101
+
102
+ const fn = (...signals: Signal[]) => {
103
+ sentSignals.push(...signals)
104
+ return Promise.resolve()
105
+ }
106
+
107
+ const builder: any = Object.assign(fn, {
108
+ send,
109
+ receive,
110
+ with: withFilter,
111
+ append: (...signals: Signal[]) => {
112
+ sentSignals.push(...signals)
113
+ return builder
114
+ },
115
+ })
116
+
117
+ return builder as MockAppContext['comms']['signal']
118
+ }
119
+
120
+ function createMockColorMode(): MockColorMode {
121
+ const mode = ref('light')
122
+ const isDark = computed(() => mode.value === 'dark')
123
+ const host = ref<boolean | null | undefined>(null)
124
+
125
+ return Object.assign(mode, {
126
+ isDark,
127
+ host,
128
+ state: mode,
129
+ system: ref('light'),
130
+ store: mode,
131
+ }) satisfies MockColorMode
132
+ }
133
+
134
+ export function createMockAppContext(overrides?: {
135
+ license?: Parameters<typeof createMockLicense>[0]
136
+ connect?: Record<string, any>
137
+ /** Pass app translation messages for realistic text. Import `en.json` and pass it. */
138
+ messages?: Record<string, any>
139
+ }): MockAppContext {
140
+ const mockCtx = createMockContext({
141
+ license: createMockLicense(overrides?.license),
142
+ })
143
+
144
+ const sentSignals: Signal[] = []
145
+ const signalCallbacks: Set<(s: Signal) => void> = new Set()
146
+
147
+ const comms = {
148
+ context: ref(mockCtx),
149
+ toolbar: {
150
+ title: ref<string | undefined>(undefined),
151
+ subtitle: ref<string | undefined>(undefined),
152
+ searchEnabled: ref(false),
153
+ search: ref(''),
154
+ menu: ref<any[]>([]),
155
+ isLoading: ref(false),
156
+ },
157
+ signal: createMockSignalHandler(sentSignals, signalCallbacks),
158
+ notifications: {
159
+ success: vi.fn().mockResolvedValue(undefined),
160
+ error: vi.fn().mockResolvedValue(undefined),
161
+ warning: vi.fn().mockResolvedValue(undefined),
162
+ info: vi.fn().mockResolvedValue(undefined),
163
+ },
164
+ notepad: {
165
+ show: vi.fn().mockResolvedValue(undefined),
166
+ hide: vi.fn().mockResolvedValue(undefined),
167
+ showTask: vi.fn().mockResolvedValue(undefined),
168
+ selectSbs: vi.fn().mockResolvedValue(undefined),
169
+ },
170
+ connect: { httpClient: {}, ...overrides?.connect },
171
+ request: vi.fn().mockResolvedValue(undefined),
172
+ appState: ref(''),
173
+ unsubscribe: () => {},
174
+ }
175
+
176
+ const i18n = {
177
+ t: createTranslator(overrides?.messages),
178
+ locale: ref('en'),
179
+ }
180
+
181
+ const colorMode = createMockColorMode()
182
+
183
+ Object.assign(globalThis, {
184
+ __antTestMockComms: comms,
185
+ __antTestMockColorMode: colorMode,
186
+ __antTestMockI18n: i18n,
187
+ })
188
+
189
+ return {
190
+ comms,
191
+ i18n,
192
+ colorMode,
193
+ emitSignal: (signal: Signal) => signalCallbacks.forEach(cb => cb(signal)),
194
+ sentSignals,
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Factory for `vi.mock('@antcde/vue-utils', useApiMock)`.
200
+ */
201
+ export function useApiMock() {
202
+ return {
203
+ useApi: (_serviceFn: any, defaultValue: any) => {
204
+ const state = ref(structuredClone(defaultValue))
205
+ const isLoading = ref(false)
206
+ const error = ref(null)
207
+ const execute = vi.fn(async () => state.value)
208
+ return { state, isLoading, error, execute, isReady: ref(true), executeDelayed: vi.fn() }
209
+ },
210
+ }
211
+ }
@@ -0,0 +1,31 @@
1
+ import type { TestingOptions, TestingPinia } from '@pinia/testing'
2
+ import { createTestingPinia } from '@pinia/testing'
3
+
4
+ /**
5
+ * Thin wrapper around `@pinia/testing`'s `createTestingPinia` with sensible defaults
6
+ * for component tests.
7
+ *
8
+ * Default `stubActions: false` keeps real action behavior — better for typical dialog
9
+ * and page tests that exercise full flows. Pass `stubActions: true` to spy without
10
+ * executing.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createTestPinia, mountWithContext } from '@antcde/component-library/test'
15
+ *
16
+ * const pinia = createTestPinia()
17
+ * mountWithContext(MyComponent, { pinia })
18
+ *
19
+ * // With initial state and stubbed actions
20
+ * const pinia = createTestPinia({
21
+ * initialState: { auth: { user: { id: '1' } } },
22
+ * stubActions: true,
23
+ * })
24
+ * ```
25
+ */
26
+ export function createTestPinia(options: TestingOptions = {}): TestingPinia {
27
+ return createTestingPinia({
28
+ stubActions: false,
29
+ ...options,
30
+ })
31
+ }
@@ -0,0 +1,31 @@
1
+ import type { Router, RouteRecordRaw, RouterOptions } from 'vue-router'
2
+ import { createMemoryHistory, createRouter } from 'vue-router'
3
+
4
+ /**
5
+ * Creates a real `vue-router` instance backed by `createMemoryHistory()` for tests.
6
+ *
7
+ * Default `routes` is empty — fine for tests that just need `useRouter().push()` not
8
+ * to throw. Pass routes when navigation matters.
9
+ *
10
+ * **Always `await router.isReady()` after mounting** before asserting on rendered
11
+ * route components — initial navigation is async.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { createTestRouter, mountWithContext } from '@antcde/component-library/test'
16
+ *
17
+ * const router = createTestRouter([{ path: '/', component: HomePage }])
18
+ * const { wrapper } = mountWithContext(App, { router })
19
+ * await router.isReady()
20
+ * ```
21
+ */
22
+ export function createTestRouter(
23
+ routes: RouteRecordRaw[] = [],
24
+ options: Omit<RouterOptions, 'history' | 'routes'> = {},
25
+ ): Router {
26
+ return createRouter({
27
+ history: createMemoryHistory(),
28
+ routes,
29
+ ...options,
30
+ })
31
+ }
@@ -0,0 +1,41 @@
1
+ export { createMockAppContext, createTranslator, useApiMock } from './createMockAppContext'
2
+
3
+ export type { MockAppContext, MockColorMode } from './createMockAppContext'
4
+
5
+ export { createTestPinia } from './createTestPinia'
6
+
7
+ export { createTestRouter } from './createTestRouter'
8
+
9
+ export {
10
+ createMockApi,
11
+ createMockApiMap,
12
+ createMockContext,
13
+ createMockLicense,
14
+ createMockProject,
15
+ createMockSignal,
16
+ createMockTask,
17
+ createMockUser,
18
+ } from './mocks'
19
+
20
+ export type {
21
+ ApiMockMap,
22
+ MockApiReturn,
23
+ MockApiState,
24
+ MockContext,
25
+ MockSignalReturn,
26
+ UserPreset,
27
+ } from './mocks'
28
+ export { mockVueRouter } from './mockVueRouter'
29
+
30
+ export type { MockVueRouterOverrides } from './mockVueRouter'
31
+ export { mountApp } from './mountApp'
32
+
33
+ export type { MountAppOptions } from './mountApp'
34
+
35
+ export { mountWithContext } from './mountWithContext'
36
+ export type { MountWithContextOptions } from './mountWithContext'
37
+
38
+ export { createTestI18n } from './setup'
39
+
40
+ export { testAppSetup } from './testAppSetup'
41
+ export type { TestAppSetupOptions } from './testAppSetup'
@@ -0,0 +1,93 @@
1
+ import { vi } from 'vitest'
2
+
3
+ interface MockRouterMethods {
4
+ push?: ReturnType<typeof vi.fn>
5
+ replace?: ReturnType<typeof vi.fn>
6
+ back?: ReturnType<typeof vi.fn>
7
+ forward?: ReturnType<typeof vi.fn>
8
+ go?: ReturnType<typeof vi.fn>
9
+ beforeEach?: ReturnType<typeof vi.fn>
10
+ afterEach?: ReturnType<typeof vi.fn>
11
+ }
12
+
13
+ interface MockRoute {
14
+ path?: string
15
+ name?: string | symbol | undefined
16
+ fullPath?: string
17
+ query?: Record<string, string | string[] | undefined>
18
+ params?: Record<string, string | string[]>
19
+ hash?: string
20
+ meta?: Record<string, unknown>
21
+ matched?: unknown[]
22
+ redirectedFrom?: unknown
23
+ }
24
+
25
+ export interface MockVueRouterOverrides {
26
+ /** Partial overrides for `useRouter()` methods. Pass your own `vi.fn()` to assert calls. */
27
+ useRouter?: MockRouterMethods
28
+ /**
29
+ * Override for `useRoute()`. Pass an object for a static snapshot, or a function for
30
+ * live values that should re-read on every `useRoute()` call (e.g. when a closure
31
+ * variable changes between tests).
32
+ */
33
+ useRoute?: MockRoute | (() => MockRoute)
34
+ }
35
+
36
+ /**
37
+ * Builds a module-shape object for `vi.mock('vue-router', () => mockVueRouter(overrides))`.
38
+ * Stubs `useRouter` and `useRoute` so tests can assert navigation calls without a real router.
39
+ *
40
+ * **Important:** wrap the call in an arrow function. `vi.mock` is hoisted to the top of
41
+ * the file, so a bare `vi.mock('vue-router', mockVueRouter(...))` would invoke
42
+ * `mockVueRouter` before its import is initialized.
43
+ *
44
+ * Defaults: `useRouter` returns no-op `vi.fn()` for push/replace/back/forward/go.
45
+ * `useRoute` returns `{ path: '/', query: {}, params: {}, fullPath: '/', hash: '', meta: {} }`.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { mockVueRouter } from '@antcde/component-library/test'
50
+ *
51
+ * const replace = vi.fn()
52
+ * vi.mock('vue-router', () => mockVueRouter({ useRouter: { replace } }))
53
+ *
54
+ * // Live route reads — function form re-reads on every useRoute() call:
55
+ * let routeQuery: Record<string, string> = {}
56
+ * vi.mock('vue-router', () => mockVueRouter({ useRoute: () => ({ query: routeQuery }) }))
57
+ * ```
58
+ */
59
+ export function mockVueRouter(overrides: MockVueRouterOverrides = {}) {
60
+ const routerMethods: Required<MockRouterMethods> = {
61
+ push: overrides.useRouter?.push ?? vi.fn(),
62
+ replace: overrides.useRouter?.replace ?? vi.fn(),
63
+ back: overrides.useRouter?.back ?? vi.fn(),
64
+ forward: overrides.useRouter?.forward ?? vi.fn(),
65
+ go: overrides.useRouter?.go ?? vi.fn(),
66
+ beforeEach: overrides.useRouter?.beforeEach ?? vi.fn(() => () => {}),
67
+ afterEach: overrides.useRouter?.afterEach ?? vi.fn(() => () => {}),
68
+ }
69
+
70
+ const baseRoute: MockRoute = {
71
+ path: '/',
72
+ name: undefined,
73
+ fullPath: '/',
74
+ query: {},
75
+ params: {},
76
+ hash: '',
77
+ meta: {},
78
+ matched: [],
79
+ redirectedFrom: undefined,
80
+ }
81
+
82
+ const resolveRoute = () => {
83
+ const r = typeof overrides.useRoute === 'function' ? overrides.useRoute() : overrides.useRoute
84
+ return { ...baseRoute, ...r }
85
+ }
86
+
87
+ return {
88
+ useRouter: () => routerMethods,
89
+ useRoute: () => resolveRoute(),
90
+ RouterLink: { name: 'RouterLink', template: '<a><slot /></a>' },
91
+ RouterView: { name: 'RouterView', template: '<div><slot /></div>' },
92
+ }
93
+ }
@@ -0,0 +1,43 @@
1
+ import { ref } from 'vue'
2
+
3
+ export interface MockApiState<T = any> {
4
+ state: T
5
+ isLoading?: boolean
6
+ isReady?: boolean
7
+ error?: unknown
8
+ }
9
+
10
+ export interface MockApiReturn<T = any> {
11
+ state: ReturnType<typeof ref<T>>
12
+ isLoading: ReturnType<typeof ref<boolean>>
13
+ isReady: ReturnType<typeof ref<boolean>>
14
+ error: ReturnType<typeof ref<unknown>>
15
+ execute: (...args: any[]) => Promise<T>
16
+ executeDelayed: (...args: any[]) => void
17
+ }
18
+
19
+ export function createMockApi<T>(initial: MockApiState<T>): MockApiReturn<T> {
20
+ const state = ref(initial.state) as ReturnType<typeof ref<T>>
21
+ const isLoading = ref(initial.isLoading ?? false)
22
+ const isReady = ref(initial.isReady ?? true)
23
+ const error = ref(initial.error ?? null)
24
+
25
+ return {
26
+ state,
27
+ isLoading,
28
+ isReady,
29
+ error,
30
+ execute: async (..._args: any[]) => state.value as T,
31
+ executeDelayed: () => {},
32
+ }
33
+ }
34
+
35
+ export type ApiMockMap = Record<string, MockApiState>
36
+
37
+ export function createMockApiMap(mocks: ApiMockMap): Map<string, MockApiReturn> {
38
+ const map = new Map<string, MockApiReturn>()
39
+ for (const [key, state] of Object.entries(mocks)) {
40
+ map.set(key, createMockApi(state))
41
+ }
42
+ return map
43
+ }
@@ -0,0 +1,109 @@
1
+ import type { License, Project, Task } from '@antcde/connect-ts'
2
+
3
+ export interface MockContext {
4
+ license: License | null
5
+ project: Project | null
6
+ task: Task | null
7
+ }
8
+
9
+ const BASE_LICENSE: License = {
10
+ id: 'license-1',
11
+ is_admin: true,
12
+ name: 'Test License',
13
+ type: 'enterprise',
14
+ company: 'company-1',
15
+ theme: '#125CFF',
16
+ url: 'http://localhost',
17
+ mfa_required: false,
18
+ user_is_admin: true,
19
+ labels: [],
20
+ limits: {},
21
+ user_permissions: {},
22
+ user_roles: [],
23
+ }
24
+
25
+ const BASE_PROJECT: Project = {
26
+ id: 'project-1',
27
+ name: 'Test Project',
28
+ number: '001',
29
+ slug: 'test-project',
30
+ image: null,
31
+ license: 'license-1',
32
+ is_favorite: false,
33
+ is_master: 0,
34
+ is_archive: false,
35
+ created_at: '2025-01-01T00:00:00.000000Z',
36
+ user_is_admin: true,
37
+ labels: [],
38
+ limits: {},
39
+ user_permissions: {},
40
+ user_roles: [],
41
+ }
42
+
43
+ const BASE_TASK: Task = {
44
+ id: 'task-1',
45
+ number: 1,
46
+ title: 'Test Task',
47
+ description: null,
48
+ status: 'open',
49
+ priority: 'normal',
50
+ progress: 0,
51
+ license: 'license-1',
52
+ project: 'project-1',
53
+ parent: undefined,
54
+ parent_task: null,
55
+ assigned_to: null,
56
+ assignable_users: null,
57
+ created_by: {
58
+ id: 'user-1',
59
+ email: 'test@example.com',
60
+ firstname: 'Test',
61
+ lastname: 'User',
62
+ name: 'Test User',
63
+ profile_picture: '',
64
+ },
65
+ created_at: '2025-01-01T00:00:00.000000Z',
66
+ task_project: null,
67
+ children: [],
68
+ labels: [],
69
+ relations: [],
70
+ sbscode: null,
71
+ sbs_record: null,
72
+ is_private: false,
73
+ is_task: true,
74
+ location: null,
75
+ script: null,
76
+ planned_start: null,
77
+ planned_end: null,
78
+ due: null,
79
+ task_type: null,
80
+ type: null,
81
+ hasChildren: false,
82
+ attachments: [],
83
+ rules: [],
84
+ position_x: 0,
85
+ position_y: 0,
86
+ app: null,
87
+ trigger_id: null,
88
+ trigger: null,
89
+ }
90
+
91
+ export function createMockLicense(overrides: Partial<License> = {}): License {
92
+ return { ...structuredClone(BASE_LICENSE), ...overrides }
93
+ }
94
+
95
+ export function createMockProject(overrides: Partial<Project> = {}): Project {
96
+ return { ...structuredClone(BASE_PROJECT), ...overrides }
97
+ }
98
+
99
+ export function createMockTask(overrides: Partial<Task> = {}): Task {
100
+ return { ...structuredClone(BASE_TASK), ...overrides }
101
+ }
102
+
103
+ export function createMockContext(overrides: Partial<MockContext> = {}): MockContext {
104
+ return {
105
+ license: overrides.license ?? createMockLicense(),
106
+ project: overrides.project ?? null,
107
+ task: overrides.task ?? null,
108
+ }
109
+ }
@@ -0,0 +1,30 @@
1
+ import type { Signal } from '@antcde/connect-ts'
2
+ import type { DeepReadonly, Ref } from 'vue'
3
+ import { readonly, ref } from 'vue'
4
+
5
+ export interface MockSignalReturn {
6
+ signal: DeepReadonly<Ref<Signal | undefined>>
7
+ emit: (signal: Signal) => void
8
+ history: Signal[]
9
+ sent: Signal[]
10
+ send: (signal: Signal) => void
11
+ }
12
+
13
+ export function createMockSignal(): MockSignalReturn {
14
+ const signal = ref<Signal | undefined>()
15
+ const history: Signal[] = []
16
+ const sent: Signal[] = []
17
+
18
+ return {
19
+ signal: readonly(signal),
20
+ emit(s: Signal) {
21
+ signal.value = s
22
+ history.push(s)
23
+ },
24
+ history,
25
+ sent,
26
+ send(s: Signal) {
27
+ sent.push(s)
28
+ },
29
+ }
30
+ }
@@ -0,0 +1,87 @@
1
+ import type { User } from '@antcde/connect-ts'
2
+
3
+ export type UserPreset = 'admin' | 'viewer' | 'editor'
4
+
5
+ const USER_PRESETS: Record<UserPreset, Partial<User>> = {
6
+ admin: {
7
+ is_admin: true,
8
+ licenses: [
9
+ {
10
+ id: 'license-1',
11
+ company: 'company-1',
12
+ name: 'Test License',
13
+ theme: '#125CFF',
14
+ is_admin: true,
15
+ mfa_required: false,
16
+ type: 'enterprise',
17
+ url: 'http://localhost',
18
+ user_is_admin: true,
19
+ labels: [],
20
+ limits: {},
21
+ },
22
+ ],
23
+ },
24
+ viewer: {
25
+ is_admin: false,
26
+ licenses: [
27
+ {
28
+ id: 'license-1',
29
+ company: 'company-1',
30
+ name: 'Test License',
31
+ theme: '#125CFF',
32
+ is_admin: false,
33
+ mfa_required: false,
34
+ type: 'starter',
35
+ url: 'http://localhost',
36
+ user_is_admin: false,
37
+ labels: [],
38
+ limits: {},
39
+ },
40
+ ],
41
+ },
42
+ editor: {
43
+ is_admin: false,
44
+ licenses: [
45
+ {
46
+ id: 'license-1',
47
+ company: 'company-1',
48
+ name: 'Test License',
49
+ theme: '#125CFF',
50
+ is_admin: false,
51
+ mfa_required: false,
52
+ type: 'professional',
53
+ url: 'http://localhost',
54
+ user_is_admin: false,
55
+ labels: [],
56
+ limits: {},
57
+ },
58
+ ],
59
+ },
60
+ }
61
+
62
+ const BASE_USER: User = {
63
+ id: 'user-1',
64
+ email: 'test@example.com',
65
+ name: 'Test User',
66
+ firstname: 'Test',
67
+ lastname: 'User',
68
+ language: 'en',
69
+ company_name: null,
70
+ licenses: [],
71
+ is_admin: false,
72
+ two_factor_enabled: 0,
73
+ photo: null,
74
+ profile_picture: null,
75
+ }
76
+
77
+ export function createMockUser(presetOrOverrides: UserPreset | Partial<User> = 'admin', overrides: Partial<User> = {}): User {
78
+ const preset = typeof presetOrOverrides === 'string'
79
+ ? USER_PRESETS[presetOrOverrides]
80
+ : presetOrOverrides
81
+
82
+ return {
83
+ ...structuredClone(BASE_USER),
84
+ ...structuredClone(preset),
85
+ ...structuredClone(overrides),
86
+ }
87
+ }
@@ -0,0 +1,11 @@
1
+ export { createMockApi, createMockApiMap } from './createMockApi'
2
+ export type { ApiMockMap, MockApiReturn, MockApiState } from './createMockApi'
3
+
4
+ export { createMockContext, createMockLicense, createMockProject, createMockTask } from './createMockContext'
5
+ export type { MockContext } from './createMockContext'
6
+
7
+ export { createMockSignal } from './createMockSignal'
8
+ export type { MockSignalReturn } from './createMockSignal'
9
+
10
+ export { createMockUser } from './createMockUser'
11
+ export type { UserPreset } from './createMockUser'