@antcde/component-library 0.1.14-rc.fd98dae → 0.1.15-rc.70c625c

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/dist/index.js CHANGED
@@ -120,7 +120,7 @@ var et = Object.create, tt = Object.defineProperty, nt = Object.getOwnPropertyDe
120
120
  return n;
121
121
  }, gt = /*#__PURE__*/ ht(mt, [["__scopeId", "data-v-f022cad1"]]);
122
122
  //#endregion
123
- //#region ../../node_modules/.pnpm/@vueuse+shared@14.3.0_vue@3.5.34_typescript@6.0.3_/node_modules/@vueuse/shared/dist/index.js
123
+ //#region ../../node_modules/.pnpm/@vueuse+shared@14.3.0_vue@3.5.38_typescript@6.0.3_/node_modules/@vueuse/shared/dist/index.js
124
124
  function _t(e, t) {
125
125
  return y() ? (I(e, t), !0) : !1;
126
126
  }
@@ -227,7 +227,7 @@ function Lt(e, t, n) {
227
227
  });
228
228
  }
229
229
  //#endregion
230
- //#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.34_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
230
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.38_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
231
231
  var Rt = bt ? window : void 0;
232
232
  bt && window.document, bt && window.navigator, bt && window.location;
233
233
  function zt(e) {
@@ -2925,7 +2925,7 @@ function to(e, t, n, r) {
2925
2925
  }
2926
2926
  Zr();
2927
2927
  //#endregion
2928
- //#region ../../node_modules/.pnpm/vue-i18n@11.4.6_vue@3.5.34_typescript@6.0.3_/node_modules/vue-i18n/dist/vue-i18n.runtime.mjs
2928
+ //#region ../../node_modules/.pnpm/vue-i18n@11.4.6_vue@3.5.38_typescript@6.0.3_/node_modules/vue-i18n/dist/vue-i18n.runtime.mjs
2929
2929
  var no = "11.4.6";
2930
2930
  function ro() {
2931
2931
  typeof __INTLIFY_PROD_DEVTOOLS__ != "boolean" && (Ln().__INTLIFY_PROD_DEVTOOLS__ = !1);
@@ -22668,7 +22668,7 @@ var vj = " ", yj = "\xA0", bj = VS.create({
22668
22668
  }
22669
22669
  });
22670
22670
  //#endregion
22671
- //#region ../../node_modules/.pnpm/@tiptap+vue-3@3.27.0_@floating-ui+dom@1.7.6_@tiptap+core@3.27.0_@tiptap+pm@3.27.0__@tip_63b31f25d72d072f1d46361bbe6b8037/node_modules/@tiptap/vue-3/dist/index.js
22671
+ //#region ../../node_modules/.pnpm/@tiptap+vue-3@3.27.0_@floating-ui+dom@1.7.6_@tiptap+core@3.27.0_@tiptap+pm@3.27.0__@tip_ed2c4545ae1ebe1296c02a9259ad7d77/node_modules/@tiptap/vue-3/dist/index.js
22672
22672
  function Dj(e) {
22673
22673
  return h((t, n) => ({
22674
22674
  get() {
@@ -32664,7 +32664,7 @@ function zU() {
32664
32664
  return e;
32665
32665
  }
32666
32666
  //#endregion
32667
- //#region ../../node_modules/.pnpm/@vue-flow+minimap@1.5.4_@vue-flow+core@1.48.2_vue@3.5.34_typescript@6.0.3___vue@3.5.34_typescript@6.0.3_/node_modules/@vue-flow/minimap/dist/vue-flow-minimap.mjs
32667
+ //#region ../../node_modules/.pnpm/@vue-flow+minimap@1.5.4_@vue-flow+core@1.48.2_vue@3.5.38_typescript@6.0.3___vue@3.5.38_typescript@6.0.3_/node_modules/@vue-flow/minimap/dist/vue-flow-minimap.mjs
32668
32668
  var BU = { value: () => {} };
32669
32669
  function VU() {
32670
32670
  for (var e = 0, t = arguments.length, n = {}, r; e < t; ++e) {
package/lib/build/vite.ts CHANGED
@@ -43,14 +43,6 @@ export const CSS_LAYER_ORDER = '@layer uno-base, uno-theme, vuetify-core, vuetif
43
43
  export function createAntViteConfig(appRoot: string | URL, overrides: UserConfig = {}): UserConfig {
44
44
  const resolve = (relative: string) => fileURLToPath(new URL(relative, appRoot))
45
45
 
46
- // Resolve @antcde/* workspace packages to source so dev-mode HMR picks up
47
- // their changes without rebuilding their dist. Mirrors ant-os' own aliases.
48
- const componentLibSrc = fileURLToPath(new URL('../../src', import.meta.url))
49
- const componentLibBuild = fileURLToPath(new URL('../../lib/build', import.meta.url))
50
- const componentLibTest = fileURLToPath(new URL('../../lib/test', import.meta.url))
51
- const vueUtilsSrc = fileURLToPath(new URL('../../../ant-vue-utils/src', import.meta.url))
52
- const connectTsSrc = fileURLToPath(new URL('../../../ant-connect-ts/src', import.meta.url))
53
-
54
46
  const baseConfig = defineConfig({
55
47
  base: '/__APP_URL__/',
56
48
  optimizeDeps: { exclude: ['vuetify'] },
@@ -101,11 +93,6 @@ export function createAntViteConfig(appRoot: string | URL, overrides: UserConfig
101
93
  extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue'],
102
94
  alias: {
103
95
  '@': resolve('./src'),
104
- '@antcde/component-library/build': componentLibBuild,
105
- '@antcde/component-library/test': componentLibTest,
106
- '@antcde/component-library': componentLibSrc,
107
- '@antcde/vue-utils': vueUtilsSrc,
108
- '@antcde/connect-ts': connectTsSrc,
109
96
  },
110
97
  },
111
98
  build: {
@@ -25,9 +25,9 @@ All exports live at `@antcde/component-library/test`.
25
25
  | `testAppSetup(App, mockContext, { provideContext })` | 5 integration tests verifying real app wiring. Every iframe app's `app.test.ts` includes this. |
26
26
  | `createMockAppContext(overrides?)` | Full mock context: `comms`, `i18n`, `colorMode`, `emitSignal`, `sentSignals`. Sets `globalThis.__antTestMockComms` so `useCommsClient` resolves. |
27
27
  | `createTestI18n(overrides?)` | Build an i18n instance with custom messages/locale. |
28
- | `createTestRouter(routes?, options?)` | Real `vue-router` with `createMemoryHistory()`. Always `await router.isReady()` after mount. |
29
- | `mockVueRouter(overrides?)` | Returns a module-shape object. Use as `vi.mock('vue-router', () => mockVueRouter({ ... }))`. |
30
- | `createTestPinia(options?)` | Wraps `@pinia/testing` `createTestingPinia` (default `stubActions: false`). |
28
+ | `createTestRouter(routes?, options?)` | **Subpath:** `…/test/createTestRouter`. Real `vue-router` with `createMemoryHistory()`. Always `await router.isReady()` after mount. |
29
+ | `mockVueRouter(overrides?)` | **Subpath:** `…/test/mockVueRouter`. Returns a module-shape object. Use as `vi.mock('vue-router', () => mockVueRouter({ ... }))`. |
30
+ | `createTestPinia(options?)` | **Subpath:** `…/test/createTestPinia`. Wraps `@pinia/testing` `createTestingPinia` (default `stubActions: false`). |
31
31
  | `createMockUser(preset?)` | User with `'admin'` / `'viewer'` / `'editor'` presets. |
32
32
  | `createMockLicense/Project/Task(overrides?)` | Domain objects with sensible defaults. |
33
33
  | `createMockSignal()` | Signal mock — `emit()` simulates host, `send()` captures app signals. |
@@ -96,7 +96,8 @@ testAppSetup(App, mockContext, { provideContext })
96
96
  Use `createTestRouter` when the test needs actual `<router-view>` rendering or `router.push()` to navigate.
97
97
 
98
98
  ```ts
99
- import { createTestRouter, mountWithContext } from '@antcde/component-library/test'
99
+ import { mountWithContext } from '@antcde/component-library/test'
100
+ import { createTestRouter } from '@antcde/component-library/test/createTestRouter'
100
101
  import HomePage from '@/pages/Home/index.vue'
101
102
  import DetailPage from '@/pages/Detail/index.vue'
102
103
 
@@ -143,7 +144,7 @@ vi.mock('vue-router', async () => {
143
144
  })
144
145
  ```
145
146
 
146
- > **Why the subpath?** The main `@antcde/component-library/test` barrel re-exports `createTestRouter`, which imports `vue-router`. Importing the barrel from a `vue-router` mock factory creates a resolution cycle. The `./test/mockVueRouter` subpath imports only the helper.
147
+ > **Why the subpath?** `createTestRouter` / `createTestPinia` / `mockVueRouter` are intentionally **not** on the `/test` barrel — they import `vue-router` / `@pinia/testing`, which most iframe apps don't have. Keeping them subpath-only means importing the barrel never forces those deps, and a `vue-router` mock factory can pull `mockVueRouter` without dragging in the whole barrel.
147
148
 
148
149
  ### Custom translations
149
150
 
@@ -173,7 +174,8 @@ const mockContext = createMockAppContext({ messages: en })
173
174
  ### Pinia (apps using stores)
174
175
 
175
176
  ```ts
176
- import { createTestPinia, mountWithContext } from '@antcde/component-library/test'
177
+ import { mountWithContext } from '@antcde/component-library/test'
178
+ import { createTestPinia } from '@antcde/component-library/test/createTestPinia'
177
179
 
178
180
  // Default: real action behavior
179
181
  const pinia = createTestPinia()
@@ -3,6 +3,7 @@ import type { Mock } from 'vitest'
3
3
  import type { Ref } from 'vue'
4
4
  import { vi } from 'vitest'
5
5
  import { computed, ref } from 'vue'
6
+ import { createMockConnect } from './createMockConnect'
6
7
  import { createMockContext, createMockLicense } from './mocks/createMockContext'
7
8
 
8
9
  type MockFn = Mock & ((...args: any[]) => any)
@@ -167,7 +168,7 @@ export function createMockAppContext(overrides?: {
167
168
  showTask: vi.fn().mockResolvedValue(undefined),
168
169
  selectSbs: vi.fn().mockResolvedValue(undefined),
169
170
  },
170
- connect: { httpClient: {}, ...overrides?.connect },
171
+ connect: createMockConnect(overrides?.connect),
171
172
  request: vi.fn().mockResolvedValue(undefined),
172
173
  appState: ref(''),
173
174
  unsubscribe: () => {},
@@ -0,0 +1,46 @@
1
+ import { vi } from 'vitest'
2
+
3
+ /**
4
+ * Builds the mock `connect` client. Every service/method an app touches is
5
+ * auto-stubbed with a `vi.fn()` resolving `undefined` — which the mocked
6
+ * `useApi` turns back into the call site's declared default value — so app
7
+ * smoke tests don't have to enumerate the whole service surface just to keep
8
+ * `useApi(connect.x.y, …)` from dereferencing `undefined` at setup.
9
+ *
10
+ * Pass `overrides` only for the services whose return value a test asserts on
11
+ * (or that the app calls directly and post-processes). Override methods win;
12
+ * any sibling method the app also calls is still auto-stubbed. Stubs are cached,
13
+ * so repeated access returns the same `vi.fn()` instance (stable references for
14
+ * `toHaveBeenCalled` assertions and `useApi`).
15
+ */
16
+ export function createMockConnect(overrides: Record<string, any> = {}): Record<string, any> {
17
+ const services = new Map<string, any>()
18
+
19
+ const makeService = (seed: any): any => {
20
+ const methods = new Map<string, any>()
21
+ return new Proxy(seed && typeof seed === 'object' ? seed : {}, {
22
+ get(target, prop) {
23
+ if (typeof prop !== 'string' || prop === 'then' || prop in target)
24
+ return Reflect.get(target, prop)
25
+ if (!methods.has(prop))
26
+ methods.set(prop, vi.fn().mockResolvedValue(undefined))
27
+ return methods.get(prop)
28
+ },
29
+ })
30
+ }
31
+
32
+ return new Proxy({ httpClient: {}, ...overrides }, {
33
+ get(target, prop) {
34
+ // Pass through non-strings, `then` (thenable probing), and Object.prototype
35
+ // members (constructor/toString/hasOwnProperty/…) so host introspection and
36
+ // instanceof-style access behave normally — only real service names get stubbed.
37
+ if (typeof prop !== 'string' || prop === 'then' || prop in Object.prototype)
38
+ return Reflect.get(target, prop)
39
+ if (prop === 'httpClient')
40
+ return Reflect.get(target, prop) ?? {}
41
+ if (!services.has(prop))
42
+ services.set(prop, makeService(Reflect.get(target, prop)))
43
+ return services.get(prop)
44
+ },
45
+ })
46
+ }
package/lib/test/index.ts CHANGED
@@ -2,9 +2,12 @@ export { createMockAppContext, createTranslator, useApiMock } from './createMock
2
2
 
3
3
  export type { MockAppContext, MockColorMode } from './createMockAppContext'
4
4
 
5
- export { createTestPinia } from './createTestPinia'
6
-
7
- export { createTestRouter } from './createTestRouter'
5
+ // createTestPinia / createTestRouter / mockVueRouter are intentionally NOT
6
+ // re-exported here. createTestPinia / createTestRouter pull in @pinia/testing /
7
+ // vue-router (which iframe apps don't need); mockVueRouter is used inside a
8
+ // `vi.mock('vue-router', …)` factory and stays on its own subpath so the mock
9
+ // doesn't drag the whole barrel (and its side effects) in. Import each from its
10
+ // subpath: @antcde/component-library/test/{createTestPinia,createTestRouter,mockVueRouter}.
8
11
 
9
12
  export {
10
13
  createMockApi,
@@ -25,9 +28,6 @@ export type {
25
28
  MockSignalReturn,
26
29
  UserPreset,
27
30
  } from './mocks'
28
- export { mockVueRouter } from './mockVueRouter'
29
-
30
- export type { MockVueRouterOverrides } from './mockVueRouter'
31
31
  export { mountApp } from './mountApp'
32
32
 
33
33
  export type { MountAppOptions } from './mountApp'
@@ -18,9 +18,9 @@ export interface MountWithContextOptions {
18
18
  * without needing a per-test `vi.mock('@/plugins/context')`.
19
19
  */
20
20
  mockContext?: MockAppContext
21
- /** Pinia instance — typically from `createTestPinia()`. Opt-in. */
21
+ /** Pinia instance (opt-in) — from `createTestPinia()` (`@antcde/component-library/test/createTestPinia`). */
22
22
  pinia?: Plugin
23
- /** Router instance — typically from `createTestRouter()`. Opt-in. */
23
+ /** Router instance (opt-in) — from `createTestRouter()` (`@antcde/component-library/test/createTestRouter`). */
24
24
  router?: Plugin
25
25
  props?: Record<string, any>
26
26
  slots?: MountingOptions<any>['slots']
@@ -100,15 +100,10 @@ export function testAppSetup(
100
100
  wrapper.unmount()
101
101
  })
102
102
 
103
- it('useApi resolves connect service mocks', async () => {
103
+ it('survives a full async mount (on-mount fetches resolve without crashing)', async () => {
104
104
  const wrapper = mountApp()
105
105
  await flushPromises()
106
106
  expect(wrapper.vm).toBeTruthy()
107
-
108
- const services = Object.entries(mockContext.comms.connect)
109
- .filter(([key]) => key !== 'httpClient')
110
- expect(services.length).toBeGreaterThan(0)
111
-
112
107
  wrapper.unmount()
113
108
  })
114
109
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/component-library",
3
3
  "type": "module",
4
- "version": "0.1.14-rc.fd98dae",
4
+ "version": "0.1.15-rc.70c625c",
5
5
  "description": "Helper to use ant components in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "exports": {
@@ -39,6 +39,12 @@
39
39
  "./test/mockVueRouter": {
40
40
  "import": "./lib/test/mockVueRouter.ts"
41
41
  },
42
+ "./test/createTestPinia": {
43
+ "import": "./lib/test/createTestPinia.ts"
44
+ },
45
+ "./test/createTestRouter": {
46
+ "import": "./lib/test/createTestRouter.ts"
47
+ },
42
48
  "./lib/ForgeViewer": {
43
49
  "import": "./lib/ForgeViewer/index.ts"
44
50
  },
@@ -160,8 +166,8 @@
160
166
  }
161
167
  },
162
168
  "dependencies": {
163
- "@antcde/connect-ts": "0.4.18-rc.fd98dae",
164
- "@antcde/vue-utils": "0.2.14-rc.fd98dae",
169
+ "@antcde/connect-ts": "0.4.18-rc.70c625c",
170
+ "@antcde/vue-utils": "0.2.14-rc.70c625c",
165
171
  "@arcgis/core": "^4.34.8",
166
172
  "@mdi/font": "^7.4.47",
167
173
  "@tiptap/extension-link": "^3.26.1",
@@ -200,6 +206,7 @@
200
206
  "vite-plugin-dts": "^4.5.4",
201
207
  "vite-plugin-vuetify": "^2.1.3",
202
208
  "vitest": "^4.1.9",
209
+ "vue": "^3.5.38",
203
210
  "vue-tsc": "^3.3.5"
204
211
  }
205
212
  }