Fix/typecheck test #601

Merged
k88936 merged 11 commits from fix/typecheck-test into master 2026-10-03 21:05:43 +08:00
Member
No description provided.
k88936 added 3 commits 2026-10-03 17:55:01 +08:00
- 按 vitest 0.34 的参数元组口径改写 mock 泛型
- 修正 noUncheckedIndexedAccess 下的下标访问
- 补齐与当前类型脱节的测试桩字段
- 按 scripts/*.mjs 的运行时契约补局部类型声明
- 新增 apps/ai-game-creator-shell/tsconfig.tests.json,覆盖 src、tests 与 vite.config.ts
- 新增 check:tests:types 脚本执行 tsc -p tsconfig.tests.json --noEmit
- 将 check:tests:types 并入 AGC 的 typecheck
文档:记录 AGC 测试类型门禁与 Node 环境口径
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 5m15s
Project CI / Backend tests (pull_request) Failing after 23s
Project CI / AI game creator shell Rust crates (pull_request) Failing after 2m47s
Project CI / Repository checks (pull_request) Failing after 38s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 5m20s
Project CI / Frontend tests (pull_request) Successful in 2m38s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m12s
Project CI / Native shell tests (pull_request) Successful in 6m52s
2922b94594
- development-workflow 增补 AGC 测试类型门禁一节
- pitfalls 记录测试未进 tsconfig 时类型断言为空写的经验
- pitfalls 记录 Node 24+ Web Storage 顶掉 jsdom localStorage 的环境口径
k88936 added 1 commit 2026-10-03 18:41:30 +08:00
Merge branch 'master' into fix/typecheck-test
Project CI / AI game creator shell Rust crates (pull_request) Successful in 3m4s
Project CI / Backend tests (pull_request) Failing after 4m30s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 4m43s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 5m23s
Project CI / Frontend tests (pull_request) Successful in 3m21s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m17s
Project CI / Repository checks (pull_request) Failing after 4m28s
Project CI / Native shell tests (pull_request) Successful in 7m43s
88abe52c3d
k88936 added 5 commits 2026-10-03 19:37:05 +08:00
- 「渲染函数子节点改编进 props」改为「改传进 props」
- asTauriListen 形参返回类型由 Promise<unknown> 改为 Promise<() => void>,与 TauriListen 的 unlisten 契约一致
- 合并 chat-composer / project-conversation / project-development / runtime-settings / design-agent 五处重复的 installTauriRuntime 定义为 harness 中一处
- 安装参数由 unknown 收成可调用下界并声明 event 可缺省,非函数的误装会在编译期被挡下
- design-agent 改为薄适配 installChatRuntime,调用点与运行时行为不变
- harness 新增 createTauriEventBridge,只负责事件登记与派发,不碰 window、不做类型转换
- home.suite 44 处内联 window.__TAURI__ 赋值改为 installTauriRuntime,并删除 asTauriInvoke / asTauriListen 两个适配器
- auth.suite 删除 installTauriBridge 的 as never,改为 createTauriEventBridge + installTauriRuntime 组合
Merge remote-tracking branch 'origin/master' into fix/typecheck-test
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m30s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 5m2s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 3m46s
Project CI / Frontend tests (pull_request) Successful in 3m20s
Project CI / Backend tests (pull_request) Failing after 4m41s
Project CI / Repository checks (pull_request) Failing after 3m59s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m34s
Project CI / Native shell tests (pull_request) Successful in 7m16s
55cca04971
k88936 added 2 commits 2026-10-03 20:35:09 +08:00
- 新增 tests/tauriRuntimeFake.ts,作为唯一的 window.__TAURI__ 安装点与类型转换点,并提供 createTauriEventBridge 与 resetTauriRuntime
- appSurface/harness.ts 改为从该模块导入并转出 installTauriRuntime / createTauriEventBridge,既有 ./harness 导入路径不变
- pickProjectFromLauncher 不再直接写 window.__TAURI__,改走 installTauriRuntime 保留原有 core/event
测试:全仓测试统一 Tauri 运行时替身安装点
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m58s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 6m34s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 5m29s
Project CI / Backend tests (pull_request) Failing after 4m38s
Project CI / Frontend tests (pull_request) Successful in 3m33s
Project CI / Repository checks (pull_request) Failing after 4m4s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m13s
Project CI / Native shell tests (pull_request) Successful in 6m35s
25c5ecdf6e
- 78 处内联 window.__TAURI__ 赋值改为 installTauriRuntime,覆盖 appSurface 之外的 37 个测试文件
- 31 处 delete window.__TAURI__ / window.__TAURI__ = undefined 复位改为 resetTauriRuntime
- 删除 recentProjectsHook、projectCreationDirectory、projectResourceLiveIntegration、useProjectResourceCardPreviews、resourceVersionReplacementModel、unityProjectOpen 里的本地 asTauriInvoke / asTauriListen 适配器与相关类型别名
- designProjectRestore 的 setup 参数由 ReturnType<typeof vi.fn> 收窄为具体 invoke 签名
- 迁移后仅 tests/tauriRuntimeFake.ts 直接读写 window.__TAURI__
Author
Member
  • 1. tests/appSurface/chat-composer.suite.ts:49-54 —— installTauriRuntime 在多个 suite 重复

    • 现状:chat-composer 与 project-conversation 各自定义逐字相同的 installTauriRuntime({ core: { invoke: unknown }; event?: { listen: unknown } });project-development / runtime-settings 是 core-only 版本;design-agent 是收 ChatRuntimeHarness 的版本。
    • 问题:同一份"装 Tauri 替身"契约散在 5 个文件,签名还各不相同;以后改 Tauri 类型或改转换方式要同时动 5 处,必然漂移。
    • 建议:把转换点收进 tests/appSurface/harness.ts,各 suite 复用。
    • 结论:已修。commit 6efab1074。
  • 2. tests/appSurface/design-agent.suite.ts:25-30 —— 5 个 suite 各自定义、签名分歧

    • 现状/问题:同第 1 项;design-agent 的版本总是装 event.listen,project-conversation 的 event 可选,project-development / runtime-settings 只收 core.invoke。
    • 建议:抽一个共享 helper,未来只改一处。
    • 结论:已修(同 6efab1074)。5 处本地定义全部删除,installTauriRuntime 定义只剩 harness.ts 一处;design-agent 保留一个不含 cast 的薄适配 installChatRuntime(harness)。
  • 3. tests/appSurface/home.suite.ts:42-44 —— 三种 mock 适配写法

    • 现状(修前):home.suite 用 asTauriInvoke / asTauriListen 两个适配器,44 处内联 window.__TAURI__ = { core: { invoke: asTauriInvoke(...) } };runtime-settings 用 installTauriRuntime + 整体 as unknown as Window['__TAURI__'];auth.suite 的 installTauriBridge(invoke, { withEvents }) 用 as never,并返回 { listeners, emit } 事件桥。
    • 问题:三种转换策略并存;as never 完全绕过类型检查,home 的 44 处也各自在调用点转换,安装点不唯一。review 说的"抽一个 installer 全复用"只对一半——installTauriBridge 的返回值是事件桥,asTauriInvoke / asTauriListen 是逐调用点适配器而非安装器。
    • 建议(已采纳 B 方案):安装器只负责安装,harness.installTauriRuntime 是全仓唯一 cast 点;事件桥拆成纯工具 harness.createTauriEventBridge(只登记/派发,不碰 window、不 cast)再组合。不要给安装器加 withEvents 之类的模式开关——flag argument + void | Bridge 联合返回更脏。
    • 结论:已修。commit 179983b82。home.suite 44 处改为 installTauriRuntime({...}) 并删除两个适配器;auth.suite 删除 installTauriBridge 的 as never,改为 createTauriEventBridge() + installTauriRuntime(...)。appSurface 内已无 as never / asTauriInvoke / asTauriListen。
  • 4. tests/appSurface/home.suite.ts:50-53 —— asTauriListen 形参返回 Promise<unknown>

    • 现状:asTauriListen(listen: (event, handler) => Promise<unknown>): TauriListen。
    • 问题:TauriListen 的真实返回是 Promise<() => void>(unlisten);写成 Promise<unknown> 把 unlisten 契约从形参上抹掉了,还多一次 unknown 往返。
    • 建议:形参返回类型写成 Promise<() => void>。
    • 结论:已修。所有调用点都是 harness 的 listen(返回 Promise<() => void>),tsc 通过。commit a83525c96。
  • 5. tests/appSurface/runtime-settings.suite.ts:28-30 —— 参数只收 core,却 cast 成完整窗口形状

    • 现状:installTauriRuntime(runtime: { core: { invoke: unknown } }) 后整体 cast。
    • 问题:参数比真实窗口形状窄,安装点没有表达"调用方可能装 event"。不过 review 里"未来读 window.__TAURI__.event 会 type-check 却 undefined"这半句不准确:Window['__TAURI__'] 声明的 core / event 本来都是可选的,读它 TS 会要求可选链;真正成立的是参数类型偏窄。
    • 建议:参数放宽为可缺省的 event。
    • 结论:已修。共享安装器现在是 { core?: { invoke?: ... }; event?: { listen?: ... } }。commit 6efab1074。
  • 6. tests/appSurface/auth.suite.ts:71 —— 注释错别字

    • 现状:渲染函数子节点改编进 props。
    • 问题:「改编进」不成词,此处语义是"把渲染函数作为 children 传进 props"。
    • 建议:改为「改传进」。
    • 结论:已修。commit 19c6b1dfc。
  • 7. tests/appSurface/runtime-settings.suite.ts:28 —— invoke: unknown 过松

    • 现状:core: { invoke: unknown }。
    • 问题:字符串、undefined 都能编译通过并被装成运行时 invoke;安装点本应做类型收敛。
    • 建议:收成可调用签名。
    • 结论:已修。共享安装器的 invoke 收成 (command: string, args?: Record<string, unknown>) => Promise<unknown>,listen 收成 (event, handler) => Promise<() => void>;vi.fn 与各夹具的具体 mock 均可赋值。commit 6efab1074。
- [x] 1. `tests/appSurface/chat-composer.suite.ts:49-54` —— `installTauriRuntime` 在多个 suite 重复 - 现状:`chat-composer` 与 `project-conversation` 各自定义逐字相同的 `installTauriRuntime({ core: { invoke: unknown }; event?: { listen: unknown } })`;`project-development` / `runtime-settings` 是 core-only 版本;`design-agent` 是收 `ChatRuntimeHarness` 的版本。 - 问题:同一份"装 Tauri 替身"契约散在 5 个文件,签名还各不相同;以后改 Tauri 类型或改转换方式要同时动 5 处,必然漂移。 - 建议:把转换点收进 `tests/appSurface/harness.ts`,各 suite 复用。 - 结论:已修。commit `6efab1074`。 - [x] 2. `tests/appSurface/design-agent.suite.ts:25-30` —— 5 个 suite 各自定义、签名分歧 - 现状/问题:同第 1 项;`design-agent` 的版本总是装 `event.listen`,`project-conversation` 的 event 可选,`project-development` / `runtime-settings` 只收 `core.invoke`。 - 建议:抽一个共享 helper,未来只改一处。 - 结论:已修(同 `6efab1074`)。5 处本地定义全部删除,`installTauriRuntime` 定义只剩 `harness.ts` 一处;`design-agent` 保留一个不含 cast 的薄适配 `installChatRuntime(harness)`。 - [x] 3. `tests/appSurface/home.suite.ts:42-44` —— 三种 mock 适配写法 - 现状(修前):`home.suite` 用 `asTauriInvoke` / `asTauriListen` 两个适配器,44 处内联 `window.__TAURI__ = { core: { invoke: asTauriInvoke(...) } }`;`runtime-settings` 用 `installTauriRuntime` + 整体 `as unknown as Window['__TAURI__']`;`auth.suite` 的 `installTauriBridge(invoke, { withEvents })` 用 `as never`,并返回 `{ listeners, emit }` 事件桥。 - 问题:三种转换策略并存;`as never` 完全绕过类型检查,home 的 44 处也各自在调用点转换,安装点不唯一。review 说的"抽一个 installer 全复用"只对一半——`installTauriBridge` 的返回值是事件桥,`asTauriInvoke` / `asTauriListen` 是逐调用点适配器而非安装器。 - 建议(已采纳 B 方案):安装器只负责安装,`harness.installTauriRuntime` 是全仓唯一 cast 点;事件桥拆成纯工具 `harness.createTauriEventBridge`(只登记/派发,不碰 window、不 cast)再组合。不要给安装器加 `withEvents` 之类的模式开关——flag argument + `void | Bridge` 联合返回更脏。 - 结论:已修。commit `179983b82`。`home.suite` 44 处改为 `installTauriRuntime({...})` 并删除两个适配器;`auth.suite` 删除 `installTauriBridge` 的 `as never`,改为 `createTauriEventBridge()` + `installTauriRuntime(...)`。appSurface 内已无 `as never` / `asTauriInvoke` / `asTauriListen`。 - [x] 4. `tests/appSurface/home.suite.ts:50-53` —— `asTauriListen` 形参返回 `Promise<unknown>` - 现状:`asTauriListen(listen: (event, handler) => Promise<unknown>): TauriListen`。 - 问题:`TauriListen` 的真实返回是 `Promise<() => void>`(unlisten);写成 `Promise<unknown>` 把 unlisten 契约从形参上抹掉了,还多一次 `unknown` 往返。 - 建议:形参返回类型写成 `Promise<() => void>`。 - 结论:已修。所有调用点都是 harness 的 `listen`(返回 `Promise<() => void>`),tsc 通过。commit `a83525c96`。 - [x] 5. `tests/appSurface/runtime-settings.suite.ts:28-30` —— 参数只收 core,却 cast 成完整窗口形状 - 现状:`installTauriRuntime(runtime: { core: { invoke: unknown } })` 后整体 cast。 - 问题:参数比真实窗口形状窄,安装点没有表达"调用方可能装 event"。不过 review 里"未来读 `window.__TAURI__.event` 会 type-check 却 undefined"这半句不准确:`Window['__TAURI__']` 声明的 `core` / `event` 本来都是可选的,读它 TS 会要求可选链;真正成立的是参数类型偏窄。 - 建议:参数放宽为可缺省的 `event`。 - 结论:已修。共享安装器现在是 `{ core?: { invoke?: ... }; event?: { listen?: ... } }`。commit `6efab1074`。 - [x] 6. `tests/appSurface/auth.suite.ts:71` —— 注释错别字 - 现状:`渲染函数子节点改编进 props`。 - 问题:「改编进」不成词,此处语义是"把渲染函数作为 children 传进 props"。 - 建议:改为「改传进」。 - 结论:已修。commit `19c6b1dfc`。 - [x] 7. `tests/appSurface/runtime-settings.suite.ts:28` —— `invoke: unknown` 过松 - 现状:`core: { invoke: unknown }`。 - 问题:字符串、`undefined` 都能编译通过并被装成运行时 invoke;安装点本应做类型收敛。 - 建议:收成可调用签名。 - 结论:已修。共享安装器的 invoke 收成 `(command: string, args?: Record<string, unknown>) => Promise<unknown>`,listen 收成 `(event, handler) => Promise<() => void>`;`vi.fn` 与各夹具的具体 mock 均可赋值。commit `6efab1074`。
k88936 merged commit ccd2715726 into master 2026-10-03 21:05:43 +08:00
k88936 deleted branch fix/typecheck-test 2026-10-03 21:05:43 +08:00
Sign in to join this conversation.