mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
test: align app-spec and enhancement mode tests
This commit is contained in:
@@ -17,6 +17,14 @@ import {
|
|||||||
type EnhancementMode,
|
type EnhancementMode,
|
||||||
} from '@/lib/enhancement-prompts.js';
|
} from '@/lib/enhancement-prompts.js';
|
||||||
|
|
||||||
|
const ENHANCEMENT_MODES: EnhancementMode[] = [
|
||||||
|
'improve',
|
||||||
|
'technical',
|
||||||
|
'simplify',
|
||||||
|
'acceptance',
|
||||||
|
'ux-reviewer',
|
||||||
|
];
|
||||||
|
|
||||||
describe('enhancement-prompts.ts', () => {
|
describe('enhancement-prompts.ts', () => {
|
||||||
describe('System Prompt Constants', () => {
|
describe('System Prompt Constants', () => {
|
||||||
it('should have non-empty improve system prompt', () => {
|
it('should have non-empty improve system prompt', () => {
|
||||||
@@ -184,8 +192,7 @@ describe('enhancement-prompts.ts', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work with all enhancement modes', () => {
|
it('should work with all enhancement modes', () => {
|
||||||
const modes: EnhancementMode[] = ['improve', 'technical', 'simplify', 'acceptance'];
|
ENHANCEMENT_MODES.forEach((mode) => {
|
||||||
modes.forEach((mode) => {
|
|
||||||
const prompt = buildUserPrompt(mode, testText);
|
const prompt = buildUserPrompt(mode, testText);
|
||||||
expect(prompt).toContain(testText);
|
expect(prompt).toContain(testText);
|
||||||
expect(prompt.length).toBeGreaterThan(100);
|
expect(prompt.length).toBeGreaterThan(100);
|
||||||
@@ -205,6 +212,7 @@ describe('enhancement-prompts.ts', () => {
|
|||||||
expect(isValidEnhancementMode('technical')).toBe(true);
|
expect(isValidEnhancementMode('technical')).toBe(true);
|
||||||
expect(isValidEnhancementMode('simplify')).toBe(true);
|
expect(isValidEnhancementMode('simplify')).toBe(true);
|
||||||
expect(isValidEnhancementMode('acceptance')).toBe(true);
|
expect(isValidEnhancementMode('acceptance')).toBe(true);
|
||||||
|
expect(isValidEnhancementMode('ux-reviewer')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for invalid modes', () => {
|
it('should return false for invalid modes', () => {
|
||||||
@@ -216,13 +224,12 @@ describe('enhancement-prompts.ts', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getAvailableEnhancementModes', () => {
|
describe('getAvailableEnhancementModes', () => {
|
||||||
it('should return all four enhancement modes', () => {
|
it('should return all enhancement modes', () => {
|
||||||
const modes = getAvailableEnhancementModes();
|
const modes = getAvailableEnhancementModes();
|
||||||
expect(modes).toHaveLength(4);
|
expect(modes).toHaveLength(ENHANCEMENT_MODES.length);
|
||||||
expect(modes).toContain('improve');
|
ENHANCEMENT_MODES.forEach((mode) => {
|
||||||
expect(modes).toContain('technical');
|
expect(modes).toContain(mode);
|
||||||
expect(modes).toContain('simplify');
|
});
|
||||||
expect(modes).toContain('acceptance');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an array', () => {
|
it('should return an array', () => {
|
||||||
|
|||||||
@@ -5,59 +5,61 @@ import {
|
|||||||
getSpecRegenerationStatus,
|
getSpecRegenerationStatus,
|
||||||
} from '@/routes/app-spec/common.js';
|
} from '@/routes/app-spec/common.js';
|
||||||
|
|
||||||
|
const TEST_PROJECT_PATH = '/tmp/automaker-test-project';
|
||||||
|
|
||||||
describe('app-spec/common.ts', () => {
|
describe('app-spec/common.ts', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Reset state before each test
|
// Reset state before each test
|
||||||
setRunningState(false, null);
|
setRunningState(TEST_PROJECT_PATH, false, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setRunningState', () => {
|
describe('setRunningState', () => {
|
||||||
it('should set isRunning to true when running is true', () => {
|
it('should set isRunning to true when running is true', () => {
|
||||||
setRunningState(true);
|
setRunningState(TEST_PROJECT_PATH, true);
|
||||||
expect(getSpecRegenerationStatus().isRunning).toBe(true);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).isRunning).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set isRunning to false when running is false', () => {
|
it('should set isRunning to false when running is false', () => {
|
||||||
setRunningState(true);
|
setRunningState(TEST_PROJECT_PATH, true);
|
||||||
setRunningState(false);
|
setRunningState(TEST_PROJECT_PATH, false);
|
||||||
expect(getSpecRegenerationStatus().isRunning).toBe(false);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).isRunning).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set currentAbortController when provided', () => {
|
it('should set currentAbortController when provided', () => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
setRunningState(true, controller);
|
setRunningState(TEST_PROJECT_PATH, true, controller);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(controller);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(controller);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set currentAbortController to null when not provided', () => {
|
it('should set currentAbortController to null when not provided', () => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
setRunningState(true, controller);
|
setRunningState(TEST_PROJECT_PATH, true, controller);
|
||||||
setRunningState(false);
|
setRunningState(TEST_PROJECT_PATH, false);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(null);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set currentAbortController to null when explicitly passed null', () => {
|
it('should keep currentAbortController when explicitly passed null while running', () => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
setRunningState(true, controller);
|
setRunningState(TEST_PROJECT_PATH, true, controller);
|
||||||
setRunningState(true, null);
|
setRunningState(TEST_PROJECT_PATH, true, null);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(null);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(controller);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update state multiple times correctly', () => {
|
it('should update state multiple times correctly', () => {
|
||||||
const controller1 = new AbortController();
|
const controller1 = new AbortController();
|
||||||
const controller2 = new AbortController();
|
const controller2 = new AbortController();
|
||||||
|
|
||||||
setRunningState(true, controller1);
|
setRunningState(TEST_PROJECT_PATH, true, controller1);
|
||||||
expect(getSpecRegenerationStatus().isRunning).toBe(true);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).isRunning).toBe(true);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(controller1);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(controller1);
|
||||||
|
|
||||||
setRunningState(true, controller2);
|
setRunningState(TEST_PROJECT_PATH, true, controller2);
|
||||||
expect(getSpecRegenerationStatus().isRunning).toBe(true);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).isRunning).toBe(true);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(controller2);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(controller2);
|
||||||
|
|
||||||
setRunningState(false, null);
|
setRunningState(TEST_PROJECT_PATH, false, null);
|
||||||
expect(getSpecRegenerationStatus().isRunning).toBe(false);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).isRunning).toBe(false);
|
||||||
expect(getSpecRegenerationStatus().currentAbortController).toBe(null);
|
expect(getSpecRegenerationStatus(TEST_PROJECT_PATH).currentAbortController).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import fs from 'fs/promises';
|
|||||||
vi.mock('child_process', () => ({
|
vi.mock('child_process', () => ({
|
||||||
spawn: vi.fn(),
|
spawn: vi.fn(),
|
||||||
execSync: vi.fn(),
|
execSync: vi.fn(),
|
||||||
|
execFile: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock secure-fs
|
// Mock secure-fs
|
||||||
|
|||||||
Reference in New Issue
Block a user