保留 Web 环境预检错误正文

展示脱敏后的宿主预检和 IPC 具体原因

补充环境预检错误回归测试
This commit is contained in:
kdletters
2026-10-05 17:28:47 +08:00
parent 1a1f3df951
commit 11cf7a49fc
2 changed files with 24 additions and 3 deletions
@@ -1,4 +1,5 @@
import type { ProjectStartMode, TauriInvoke } from '../../app/types';
import { visibleClientErrorMessage } from '../../services/errorReporting';
import type { HomeCreationType } from '../../view/home/useHomeDraftStore';
/**
@@ -28,12 +29,32 @@ function knownPreflightCode(value: unknown): string | undefined {
}
export function homeWebPreflightErrorMessage(value: unknown): string {
const visible = visibleClientErrorMessage(value, '');
if (
visible.startsWith('Web 游戏环境预检未通过(') ||
visible.startsWith(HOME_WEB_PREFLIGHT_IPC_FAILURE)
) {
return visible;
}
if (value instanceof Error && value.message === HOME_WEB_PREFLIGHT_FAILURE) {
return HOME_WEB_PREFLIGHT_FAILURE;
}
const code = knownPreflightCode(value);
if (code) return `Web 游戏环境预检未通过(${code});尚未开始生成。`;
return HOME_WEB_PREFLIGHT_IPC_FAILURE;
const safeDetail = visible
.replace(/Web 游戏环境预检未通过[::]?/u, '')
.replace(code ?? '', '')
.replace(/[;;]?\s*尚未启动生成[。.]?/u, '')
.replace(/^\s*[;::,,-]\s*/u, '')
.replace(/[;;]\s*$/u, '')
.trim();
if (code) {
return safeDetail
? `Web 游戏环境预检未通过(${code}):${safeDetail};尚未开始生成。`
: `Web 游戏环境预检未通过(${code});尚未开始生成。`;
}
return safeDetail
? `${HOME_WEB_PREFLIGHT_IPC_FAILURE}(${safeDetail})`
: HOME_WEB_PREFLIGHT_IPC_FAILURE;
}
function isHostPreflightError(value: unknown): boolean {
@@ -101,7 +101,7 @@ it('distinguishes an IPC failure from a host preflight failure', async () => {
'direct-build',
);
});
expect(status).toBe(HOME_WEB_PREFLIGHT_IPC_FAILURE);
expect(status).toBe(`${HOME_WEB_PREFLIGHT_IPC_FAILURE}(Failed to fetch)`);
expect(calls).toEqual([
'preflight_web_game_creation',
'preflight_web_game_creation',