Files
Genarrative/apps/ai-game-creator-shell/tests/homeCreationFailure.test.ts
T
kdletters e3b4127440
Project CI / AI game creator shell Rust crates (push) Successful in 1m52s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m47s
Project CI / Backend tests (push) Failing after 4m0s
Project CI / Frontend tests (push) Successful in 1m59s
Project CI / Native shell tests (push) Successful in 6m19s
Project CI / Repository checks (push) Successful in 2m43s
Project CI / AI game creator shell web tests (push) Successful in 1m47s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 11m5s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 11m19s
统一 AGC 失败兜底口径:兜底只用专用错误码与专用文案
新增 homeCreationFailure 统一创建失败出口:宿主机器码 / IPC 失联 / 专用未分类兜底三种文案,宿主原始文本改为 appendWebviewLog 落 application.log 而不上屏
首页创建失败不再无条件覆盖成「创建未完成,请重试」,也不再写死「首条需求投递失败」指认某一步;工作区已建好时保留该事实并提供「已创建的工作区」恢复说法
宿主预检按真实原因分流浏览器验证错误码(browser-missing / launch-timeout / launch-failed / cancelled / browser-cleanup-failed / browser-environment-failed / evidence-failed / input-invalid / page-check-failed),未识别落回专用 web-preflight-unclassified
依赖准备收据保留宿主返回的真实失败码,不再一律写成 web-scaffold-preparation-failed
直连回合失败分类器 else 改为专用 runtime-unclassified,并补 sidecar-turn-timeout / sidecar-launch-failed / app-server-launch-failed / claude-code-failed 四个有证据的具体码
Codex CLI 与 Claude sidecar 的进程启动失败保留真实 OS 错误,不再报成「不支持 app-server 子命令」或「Node runtime 不可用」
更新检查新增结果型入口 checkForAppUpdateResult,「关于」页检查失败显示真实原因而不是「当前已是最新版本」
首页无码预检兜底文案不再写「请检查 Node/npm 或浏览器」这类未证实的候选原因
同步 pitfalls 六条与团队约定:兜底码/兜底文案规则、五项修复的现象根因处理验证、测试夹具编译修复记录
验证:vitest homeCreationFailure/homeWebPreflight/appUpdate/appSurface 共 215 passed;cargo test environment_check:: 19 passed、agent::runtime_error:: 5 passed、direct_failure_diagnostic 4 passed、tests::configuration:: 45 passed;cargo fmt --check、tsc --noEmit、npm run typecheck、check:encoding、git diff --check 通过
2026-10-02 13:07:00 +08:00

83 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, it } from 'vitest';
import {
createHomeCreationFailure,
HOME_CREATION_AFTER_PROJECT_FAILURE,
HOME_CREATION_AFTER_PROJECT_IPC_FAILURE,
HOME_CREATION_IPC_FAILURE,
HOME_CREATION_UNCLASSIFIED_FAILURE,
HomeCreationFailure,
homeCreationFailureMessage,
resolveHomeCreationFailureMessage,
} from '../src/features/app-shell/homeCreationFailure';
it('宿主机器码原样显示,不落回通用文案', () => {
expect(
homeCreationFailureMessage(
new Error('项目已被其它操作改动:project-revision-conflict'),
),
).toBe('创建未完成(project-revision-conflict);请重试。');
expect(
homeCreationFailureMessage(new Error('web-build-timeout'), {
projectCreated: true,
}),
).toBe(
'工作区已创建;未能进入项目开发(web-build-timeout);请从「已创建的工作区」打开后重试。',
);
});
it('调用通道失联使用专用 IPC 文案,不冒充业务原因', () => {
expect(homeCreationFailureMessage(new Error('Failed to fetch'))).toBe(
HOME_CREATION_IPC_FAILURE,
);
expect(
homeCreationFailureMessage(
new Error(
'IPC custom protocol failed, Tauri will now use the postMessage interface instead TypeError: Failed to fetch',
),
{ projectCreated: true },
),
).toBe(HOME_CREATION_AFTER_PROJECT_IPC_FAILURE);
});
it('拿不到任何机器码时使用专用兜底,并按是否已建好工作区分文案', () => {
expect(homeCreationFailureMessage(new Error('自动创建测试结束'))).toBe(
HOME_CREATION_UNCLASSIFIED_FAILURE,
);
expect(homeCreationFailureMessage(undefined)).toBe(
HOME_CREATION_UNCLASSIFIED_FAILURE,
);
expect(
homeCreationFailureMessage(new Error('design runtime unavailable'), {
projectCreated: true,
}),
).toBe(HOME_CREATION_AFTER_PROJECT_FAILURE);
});
it('宿主原始文本只进诊断,不进用户文案', () => {
const failure = createHomeCreationFailure(
new Error('Provider 返回 500:https://provider.example/private'),
{ projectCreated: false },
);
expect(failure).toBeInstanceOf(HomeCreationFailure);
expect(failure.userMessage).toBe(HOME_CREATION_UNCLASSIFIED_FAILURE);
expect(failure.diagnostic).toBe(
'Provider 返回 500:https://provider.example/private',
);
});
it('首页出口只认控制器包装过的文案,未知值落回专用兜底', () => {
const failure = createHomeCreationFailure(
new Error('project-revision-conflict'),
);
expect(resolveHomeCreationFailureMessage(failure)).toBe(
'创建未完成(project-revision-conflict);请重试。',
);
expect(resolveHomeCreationFailureMessage(new Error('自动创建测试结束'))).toBe(
HOME_CREATION_UNCLASSIFIED_FAILURE,
);
expect(resolveHomeCreationFailureMessage(undefined)).toBe(
HOME_CREATION_UNCLASSIFIED_FAILURE,
);
});