feat: redesign coding default entry

This commit is contained in:
inman
2026-09-06 15:07:19 +08:00
parent f8eee430f4
commit de8ce283dd
12 changed files with 334 additions and 28 deletions

View File

@@ -139,8 +139,12 @@ test.describe('Makelore module navigation without setup flow', () => {
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
await page.getByTestId('ai-module-option-programming').click();
await expect(page.getByTestId('main-layout')).toBeVisible();
await expect(page).toHaveURL(/\/chat$/);
await expect(page.getByText('请先新建项目')).toHaveCount(0);
await expect(page.getByText('一念成光,万物可创。')).toBeVisible();
await expect(page.getByRole('heading', { name: '你想让麦洛和你一起构建什么?' })).toBeVisible();
await expect(page.getByRole('img', { name: '麦洛 M 标识' })).toBeVisible();
await expect(page.getByTestId('coding-project-starter')).toBeVisible();
await expect(page.getByText('一念成光,万物可创。')).toHaveCount(0);
await expect(page.getByRole('img', { name: 'Makelore logo' })).toBeVisible();
await expect(page.getByTestId('sidebar-module-switcher-trigger')).toContainText('编程 Code');
await expect(page.getByTestId('sidebar-module-return-icon')).toBeVisible();
@@ -154,6 +158,12 @@ test.describe('Makelore module navigation without setup flow', () => {
await expect(page.getByTestId('game-asset-browser')).toHaveCount(0);
await expect(page.getByTestId('game-asset-review-summary')).toHaveCount(0);
await page.getByTestId('coding-start-project-button').click();
const createProjectDialog = page.getByRole('dialog', { name: '新建项目' });
await expect(createProjectDialog).toBeVisible();
await createProjectDialog.getByRole('button', { name: '取消' }).first().click();
await expect(page.getByRole('dialog', { name: '新建项目' })).toHaveCount(0);
await expect(page.getByTestId('sidebar-module-switcher')).toBeVisible();
const moduleHomeTrigger = page.getByTestId('sidebar-module-switcher-trigger');
await expect(moduleHomeTrigger).toHaveAttribute('aria-label', '返回首页');

View File

@@ -199,6 +199,31 @@ 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 });
const onCreateProject = vi.fn();
const onOpenProjectSettings = vi.fn();
const { CodingChatPanel } = await import('@/pages/Chat/CodingChatPanel');
render(
<CodingChatPanel
onCreateProject={onCreateProject}
onOpenProjectSettings={onOpenProjectSettings}
/>,
);
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('尚未选择项目');
fireEvent.click(screen.getByTestId('coding-start-project-button'));
expect(onCreateProject).toHaveBeenCalledOnce();
fireEvent.click(screen.getByRole('button', { name: '项目与插件设置' }));
expect(onOpenProjectSettings).toHaveBeenCalledOnce();
});
it('makes the first-Conversation textarea editable while runtime metadata is held', async () => {
projectApi.list.mockResolvedValue({ projects: [project], activeProjectId: project.id });
projectApi.config.mockResolvedValue({ project, config });
@@ -215,6 +240,8 @@ describe('CodingChatPanel first Conversation', () => {
const view = render(<CodingChatPanel />);
const textbox = await screen.findByRole('textbox');
expect(screen.getByRole('heading', { name: '你想让麦洛和你一起构建什么?' })).toBeInTheDocument();
expect(screen.getByRole('img', { name: '麦洛 M 标识' })).toBeInTheDocument();
expect(textbox).toBeEnabled();
expect(projectApi.create).toHaveBeenCalledOnce();
expect(conversationApi.snapshot).toHaveBeenCalledWith(conversation.id);
@@ -922,7 +949,7 @@ describe('CodingChatPanel first Conversation', () => {
target: { files },
});
expect(await screen.findByText('每条消息最多添加 16 张图片。')).toBeInTheDocument();
expect(screen.getAllByRole('img')).toHaveLength(16);
expect(screen.getAllByRole('img', { name: /^image-\d+\.png$/u })).toHaveLength(16);
expect(codingConversationStore.getState().entriesByConversationId[conversation.id])
.toMatchObject({ loadState: 'live', error: null });
await waitFor(() => expect(screen.getByRole('button', { name: '发送' })).toBeEnabled());