Files
makelore/tests/e2e/main-navigation.spec.ts
2026-07-29 17:22:35 +08:00

78 lines
4.8 KiB
TypeScript

import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron';
test.describe('NianCode main navigation without setup flow', () => {
test('navigates between core pages with setup bypassed', async ({ launchElectronApp }) => {
const app = await launchElectronApp({ skipSetup: true });
try {
const page = await getStableWindow(app);
const minimumSize = await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0]?.getMinimumSize());
expect(minimumSize).toEqual([1100, 700]);
await expect(page.getByTestId('main-layout')).toBeVisible();
await expect(page.getByText('请先新建项目')).toBeVisible();
await expect(page.getByText('一念成光,万物可创。')).toBeVisible();
await expect(page.getByRole('img', { name: 'Makelore logo' })).toBeVisible();
await expect(page.getByText('Makelore 工作台', { exact: true })).toBeVisible();
await expect(page.getByText(/NITU/)).toHaveCount(0);
await expect(page.getByTestId('sidebar-create-project')).toBeVisible();
await expect(page.getByTestId('sidebar-nav-publish')).toHaveCount(0);
await expect(page.getByTestId('sidebar-nav-project-config')).toHaveCount(0);
await expect(page.getByTestId('sidebar-nav-agent-chat')).toHaveCount(0);
await expect(page.getByRole('button', { name: '添加已有项目' })).toHaveCount(0);
await expect(page.getByTestId('sidebar-nav-character')).toHaveText('角色场景');
await expect(page.getByText('成长成就在这里')).toHaveCount(0);
await expect(page.getByText('已创建 Phaser 2D 小游戏起步工程')).toHaveCount(0);
await expect(page.getByTestId('game-asset-browser')).toHaveCount(0);
await expect(page.getByTestId('game-asset-review-summary')).toHaveCount(0);
await page.getByTestId('resource-card-models').click();
await expect(page.getByTestId('nitu-model-config-refresh-button')).toBeVisible();
await page.keyboard.press('Escape');
await page.getByTestId('resource-card-skills').click();
await expect(page.getByRole('heading', { name: '可用技能库' })).toBeVisible();
await expect(page.getByTestId('skill-library-card-youth-plain-language')).toContainText('青少年通俗表达');
await expect(page.getByTestId('skill-library-card-youth-plain-language')).not.toContainText('youth-plain-language');
await expect(page.getByTestId('skill-library-card-pm-project-plan')).toContainText('通用软件项目规划');
await expect(page.getByTestId('skill-library-card-pm-project-plan')).not.toContainText('pm-project-plan');
await page.keyboard.press('Escape');
await page.getByTestId('sidebar-nav-models').click();
await expect(page.getByTestId('models-page')).toBeVisible();
await expect(page.getByTestId('models-page-title')).toBeVisible();
await expect(page.getByTestId('sidebar-module-switcher')).toBeVisible();
await expect(page.getByTestId('sidebar-module-switcher-trigger')).toHaveAttribute('aria-expanded', 'false');
await page.getByTestId('sidebar-module-switcher-trigger').click();
await expect(page.getByTestId('sidebar-module-programming')).toHaveAttribute('aria-current', 'page');
await page.getByTestId('sidebar-module-painting').click();
await expect(page.getByTestId('image-canvas-page')).toBeVisible();
await expect(page.getByTestId('image-workspace-unavailable')).toBeVisible();
await expect(page.getByText('创作空间暂不可用').first()).toBeVisible();
await expect(page.getByTestId('sidebar-image-workspace')).toBeVisible();
await expect(page.getByTestId('sidebar-create-image-project')).toBeVisible();
await expect(page.getByText('本地开发')).toHaveCount(0);
await expect(page.getByTestId('sidebar-reset-local-image-workspace')).toHaveCount(0);
await expect(page.getByTestId('sidebar-create-project')).toHaveCount(0);
await expect(page.getByText('制作中心')).toHaveCount(0);
await expect(page.getByText('任务模块')).toHaveCount(0);
await expect(page.getByTestId('sidebar-module-painting')).toHaveAttribute('aria-current', 'page');
await page.getByTestId('sidebar-module-switcher-trigger').click();
await page.getByTestId('sidebar-module-programming').click();
await expect(page.getByText('请先新建项目')).toBeVisible();
await expect(page.getByTestId('chat-operation-page')).toHaveCount(0);
await expect(page.getByTestId('sidebar-nav-asset-square')).toHaveCount(0);
await page.getByTestId('sidebar-nav-agents').click();
await expect(page.getByTestId('agents-page')).toBeVisible();
await page.getByTestId('sidebar-nav-channels').click();
await expect(page.getByTestId('channels-page')).toBeVisible();
} finally {
await closeElectronApp(app);
}
});
});