085181c795
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m55s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m21s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 9m58s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 10m40s
Project CI / Backend tests (pull_request) Successful in 5m37s
Project CI / Native shell tests (pull_request) Successful in 7m30s
Project CI / Repository checks (pull_request) Successful in 3m46s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m22s
Project CI / Frontend tests (pull_request) Successful in 4m54s
Project CI / AI game creator shell Rust crates (push) Successful in 2m57s
Project CI / AI game creator shell Rust smoke (push) Successful in 3m51s
Project CI / Backend tests (push) Failing after 3m47s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 9m22s
Project CI / Native shell tests (push) Successful in 6m12s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 10m13s
Project CI / Frontend tests (push) Successful in 3m51s
Project CI / Repository checks (push) Successful in 2m44s
Project CI / AI game creator shell web tests (push) Successful in 2m25s
新增策划工作区文件导入命令,支持同名另存并保留文件字节 首页和聊天框附件直接导入策划工作区,脱离游戏资源清单与回合附件 导入期间暂缓发送、阶段操作和游戏制作切换,保留逐文件失败提示 补充导入、刷新与切换回归测试,同步技术方案和共享约定
120 lines
3.7 KiB
TypeScript
120 lines
3.7 KiB
TypeScript
// @vitest-environment jsdom
|
|
import {
|
|
act,
|
|
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('shows imported references after a workspace event without reloading the design session', async () => {
|
|
let imported = false;
|
|
let onUpdate:
|
|
| ((event: { payload: { projectPath: string; kind: string } }) => void)
|
|
| undefined;
|
|
const invoke = vi.fn(async (command: string) => {
|
|
if (command === 'is_design_agent_debug_enabled') return false;
|
|
if (command === 'hydrate_design_agent_session') return null;
|
|
if (command === 'list_design_workspace')
|
|
return imported
|
|
? [
|
|
{ path: 'references', kind: 'directory' },
|
|
{ path: 'references/需求.md', kind: 'file' },
|
|
]
|
|
: [];
|
|
if (command === 'read_design_workspace_file') return '# 导入的需求';
|
|
throw new Error(`Unexpected command: ${command}`);
|
|
});
|
|
window.__TAURI__ = {
|
|
core: { invoke },
|
|
event: {
|
|
listen: vi.fn(async (_name, callback) => {
|
|
onUpdate = callback;
|
|
return () => undefined;
|
|
}),
|
|
},
|
|
} as unknown as typeof window.__TAURI__;
|
|
render(<DesignWorkspacePanel projectPath="imported-project" />);
|
|
await waitFor(() => expect(onUpdate).toBeDefined());
|
|
await waitFor(() =>
|
|
expect(invoke).toHaveBeenCalledWith('list_design_workspace', {
|
|
projectPath: 'imported-project',
|
|
}),
|
|
);
|
|
imported = true;
|
|
act(() =>
|
|
onUpdate!({
|
|
payload: { projectPath: 'imported-project', kind: 'workspace' },
|
|
}),
|
|
);
|
|
fireEvent.click(await screen.findByRole('button', { name: '需求.md' }));
|
|
await waitFor(() =>
|
|
expect(invoke).toHaveBeenCalledWith('read_design_workspace_file', {
|
|
projectPath: 'imported-project',
|
|
path: 'references/需求.md',
|
|
}),
|
|
);
|
|
expect(
|
|
invoke.mock.calls.filter(
|
|
([command]) => command === 'hydrate_design_agent_session',
|
|
),
|
|
).toHaveLength(1);
|
|
});
|
|
|
|
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',
|
|
});
|
|
});
|