Files
caikai-assets/tests/unit/setup.ts
T
liujjandClaude Opus 5.5 2072c6780f
CI / build-and-test (push) Canceled after 0s
feat: 资产管理前端从管理端拆分为独立工程
以 ckcloudManage a44810c 为基础,只保留资产页面(台账、单据、基础数据、同步任务)、
登录/错误/个人资料等公共页面,以及资产单据“查看流程”用到的流程详情页;
统一登录应用编码默认 CK_ASSET,标题“资产管理”,本地端口 9090。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 03:44:26 -08:00

56 lines
1.5 KiB
TypeScript

import { setActivePinia } from 'pinia'
import { config } from '@vue/test-utils'
import { store } from '@/store'
// 业务模块在顶层调用 useXxxStore(),需在导入前激活全局 pinia(与 main.ts 中 setupStore 一致)
setActivePinia(store)
// jsdom 未实现 Web Locks;生产要求 HTTPS + navigator.locks,这里提供同名串行实现
if (!('locks' in navigator)) {
const queue = new Map<string, Promise<unknown>>()
Object.defineProperty(navigator, 'locks', {
configurable: true,
value: {
request: (name: string, callback: () => unknown) => {
const previous = queue.get(name) ?? Promise.resolve()
const next = previous.then(() => callback())
queue.set(
name,
next.catch(() => undefined)
)
return next
}
}
})
}
// element-plus 部分组件依赖 matchMedia / ResizeObserver
if (!window.matchMedia) {
window.matchMedia = (query: string) =>
({
matches: false,
media: query,
onchange: null,
addListener: () => undefined,
removeListener: () => undefined,
addEventListener: () => undefined,
removeEventListener: () => undefined,
dispatchEvent: () => false
}) as MediaQueryList
}
if (!('ResizeObserver' in window)) {
class ResizeObserverStub {
observe() {}
unobserve() {}
disconnect() {}
}
Object.defineProperty(window, 'ResizeObserver', { value: ResizeObserverStub })
}
config.global.stubs = { transition: false }
afterEach(() => {
localStorage.clear()
sessionStorage.clear()
})