fix: refine coding project landing actions

This commit is contained in:
inman
2026-09-06 15:45:22 +08:00
parent de8ce283dd
commit faf751be5e
10 changed files with 307 additions and 117 deletions

View File

@@ -60,6 +60,12 @@ const project: CodingProjectSummary = {
updatedAt: '2026-08-23T00:00:00.000Z',
lastOpenedAt: '2026-08-23T00:00:00.000Z',
};
const secondProject: CodingProjectSummary = {
...project,
id: 'project-2',
name: 'Second local project',
lastOpenedAt: '2026-08-22T00:00:00.000Z',
};
const agent: CodingProjectAgent = {
id: 'agent-1',
avatarId: 'default',
@@ -199,15 +205,17 @@ describe('CodingChatPanel first Conversation', () => {
vi.resetModules();
});
it('shows a branded project starter before any local project is selected', async () => {
projectApi.list.mockResolvedValue({ projects: [], activeProjectId: null });
it('shows a branded create CTA and horizontal existing-project cards before a project is selected', async () => {
projectApi.list.mockResolvedValue({ projects: [project, secondProject], activeProjectId: null });
const onCreateProject = vi.fn();
const onOpenProject = vi.fn();
const onOpenProjectSettings = vi.fn();
const { CodingChatPanel } = await import('@/pages/Chat/CodingChatPanel');
render(
<CodingChatPanel
onCreateProject={onCreateProject}
onOpenProject={onOpenProject}
onOpenProjectSettings={onOpenProjectSettings}
/>,
);
@@ -215,13 +223,18 @@ describe('CodingChatPanel first Conversation', () => {
expect(await screen.findByTestId('coding-chat-empty-project')).toBeInTheDocument();
expect(screen.getByRole('heading', { name: '你想让麦洛和你一起构建什么?' })).toBeInTheDocument();
expect(screen.getByRole('img', { name: '麦洛 M 标识' })).toBeInTheDocument();
expect(screen.getByTestId('coding-project-starter')).toHaveTextContent('尚未选择项目');
expect(screen.getByRole('button', { name: '新增项目' })).toBeInTheDocument();
expect(screen.getByTestId('coding-existing-projects')).toHaveTextContent('Local project');
expect(screen.getByTestId('coding-existing-projects')).toHaveTextContent('Second local project');
expect(screen.queryByTestId('coding-project-starter')).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '项目与插件设置' })).not.toBeInTheDocument();
fireEvent.click(screen.getByTestId('coding-start-project-button'));
expect(onCreateProject).toHaveBeenCalledOnce();
fireEvent.click(screen.getByRole('button', { name: '项目与插件设置' }));
expect(onOpenProjectSettings).toHaveBeenCalledOnce();
fireEvent.click(screen.getByRole('button', { name: '进入项目 Second local project' }));
expect(onOpenProject).toHaveBeenCalledWith(secondProject.id);
expect(onOpenProjectSettings).not.toHaveBeenCalled();
});
it('makes the first-Conversation textarea editable while runtime metadata is held', async () => {