实现小游戏与小程序项目创建发布
This commit is contained in:
@@ -232,9 +232,9 @@ describe('Sidebar project initialization flow', () => {
|
||||
expect(update).toHaveAccessibleName('下载新版本 0.9.2');
|
||||
});
|
||||
|
||||
it('creates a path-backed project without selecting a template and opens configuration', async () => {
|
||||
it('defaults to a publishable mini-game project and opens configuration', async () => {
|
||||
const project = { id: 'prj_game', path: 'D:/repo/星星收集器', name: '星星收集器', createdAt: '2026-07-11T00:00:00.000Z', updatedAt: '2026-07-11T00:00:00.000Z', lastOpenedAt: '2026-07-11T00:00:00.000Z' };
|
||||
const config = createProjectConfig();
|
||||
const config = createProjectConfig(undefined, 'mini_game');
|
||||
invokeIpcMock.mockResolvedValue({ canceled: false, filePaths: ['D:/repo/星星收集器'] });
|
||||
hostApiFetchMock.mockImplementation(async (path: string, init?: RequestInit) => {
|
||||
if (path === '/api/opencode/projects') return { projects: [], activeProject: null };
|
||||
@@ -245,19 +245,22 @@ describe('Sidebar project initialization flow', () => {
|
||||
});
|
||||
render(<MemoryRouter><Sidebar /></MemoryRouter>);
|
||||
fireEvent.click(await screen.findByRole('button', { name: '新建项目' }));
|
||||
expect(screen.getByRole('radio', { name: '小游戏' })).toBeChecked();
|
||||
expect(screen.getByRole('radio', { name: '小程序' })).not.toBeChecked();
|
||||
expect(screen.getByRole('radio', { name: '自定义项目' })).not.toBeChecked();
|
||||
expect(screen.getByRole('radio', { name: '直接使用所选文件夹(默认)' })).toBeChecked();
|
||||
expect(screen.queryByLabelText('项目名称')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '选择路径' }));
|
||||
await waitFor(() => expect(screen.getByLabelText('项目路径')).toHaveValue('D:/repo/星星收集器'));
|
||||
expect(screen.getByText('将直接接入此文件夹,项目名称使用“星星收集器”,不会重命名目录。')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '确认创建' }));
|
||||
await waitFor(() => expect(hostApiFetchMock).toHaveBeenCalledWith('/api/opencode/projects/create', { method: 'POST', body: JSON.stringify({ projectPath: 'D:/repo/星星收集器' }) }));
|
||||
await waitFor(() => expect(hostApiFetchMock).toHaveBeenCalledWith('/api/opencode/projects/create', { method: 'POST', body: JSON.stringify({ projectPath: 'D:/repo/星星收集器', projectType: 'mini_game' }) }));
|
||||
await waitFor(() => expect(navigateMock).toHaveBeenCalledWith('/project-config'));
|
||||
});
|
||||
|
||||
it('keeps creating a named child folder when that directory mode is selected', async () => {
|
||||
const project = { id: 'prj_child', path: 'D:/repo/星星收集器', name: '星星收集器', createdAt: '', updatedAt: '', lastOpenedAt: '' };
|
||||
const config = createProjectConfig();
|
||||
const config = createProjectConfig(undefined, 'mini_program');
|
||||
invokeIpcMock.mockResolvedValue({ canceled: false, filePaths: ['D:/repo'] });
|
||||
hostApiFetchMock.mockImplementation(async (path: string, init?: RequestInit) => {
|
||||
if (path === '/api/opencode/projects') return { projects: [], activeProject: null };
|
||||
@@ -269,6 +272,7 @@ describe('Sidebar project initialization flow', () => {
|
||||
|
||||
render(<MemoryRouter><Sidebar /></MemoryRouter>);
|
||||
fireEvent.click(await screen.findByRole('button', { name: '新建项目' }));
|
||||
fireEvent.click(screen.getByRole('radio', { name: '小程序' }));
|
||||
fireEvent.click(screen.getByRole('radio', { name: '在所选位置新建下级文件夹' }));
|
||||
fireEvent.change(screen.getByLabelText('项目名称'), { target: { value: '星星收集器' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: '选择路径' }));
|
||||
@@ -280,6 +284,7 @@ describe('Sidebar project initialization flow', () => {
|
||||
body: JSON.stringify({
|
||||
parentPath: 'D:/repo',
|
||||
projectName: '星星收集器',
|
||||
projectType: 'mini_program',
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user