实现小游戏与小程序项目创建发布
This commit is contained in:
@@ -45,6 +45,7 @@ describe('project-owned contact configuration', () => {
|
||||
it('creates an empty, template-free project config', () => {
|
||||
const config = createProjectConfig('2026-07-11T00:00:00.000Z');
|
||||
expect(config).toMatchObject({
|
||||
projectType: 'custom',
|
||||
initialized: false,
|
||||
superpowersEnabled: false,
|
||||
agents: [],
|
||||
@@ -53,6 +54,19 @@ describe('project-owned contact configuration', () => {
|
||||
expect('templateId' in config).toBe(false);
|
||||
});
|
||||
|
||||
it('normalizes legacy configs without a project type as custom', () => {
|
||||
const legacyConfig = { ...createProjectConfig(), projectType: undefined };
|
||||
expect(normalizeProjectConfig(legacyConfig).projectType).toBe('custom');
|
||||
expect(normalizeProjectConfig({
|
||||
...legacyConfig,
|
||||
projectType: 'mini_game',
|
||||
}).projectType).toBe('mini_game');
|
||||
expect(() => normalizeProjectConfig({
|
||||
...legacyConfig,
|
||||
projectType: 'future_project',
|
||||
})).toThrow('Invalid project type');
|
||||
});
|
||||
|
||||
it('requires a unique name, preset avatar, model, and responsibility for every contact', () => {
|
||||
expect(validateAgentConfigs([])).toEqual([]);
|
||||
expect(validateAgentConfigs([createContact({ name: '' })])).toContain('agent-test:name-required');
|
||||
@@ -130,4 +144,18 @@ describe('project-owned contact configuration', () => {
|
||||
agents: [createContact({ model: null })],
|
||||
})).rejects.toThrow('model-required');
|
||||
});
|
||||
|
||||
it('does not allow the persisted project type to change', async () => {
|
||||
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-project-type-'));
|
||||
const initial = await createInitialProjectConfig(projectPath, { projectType: 'mini_game' });
|
||||
|
||||
await expect(writeProjectConfig(projectPath, {
|
||||
...initial,
|
||||
projectType: 'mini_program',
|
||||
})).rejects.toThrow('已有项目类型不可更改');
|
||||
await expect(readProjectConfig(projectPath)).resolves.toMatchObject({
|
||||
status: 'valid',
|
||||
config: { projectType: 'mini_game' },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user