实现小游戏与小程序项目创建发布

This commit is contained in:
2026-08-09 13:31:06 +08:00
parent a6fe14a8d6
commit 493b31cff0
26 changed files with 1827 additions and 39 deletions

View File

@@ -52,7 +52,7 @@ describe('ProjectConfiguration', () => {
dispatchEvent: vi.fn(),
})),
});
const config = createProjectConfig();
const config = createProjectConfig(undefined, 'mini_game');
useOpencodeStore.setState({ activeProject: project, projects: [project] });
useProjectConfigStore.setState({ configsByProjectId: { [project.id]: config }, knowledgeByProjectId: { [project.id]: [] }, errorsByProjectId: {}, loadingProjectId: null });
useProviderStore.setState({
@@ -85,6 +85,29 @@ describe('ProjectConfiguration', () => {
expect(screen.queryAllByTestId(/^project-agent-/)).toHaveLength(0);
});
it('does not offer one-click submission for custom projects', async () => {
const customConfig = createProjectConfig();
useProjectConfigStore.setState({
configsByProjectId: { [project.id]: customConfig },
knowledgeByProjectId: { [project.id]: [] },
errorsByProjectId: {},
loadingProjectId: null,
});
const fallback = hostApiFetchMock.getMockImplementation();
hostApiFetchMock.mockImplementation(async (path: string, init?: RequestInit) => {
if (path === `/api/opencode/projects/config?projectId=${project.id}`) {
return { status: 'valid', config: customConfig, knowledgeFiles: [] };
}
if (!fallback) throw new Error(`Unexpected path ${path}`);
return fallback(path, init);
});
render(<MemoryRouter><ProjectConfiguration /></MemoryRouter>);
expect(await screen.findByText('自定义项目暂未配置发布方式。如需一键提交,请新建小游戏或小程序项目。')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: '一键提交审核' })).not.toBeInTheDocument();
});
it('creates a contact with the required basics and leaves advanced settings empty', async () => {
render(<MemoryRouter><ProjectConfiguration /></MemoryRouter>);
fireEvent.click(await screen.findByRole('button', { name: '新增伙伴' }));