mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
fix: update category mapping and improve ID generation format in IdeationService
- Changed the category mapping for 'feature' from 'feature' to 'ui'. - Updated ID generation format to use hyphens instead of underscores for better readability. - Enhanced unit tests to reflect the updated category and ensure proper functionality.
This commit is contained in:
@@ -1631,7 +1631,7 @@ Focus on practical, implementable suggestions that would genuinely improve the p
|
|||||||
|
|
||||||
private mapIdeaCategoryToFeatureCategory(category: IdeaCategory): string {
|
private mapIdeaCategoryToFeatureCategory(category: IdeaCategory): string {
|
||||||
const mapping: Record<IdeaCategory, string> = {
|
const mapping: Record<IdeaCategory, string> = {
|
||||||
feature: 'feature',
|
feature: 'ui',
|
||||||
'ux-ui': 'enhancement',
|
'ux-ui': 'enhancement',
|
||||||
dx: 'chore',
|
dx: 'chore',
|
||||||
growth: 'feature',
|
growth: 'feature',
|
||||||
@@ -1674,6 +1674,6 @@ Focus on practical, implementable suggestions that would genuinely improve the p
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateId(prefix: string): string {
|
private generateId(prefix: string): string {
|
||||||
return `${prefix}_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,26 @@ import type {
|
|||||||
} from '@automaker/types';
|
} from '@automaker/types';
|
||||||
import { ProviderFactory } from '@/providers/provider-factory.js';
|
import { ProviderFactory } from '@/providers/provider-factory.js';
|
||||||
|
|
||||||
|
// Create a shared mock logger instance for assertions using vi.hoisted
|
||||||
|
const mockLogger = vi.hoisted(() => ({
|
||||||
|
info: vi.fn(),
|
||||||
|
error: vi.fn(),
|
||||||
|
warn: vi.fn(),
|
||||||
|
debug: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
vi.mock('@/lib/secure-fs.js');
|
vi.mock('@/lib/secure-fs.js');
|
||||||
vi.mock('@automaker/platform');
|
vi.mock('@automaker/platform');
|
||||||
vi.mock('@automaker/utils');
|
vi.mock('@automaker/utils', async () => {
|
||||||
|
const actual = await vi.importActual<typeof import('@automaker/utils')>('@automaker/utils');
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
createLogger: vi.fn(() => mockLogger),
|
||||||
|
loadContextFiles: vi.fn(),
|
||||||
|
isAbortError: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
vi.mock('@/providers/provider-factory.js');
|
vi.mock('@/providers/provider-factory.js');
|
||||||
vi.mock('@/lib/sdk-options.js', () => ({
|
vi.mock('@/lib/sdk-options.js', () => ({
|
||||||
createChatOptions: vi.fn(() => ({
|
createChatOptions: vi.fn(() => ({
|
||||||
@@ -56,7 +72,9 @@ describe('IdeationService', () => {
|
|||||||
|
|
||||||
// Mock platform functions
|
// Mock platform functions
|
||||||
vi.mocked(platform.ensureIdeationDir).mockResolvedValue(undefined);
|
vi.mocked(platform.ensureIdeationDir).mockResolvedValue(undefined);
|
||||||
vi.mocked(platform.getIdeaDir).mockReturnValue('/test/project/.automaker/ideation/ideas/idea-123');
|
vi.mocked(platform.getIdeaDir).mockReturnValue(
|
||||||
|
'/test/project/.automaker/ideation/ideas/idea-123'
|
||||||
|
);
|
||||||
vi.mocked(platform.getIdeaPath).mockReturnValue(
|
vi.mocked(platform.getIdeaPath).mockReturnValue(
|
||||||
'/test/project/.automaker/ideation/ideas/idea-123/idea.json'
|
'/test/project/.automaker/ideation/ideas/idea-123/idea.json'
|
||||||
);
|
);
|
||||||
@@ -71,7 +89,7 @@ describe('IdeationService', () => {
|
|||||||
'/test/project/.automaker/ideation/analysis.json'
|
'/test/project/.automaker/ideation/analysis.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mock utils
|
// Mock utils (already mocked above, but reset return values)
|
||||||
vi.mocked(utils.loadContextFiles).mockResolvedValue({
|
vi.mocked(utils.loadContextFiles).mockResolvedValue({
|
||||||
formattedPrompt: 'Test context',
|
formattedPrompt: 'Test context',
|
||||||
files: [],
|
files: [],
|
||||||
@@ -497,7 +515,7 @@ describe('IdeationService', () => {
|
|||||||
id: 'idea-123',
|
id: 'idea-123',
|
||||||
title: 'Add Dark Mode',
|
title: 'Add Dark Mode',
|
||||||
description: 'Implement dark mode theme',
|
description: 'Implement dark mode theme',
|
||||||
category: 'features',
|
category: 'feature',
|
||||||
status: 'refined',
|
status: 'refined',
|
||||||
impact: 'high',
|
impact: 'high',
|
||||||
effort: 'medium',
|
effort: 'medium',
|
||||||
@@ -613,7 +631,14 @@ describe('IdeationService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit error event on failure', async () => {
|
it('should emit error event on failure', async () => {
|
||||||
vi.mocked(secureFs.readFile).mockRejectedValue(new Error('Read failed'));
|
// Mock writeFile to fail (this is called after gatherProjectStructure and isn't caught)
|
||||||
|
vi.mocked(secureFs.readFile).mockResolvedValue(
|
||||||
|
JSON.stringify({
|
||||||
|
name: 'test-project',
|
||||||
|
dependencies: {},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
vi.mocked(secureFs.writeFile).mockRejectedValue(new Error('Write failed'));
|
||||||
|
|
||||||
await expect(service.analyzeProject(testProjectPath)).rejects.toThrow();
|
await expect(service.analyzeProject(testProjectPath)).rejects.toThrow();
|
||||||
|
|
||||||
@@ -665,7 +690,7 @@ describe('IdeationService', () => {
|
|||||||
expect(Array.isArray(categories)).toBe(true);
|
expect(Array.isArray(categories)).toBe(true);
|
||||||
expect(categories.length).toBeGreaterThan(0);
|
expect(categories.length).toBeGreaterThan(0);
|
||||||
expect(categories[0]).toHaveProperty('id');
|
expect(categories[0]).toHaveProperty('id');
|
||||||
expect(categories[0]).toHaveProperty('label');
|
expect(categories[0]).toHaveProperty('name');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user