fix: refine coding project landing actions
This commit is contained in:
@@ -1,6 +1,84 @@
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron';
|
||||
|
||||
async function seedInactiveCodingProjects(resources: { rootDir: string; userDataDir: string }) {
|
||||
const now = '2026-09-06T08:00:00.000Z';
|
||||
const older = '2026-09-04T08:00:00.000Z';
|
||||
const projects = [
|
||||
{
|
||||
id: 'project-moonlight',
|
||||
name: '月光小游戏',
|
||||
path: join(resources.rootDir, '月光小游戏'),
|
||||
createdAt: older,
|
||||
updatedAt: now,
|
||||
lastOpenedAt: now,
|
||||
projectId: '11111111-1111-4111-8111-111111111111',
|
||||
},
|
||||
{
|
||||
id: 'project-storybook',
|
||||
name: '故事绘本',
|
||||
path: join(resources.rootDir, '故事绘本'),
|
||||
createdAt: older,
|
||||
updatedAt: older,
|
||||
lastOpenedAt: older,
|
||||
projectId: '22222222-2222-4222-8222-222222222222',
|
||||
},
|
||||
];
|
||||
|
||||
for (const project of projects) {
|
||||
await mkdir(join(project.path, '.makelore'), { recursive: true });
|
||||
await mkdir(join(project.path, 'knowledge'), { recursive: true });
|
||||
await writeFile(join(project.path, '.makelore', 'project.json'), JSON.stringify({
|
||||
schemaVersion: 2,
|
||||
projectType: 'custom',
|
||||
projectId: project.projectId,
|
||||
initialized: true,
|
||||
agents: [],
|
||||
knowledgeDirectory: 'knowledge',
|
||||
createdAt: project.createdAt,
|
||||
updatedAt: project.updatedAt,
|
||||
}));
|
||||
}
|
||||
|
||||
await writeFile(join(resources.userDataDir, 'makelore-projects.json'), JSON.stringify({
|
||||
projects: {
|
||||
projects: Object.fromEntries(projects.map(({ projectId: _projectId, ...project }) => [project.id, project])),
|
||||
activeProjectId: null,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
test.describe('Makelore module navigation without setup flow', () => {
|
||||
test('offers a create CTA and horizontal cards for remembered inactive Code projects', async ({
|
||||
electronTestResources,
|
||||
launchElectronApp,
|
||||
}) => {
|
||||
await seedInactiveCodingProjects(electronTestResources);
|
||||
const app = await launchElectronApp({ skipSetup: true });
|
||||
|
||||
try {
|
||||
const page = await getStableWindow(app);
|
||||
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
|
||||
await page.getByTestId('ai-module-option-programming').click();
|
||||
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
await expect(page.getByRole('button', { name: '新增项目' })).toBeVisible();
|
||||
const projectCards = page.getByTestId('coding-existing-projects');
|
||||
await expect(projectCards).toBeVisible();
|
||||
await expect(projectCards.getByRole('button')).toHaveCount(2);
|
||||
await expect(projectCards.getByRole('button').nth(0)).toContainText('月光小游戏');
|
||||
await expect(projectCards.getByRole('button').nth(1)).toContainText('故事绘本');
|
||||
|
||||
await projectCards.getByRole('button', { name: '进入项目 故事绘本' }).click();
|
||||
await expect(page.getByTestId('coding-chat-panel')).toBeVisible();
|
||||
await expect(page.getByTestId('coding-existing-projects')).toHaveCount(0);
|
||||
await expect(page.getByTestId('sidebar-course-project-project-storybook')).toHaveAttribute('aria-current', 'page');
|
||||
} finally {
|
||||
await closeElectronApp(app);
|
||||
}
|
||||
});
|
||||
|
||||
test('keeps the three module entries in a proportional vertical stack while resizing the window', async ({ launchElectronApp }) => {
|
||||
const app = await launchElectronApp({ skipSetup: true });
|
||||
|
||||
@@ -143,7 +221,9 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
await expect(page.getByText('请先新建项目')).toHaveCount(0);
|
||||
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.getByRole('button', { name: '新增项目' })).toBeVisible();
|
||||
await expect(page.getByTestId('coding-project-starter')).toHaveCount(0);
|
||||
await expect(page.getByTestId('coding-existing-projects')).toHaveCount(0);
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user