Files
Genarrative/apps/ai-game-creator-shell/tests/designWorkspaceDebug.test.tsx
T
lhk229 77d3917d9c
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Has been cancelled
统一策划 Agent Debug 运行时开关
策划 Debug 日志与快速推进入口共用 GENARRATIVE_AGC_DESIGN_DEBUG。

通过 Tauri 查询构建与运行时状态,移除前端 VITE Debug 开关依赖。

更新开发启动器、策划工作区测试和技术方案文档。
2026-09-15 04:22:45 +00:00

65 lines
2.0 KiB
TypeScript

// @vitest-environment jsdom
import {
cleanup,
fireEvent,
render,
screen,
waitFor,
within,
} from '@testing-library/react';
import React from 'react';
import { afterEach, expect, it, vi } from 'vitest';
import { DesignWorkspacePanel } from '../src/features/project-workspace/DesignWorkspacePanel';
vi.mock('../src/components/ChatMarkdownMessage', () => ({
ChatMarkdownMessage: () => null,
}));
afterEach(() => {
cleanup();
vi.unstubAllEnvs();
delete window.__TAURI__;
});
it('prepares debug fixtures from the header and refreshes the phase and files without a manual refresh', async () => {
let prepared = false;
const invoke = vi.fn(async (command: string) => {
if (command === 'is_design_agent_debug_enabled') {
return true;
}
if (command === 'debug_fast_forward_design_session') {
prepared = true;
return { activeRuntime: 'design' };
}
if (command === 'hydrate_design_agent_session') {
return { session: { currentPhase: prepared ? 'consultant' : 'concept' } };
}
if (command === 'list_design_workspace') {
return prepared ? [{ path: 'debug.md', kind: 'file', size: 10 }] : [];
}
throw new Error(`Unexpected command: ${command}`);
});
window.__TAURI__ = { core: { invoke } } as unknown as typeof window.__TAURI__;
render(<DesignWorkspacePanel projectPath="test-project" />);
await waitFor(() =>
expect(
screen
.getByRole('button', { name: '刷新策划工作区' })
.hasAttribute('disabled'),
).toBe(false),
);
const header = screen
.getByRole('heading', { name: '概念设计' })
.closest('header')!;
fireEvent.click(
within(header).getByRole('button', { name: '快速准备做成游戏测试' }),
);
await screen.findByRole('heading', { name: '顾问' });
await screen.findByRole('button', { name: 'debug.md' });
expect(invoke).toHaveBeenCalledWith('debug_fast_forward_design_session', {
projectPath: 'test-project',
targetPhase: 'consultant',
});
});