Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

test(desktop-e2e): 默认复用跨运行的下载缓存,核心不再每次重下

hairyfaf58e8d4221f
diff --git a/test/e2e/desktop/boot.e2e.ts b/test/e2e/desktop/boot.e2e.ts
index 7de24392..279d996c 100644
--- a/test/e2e/desktop/boot.e2e.ts
+++ b/test/e2e/desktop/boot.e2e.ts
@@ -3,8 +3,9 @@
*
* 桌面壳层的职责只有一件:把 dsh 装起来、跑起来、嵌进来。因此桌面端只保留这一条 E2E,
* 断言四件事:
- * ① 进入下载:`startDesktopApp()` 默认给本次运行一个**独占空缓存**,装配必须真的下载
- * 并落盘(Node 运行时 + dsh 本体),断言据此观察;
+ * ① 进入下载:本用例显式 `coldCache: true` 要一份**独占空缓存**,装配必须真的下载
+ * 并落盘(Node 运行时 + dsh 本体),断言据此观察;`startDesktopApp()` 默认复用
+ * 跨运行的共享缓存(`$DSH_E2E_DOWNLOAD_CACHE_DIR`),核心不再每次重下;
* ② 内核启动:`get_runtime_info().service_url` 指向本机端口,且壳层挂出 iframe——
* `src/layout/components/iframe.tsx` 只在 `harness.serviceHealthy` 为真时挂载;
* ③ dsh 页面出现:进帧(跨域,靠仓库 vendor 补丁的 `ICoreWebView2Frame2::ExecuteScript`)
@@ -86,7 +87,7 @@ describe.skipIf(process.platform === 'darwin')('桌面端启动冒烟', () => {
let browser: WebdriverIO.Browser
beforeAll(async () => {
- app = await startDesktopApp()
+ app = await startDesktopApp({ coldCache: true })
browser = app.browser
// 尽早装壳层收集器:装配失败、iframe 加载失败都会在壳层留下痕迹
await browser.execute(collectPageErrors)
@@ -100,7 +101,8 @@ describe.skipIf(process.platform === 'darwin')('桌面端启动冒烟', () => {
})
it('TC-DSK-L3-01-001 进入下载装配后 dsh 内核启动、页面渲染且无报错', async () => {
- // ① 进入下载:本次运行独占的空缓存里必须落下 dsh 本体
+ // ① 进入下载:本用例显式要一份**独占空缓存**(`coldCache: true`),装配必须真的下载并落盘
+ // (`startDesktopApp()` 默认复用跨运行的共享缓存,核心不再每次重下)
// (Node 可能直接复用系统安装,`<cache>/runtime` 因此不保证存在,故不据此断言)
const cacheDir = app?.downloadCacheDir ?? ''
expect(existsSync(join(cacheDir, 'dependencies', 'dsh')), 'dsh 本体未落盘(装配没走下载)').toBe(true)
diff --git a/test/e2e/support/desktop-host.ts b/test/e2e/support/desktop-host.ts
index fdc9777a..ed5fe37f 100644
--- a/test/e2e/support/desktop-host.ts
+++ b/test/e2e/support/desktop-host.ts
@@ -93,11 +93,17 @@ export interface StartDesktopAppOptions {
/**
* 覆盖下载缓存根。
*
- * 默认是**本次运行独占的空目录**(`<home>/download-cache`):装配必然真的走一遍
- * 下载与落盘,跑完随 scratch home 一起删除,跨运行零残留。想让本地反复跑时复用
- * 已下好的 Node/dsh(省一次联网),传一个稳定目录即可。
+ * 默认**复用跨运行的共享缓存**(`$DSH_E2E_DOWNLOAD_CACHE_DIR`,缺省
+ * `<os.tmpdir()>/dsh-e2e-download-cache`):已下好的 Node/dsh 不再每次重下。
+ * 需要观察「装配真的走了一遍下载」的用例用 `coldCache`(或 `DSH_E2E_COLD_ASSEMBLY=1`)
+ * 退回「本次运行独占的空目录」。
*/
downloadCacheDir?: string
+ /**
+ * 本次运行使用空缓存:装配必然真的下载并落盘,跑完随 scratch home 一起删除。
+ * 等价于 `DSH_E2E_COLD_ASSEMBLY=1`。
+ */
+ coldCache?: boolean
/**
* 复用指定的隔离根(跨重启持久化用例)。
*
@@ -154,9 +160,13 @@ export async function startDesktopApp(options: StartDesktopAppOptions = {}): Pro
const home = options.homeDir ?? makeHome(keepHome)
ensureHomeDirs(home)
- // 默认独占空缓存:装配必须真的下载并落盘 Node/dsh,用例据此断言「进入了下载」。
- // 复用共享缓存会让「有没有下载」取决于上一次运行的运气,断言随之失去意义。
- const cacheDir = options.downloadCacheDir ?? join(home, 'download-cache')
+ // 默认复用跨运行的共享下载缓存:核心(Node/dsh)不再每次重下。只有显式 `coldCache`
+ // (或 `DSH_E2E_COLD_ASSEMBLY=1`)才退回本次运行独占的空目录,供「必须真的下载」的用例。
+ const coldCache = options.coldCache ?? process.env.DSH_E2E_COLD_ASSEMBLY === '1'
+ const cacheDir = options.downloadCacheDir
+ ?? (coldCache
+ ? join(home, 'download-cache')
+ : process.env.DSH_E2E_DOWNLOAD_CACHE_DIR ?? join(tmpdir(), 'dsh-e2e-download-cache'))
mkdirSync(cacheDir, { recursive: true })
const profile = join(home, 'home')