DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
test: split the suite into vitest projects and archive the legacy shell tests
hairyf7e1c7c01d5e9
diff --git a/package.json b/package.jsonindex e4df3d24..28650d8b 100644--- a/package.json+++ b/package.json@@ -17,6 +17,8 @@"tauri": "tauri","release": "bumpp --pr","test": "vitest",+ "test:unit": "vitest --project unit",+ "test:e2e:plugin": "vitest --project e2e","lint": "eslint","knip": "knip","lint:fix": "eslint . --fix",diff --git a/test/backup.test.ts b/test/archive/backup.test.tssimilarity index 97%rename from test/backup.test.tsrename to test/archive/backup.test.tsindex 29776308..3a8d8787 100644--- a/test/backup.test.ts+++ b/test/archive/backup.test.ts@@ -1,11 +1,11 @@-import type { BackupSettings } from '../src/utils/backup-settings'+import type { BackupSettings } from '../../src/utils/backup-settings'import { readFileSync } from 'node:fs'import { describe, expect, it } from 'vitest'import {normalizeIntervalDays,normalizeRetentionCount,-} from '../src/utils/backup-settings'+} from '../../src/utils/backup-settings'describe('backup settings normalization', () => {it('keeps a valid interval as-is', () => {diff --git a/test/clipboard.test.ts b/test/archive/clipboard.test.tssimilarity index 96%rename from test/clipboard.test.tsrename to test/archive/clipboard.test.tsindex 4286379d..2724a042 100644--- a/test/clipboard.test.ts+++ b/test/archive/clipboard.test.ts@@ -1,7 +1,7 @@import { readFileSync } from 'node:fs'import { invoke } from '@tauri-apps/api/core'import { afterEach, describe, expect, it, vi } from 'vitest'-import { writeClipboardText } from '../src/utils/clipboard'+import { writeClipboardText } from '../../src/utils/clipboard'vi.mock('@tauri-apps/api/core', () => ({invoke: vi.fn(),diff --git a/test/clone-profile.test.ts b/test/archive/clone-profile.test.tssimilarity index 100%rename from test/clone-profile.test.tsrename to test/archive/clone-profile.test.tsdiff --git a/test/close-action.test.ts b/test/archive/close-action.test.tssimilarity index 98%rename from test/close-action.test.tsrename to test/archive/close-action.test.tsindex c708c93f..c3b219f6 100644--- a/test/close-action.test.ts+++ b/test/archive/close-action.test.ts@@ -4,7 +4,7 @@ import {CLOSE_ACTION_DEFAULT,CLOSE_ACTION_OPTIONS,normalizeCloseAction,-} from '../src/utils/close-action'+} from '../../src/utils/close-action'describe('close action normalization', () => {it('defaults to hiding in tray', () => {diff --git a/test/compat-iterator.test.ts b/test/archive/compat-iterator.test.tssimilarity index 100%rename from test/compat-iterator.test.tsrename to test/archive/compat-iterator.test.tsdiff --git a/test/core-version.test.ts b/test/archive/core-version.test.tssimilarity index 100%rename from test/core-version.test.tsrename to test/archive/core-version.test.tsdiff --git a/test/index.test.ts b/test/archive/index.test.tssimilarity index 98%rename from test/index.test.tsrename to test/archive/index.test.tsindex a43c453f..44cc5a9b 100644--- a/test/index.test.ts+++ b/test/archive/index.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { containsInotifyLimitError, formatLogLine, pickErrorLines } from '../src/components/logs.utils'+import { containsInotifyLimitError, formatLogLine, pickErrorLines } from '../../src/components/logs.utils'describe('formatLogLine', () => {it('strips the official GitHub release download prefix', () => {diff --git a/test/internal-plugin-phase.test.ts b/test/archive/internal-plugin-phase.test.tssimilarity index 87%rename from test/internal-plugin-phase.test.tsrename to test/archive/internal-plugin-phase.test.tsindex 727d3070..6ae87d95 100644--- a/test/internal-plugin-phase.test.ts+++ b/test/archive/internal-plugin-phase.test.ts@@ -1,8 +1,8 @@-import type { InternalPluginsPhasePayload } from '../src/store/modules/harness'+import type { InternalPluginsPhasePayload } from '../../src/store/modules/harness'import { readFileSync } from 'node:fs'import { describe, expect, it } from 'vitest'-import { INTERNAL_PLUGIN_PHASE_DETAILS } from '../src/store/modules/harness'-import { internalPluginReason } from '../src/store/modules/harness/utils'+import { INTERNAL_PLUGIN_PHASE_DETAILS } from '../../src/store/modules/harness'+import { internalPluginReason } from '../../src/store/modules/harness/utils'function translate(key: string): string {return keydiff --git a/test/menu-restart.test.ts b/test/archive/menu-restart.test.tssimilarity index 100%rename from test/menu-restart.test.tsrename to test/archive/menu-restart.test.tsdiff --git a/test/patch-layer.test.ts b/test/archive/patch-layer.test.tssimilarity index 99%rename from test/patch-layer.test.tsrename to test/archive/patch-layer.test.tsindex 1b8ce836..d9a4aa28 100644--- a/test/patch-layer.test.ts+++ b/test/archive/patch-layer.test.ts@@ -8,7 +8,7 @@ import {patchEntryUnresolvedEntries,patchLayerErrorDetail,quarantineFailureDetail,-} from '../src/store/modules/harness/patch-layer'+} from '../../src/store/modules/harness/patch-layer'/*** issue #525:用户手写的 `cordis.patch.yml` 解析失败时,启动失败信息里的真实diff --git a/test/pet-asset-headers.test.ts b/test/archive/pet-asset-headers.test.tssimilarity index 100%rename from test/pet-asset-headers.test.tsrename to test/archive/pet-asset-headers.test.tsdiff --git a/test/pet-window-lifecycle.test.ts b/test/archive/pet-window-lifecycle.test.tssimilarity index 100%rename from test/pet-window-lifecycle.test.tsrename to test/archive/pet-window-lifecycle.test.tsdiff --git a/test/plugin-boot.test.ts b/test/archive/plugin-boot.test.tssimilarity index 100%rename from test/plugin-boot.test.tsrename to test/archive/plugin-boot.test.tsdiff --git a/test/plugin-disable.test.ts b/test/archive/plugin-disable.test.tssimilarity index 100%rename from test/plugin-disable.test.tsrename to test/archive/plugin-disable.test.tsdiff --git a/test/plugin-resource-closure.test.ts b/test/archive/plugin-resource-closure.test.tssimilarity index 100%rename from test/plugin-resource-closure.test.tsrename to test/archive/plugin-resource-closure.test.tsdiff --git a/test/plugin-uninstall.test.ts b/test/archive/plugin-uninstall.test.tssimilarity index 100%rename from test/plugin-uninstall.test.tsrename to test/archive/plugin-uninstall.test.tsdiff --git a/test/preinstall-uncheck.test.ts b/test/archive/preinstall-uncheck.test.tssimilarity index 100%rename from test/preinstall-uncheck.test.tsrename to test/archive/preinstall-uncheck.test.tsdiff --git a/test/readiness.test.ts b/test/archive/readiness.test.tssimilarity index 99%rename from test/readiness.test.tsrename to test/archive/readiness.test.tsindex 7849fb9c..2d46684c 100644--- a/test/readiness.test.ts+++ b/test/archive/readiness.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { BoundedReloadGate, pollReadiness, SingleFlight, waitForActivityTask } from '../src/store/modules/harness/readiness'+import { BoundedReloadGate, pollReadiness, SingleFlight, waitForActivityTask } from '../../src/store/modules/harness/readiness'function noWait(): Promise<void> {return Promise.resolve()diff --git a/test/release-identity.test.ts b/test/archive/release-identity.test.tssimilarity index 98%rename from test/release-identity.test.tsrename to test/archive/release-identity.test.tsindex 0cc9f4d3..1d4835f1 100644--- a/test/release-identity.test.ts+++ b/test/archive/release-identity.test.ts@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os'import path from 'node:path'import { fileURLToPath } from 'node:url'import { afterEach, describe, expect, it } from 'vitest'-import * as releaseIdentityModule from '../scripts/release-identity.mjs'+import * as releaseIdentityModule from '../../scripts/release-identity.mjs'interface SemverIdentity {version: stringdiff --git a/test/runtime-exit-store.test.ts b/test/archive/runtime-exit-store.test.tssimilarity index 100%rename from test/runtime-exit-store.test.tsrename to test/archive/runtime-exit-store.test.tsdiff --git a/test/runtime-exit.test.ts b/test/archive/runtime-exit.test.tssimilarity index 97%rename from test/runtime-exit.test.tsrename to test/archive/runtime-exit.test.tsindex 18ee96b4..5dae0bba 100644--- a/test/runtime-exit.test.ts+++ b/test/archive/runtime-exit.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { runtimeExitMessageKey, shouldAcceptRuntimeExit } from '../src/store/modules/harness/runtime'+import { runtimeExitMessageKey, shouldAcceptRuntimeExit } from '../../src/store/modules/harness/runtime'describe('runtime exit acceptance', () => {const current = {diff --git a/test/setup-copy-logs.test.ts b/test/archive/setup-copy-logs.test.tssimilarity index 100%rename from test/setup-copy-logs.test.tsrename to test/archive/setup-copy-logs.test.tsdiff --git a/test/toast.test.ts b/test/archive/toast.test.tssimilarity index 97%rename from test/toast.test.tsrename to test/archive/toast.test.tsindex 9037fd6f..0c26a0b9 100644--- a/test/toast.test.ts+++ b/test/archive/toast.test.ts@@ -1,5 +1,5 @@import { afterEach, describe, expect, it, vi } from 'vitest'-import { activeQueues as queues, toast } from '../src/utils/toast'+import { activeQueues as queues, toast } from '../../src/utils/toast'afterEach(() => {toast.clear()diff --git a/test/zoom.test.ts b/test/archive/zoom.test.tssimilarity index 99%rename from test/zoom.test.tsrename to test/archive/zoom.test.tsindex de70beb6..dd5abe77 100644--- a/test/zoom.test.ts+++ b/test/archive/zoom.test.ts@@ -6,7 +6,7 @@ import {zoomActionFromShortcut,zoomFactorFromLevel,zoomLevelFromFactor,-} from '../src/utils/zoom'+} from '../../src/utils/zoom'function shortcut(key: string,diff --git a/vite.config.ts b/vite.config.tsindex a956d55c..ecae4c9d 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -53,13 +53,4 @@ export default defineConfig(async () => ({ignored: ['**/src-tauri/**'],},},-- // Vitest 只跑工作区包、应用自有状态机与根 test(不含 source/* 参考子模块)。- test: {- include: [- 'packages/**/*.{test,spec}.?(c|m)[jt]s?(x)',- 'src/**/*.{test,spec}.?(c|m)[jt]s?(x)',- 'test/**/*.{test,spec}.?(c|m)[jt]s?(x)',- ],- },}))diff --git a/vitest.config.ts b/vitest.config.tsindex 1516d2b0..78b005e3 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -2,46 +2,25 @@ import { fileURLToPath } from 'node:url'import { defineConfig } from 'vitest/config'/**- * 根测试配置:运行内置插件(packages/**)及壳层状态机/入口契约回归测试,- * 限制并发 worker 数与放宽超时。+ * 根 Vitest 配置:只放「跨 project 的全局项」与 project 清单。*- * 仓库根还 vendored 了 dsh 核心源码(source/ 与 test/ 下的部分用例),其测试依赖- * dsh 核心的 `@/` paths 解析(在插件 workspace 的 vitest 下不可用),故 exclude 出- * 本范围;壳层自身的用例按文件显式列入 include。+ * Vitest 不把根配置本身当作 project(除非显式列出),因此这里不再写任何 include:+ * 用例归属由 `vitest.unit.config.ts`(单元)与 `vitest.e2e.config.ts`(E2E)各自声明。*- * dsh-tauri-worktree 的 operation.test 会创建真实 git 仓库(clone/checkout/- * discard),全量并行(默认 cpu-1 个 worker)时与其他文件的 git 操作竞争系统- * 资源,偶发 5s 超时 flake;限制 maxWorkers 后单独复跑稳定通过。+ * 仓库根还 vendored 了 dsh 核心源码(`source/` 与 `archive/`),其测试依赖 dsh 核心的+ * `@/` paths 解析(在插件 workspace 的 vitest 下不可用),故两个 project 都不纳入。*/export default defineConfig({- // 与 vite.config.ts 保持一致:src 内部统一用 `@/` 别名,测试入口也必须能解析。+ // 与 vite.config.ts 保持一致:src 内部统一用 `@/` 别名。resolve: {alias: {'@': fileURLToPath(new URL('./src', import.meta.url)),},},test: {- include: [- 'packages/**/*.{test,spec}.{ts,tsx,js,mjs,cjs}',- 'test/toast.test.ts',- // issue #469:桌面端不得持有屏幕唤醒锁(壳层用 reause useWakeLock 释放,桌宠 <video> 会间接加锁)。- 'test/wake-lock.test.ts',- // issue #469:收起桌宠必须是销毁窗口(隐藏窗口里的视频仍在播放并持锁)。- 'test/pet-window-lifecycle.test.ts',- // issue #525:补丁层 YAML 语法错误的识别与信息提取(纯函数回归)。- 'test/patch-layer.test.ts',- // issue #539:旧版 WebKit 缺全局 Iterator 导致插件加载失败,壳层兼容垫片回归。- 'test/compat-iterator.test.ts',- // issue #596:本地核心低于内置插件基线导致启动失败,核心面板与后端共用的版本判定回归。- 'test/core-version.test.ts',- // v0.2.0:气泡托管给 dsh-pet-component,宿主侧只剩「会话快照 → pet.bubble」的映射。- 'src/pet/hooks/use-bubble-tracker.test.ts',- // 桌宠素材响应头:GitHub 对中文动画名回 `content-disposition`,插件版 fetch 会因- // 非 ISO-8859-1 抛错并静默不落 IndexedDB(pnpm patch 过滤该头,这里锁住契约)。- 'test/pet-asset-headers.test.ts',+ projects: [+ './vitest.unit.config.ts',+ './vitest.e2e.config.ts',],- maxWorkers: 4,- testTimeout: 30_000,- hookTimeout: 30_000,},})diff --git a/vitest.unit.config.ts b/vitest.unit.config.tsnew file mode 100644index 00000000..b500bcda--- /dev/null+++ b/vitest.unit.config.ts@@ -0,0 +1,31 @@+import { defineProject } from 'vitest/config'++/**+ * `unit` project:单元测试。+ *+ * 两条来源:+ * 1. 内置插件(`packages/**`)——测试与其覆盖的源码同目录、同名(`*.test.ts`);+ * 2. 壳层自身的用例——`test/unit/**` 与 `src/**` 下与逻辑同名的 `.test.ts`。+ *+ * `test/archive/**` 是历史用例的归档(只读参考,不参与任何 project)。+ *+ * 并发与超时:`dsh-tauri-worktree` 的 operation.test 会创建真实 git 仓库+ * (clone/checkout/discard),全量并行时与其他文件的 git 操作竞争系统资源,+ * 偶发 5s 超时 flake;限制 maxWorkers 后单独复跑稳定通过。+ *+ * E2E 用例(插件 `test` 目录下的 `.e2e.ts`)由 `vitest.e2e.config.ts` 负责,本 project 不收。+ */+export default defineProject({+ test: {+ name: 'unit',+ include: [+ 'packages/**/*.{test,spec}.{ts,tsx,js,mjs,cjs}',+ 'test/unit/**/*.test.ts',+ 'src/**/*.test.ts',+ ],+ exclude: ['test/archive/**', 'archive/**'],+ maxWorkers: 4,+ testTimeout: 30_000,+ hookTimeout: 30_000,+ },+})