mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
2253d05618
Remove the nested v3/ subdirectory by moving all active source code, tests, configs, and assets directly to the project root. Archive v2/ (dead code, 847MB) to v2-archive.tar.gz. Key changes: - Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/ - Move v3/tsconfig.json, v3/vitest.config.ts to root - Merge v3/package.json into root package.json (ESM, scripts, deps, exports) - Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/ - Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes - Fix all init installer path resolution (3-level-up → 2-level-up) - Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe" - Update settings.json ADR/DDD directories to docs/implementation/ - Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks) - Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces - Update 15 guidance shards: v3/src/ → src/ path references - Fix sync interfaces: remove v3/ and v2/ path references - Fix test path calculations (process.cwd() + '..' no longer needed) - Fix flaky perf test threshold (500ms → 1000ms for CI environments) - Fix complexity-analyzer test to match ADR-051 keyword-based eligibility Build passes, 17,901 tests pass, CLI and MCP bundles verified. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
184 lines
6.5 KiB
TypeScript
184 lines
6.5 KiB
TypeScript
/**
|
|
* Test: Assets Phase - Version Upgrade Detection
|
|
*
|
|
* Verifies that:
|
|
* 1. detectVersionUpgrade correctly identifies version changes
|
|
* 2. Auto mode with version change triggers asset updates
|
|
* 3. Skills and agents are overwritten when upgrading
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import { existsSync, mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { AssetsPhase } from '../../../src/init/phases/09-assets.js';
|
|
import type { InitContext } from '../../../src/init/phases/phase-interface.js';
|
|
import type { AQEInitConfig } from '../../../src/init/types.js';
|
|
|
|
describe('AssetsPhase - Version Upgrade Detection', () => {
|
|
const testDir = join(process.cwd(), '.test-assets-phase');
|
|
const phase = new AssetsPhase() as any; // Access private methods
|
|
|
|
beforeEach(() => {
|
|
// Create test directory structure
|
|
if (existsSync(testDir)) {
|
|
rmSync(testDir, { recursive: true });
|
|
}
|
|
mkdirSync(join(testDir, '.agentic-qe'), { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
// Cleanup
|
|
if (existsSync(testDir)) {
|
|
rmSync(testDir, { recursive: true });
|
|
}
|
|
});
|
|
|
|
const createMockContext = (version: string, options: Partial<InitContext['options']> = {}): InitContext => ({
|
|
projectRoot: testDir,
|
|
options: {
|
|
autoMode: false,
|
|
upgrade: false,
|
|
...options,
|
|
},
|
|
config: {
|
|
version,
|
|
project: { name: 'test', root: testDir, type: 'single' },
|
|
skills: { install: true, installV2: true, installV3: true, overwrite: false },
|
|
} as AQEInitConfig,
|
|
services: {
|
|
log: () => {},
|
|
warn: () => {},
|
|
error: () => {},
|
|
},
|
|
phaseResults: new Map(),
|
|
});
|
|
|
|
describe('detectVersionUpgrade', () => {
|
|
it('should return false when no config exists', () => {
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
it('should return false when versions match', () => {
|
|
// Create existing config with same version
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
writeFileSync(configPath, 'version: "3.5.3"\n', 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
it('should return true when versions differ', () => {
|
|
// Create existing config with older version
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
writeFileSync(configPath, 'version: "3.5.0"\n', 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('should handle version without quotes', () => {
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
writeFileSync(configPath, 'version: 3.5.0\n', 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('should handle complex config files', () => {
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
const complexConfig = `# Agentic QE v3 Configuration
|
|
# Generated by aqe init
|
|
|
|
version: "3.5.0"
|
|
|
|
project:
|
|
name: "my-project"
|
|
root: "/path/to/project"
|
|
type: "single"
|
|
|
|
learning:
|
|
enabled: true
|
|
`;
|
|
writeFileSync(configPath, complexConfig, 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('should return false on read error', () => {
|
|
// Create a directory instead of a file to cause a read error
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
mkdirSync(configPath, { recursive: true });
|
|
|
|
const context = createMockContext('3.5.3');
|
|
const result = phase.detectVersionUpgrade(context);
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('shouldOverwrite logic', () => {
|
|
it('should NOT overwrite by default', () => {
|
|
const context = createMockContext('3.5.3');
|
|
const config = context.config as AQEInitConfig;
|
|
|
|
const shouldOverwrite = context.options.upgrade || config.skills.overwrite;
|
|
expect(shouldOverwrite).toBe(false);
|
|
});
|
|
|
|
it('should overwrite when upgrade flag is set', () => {
|
|
const context = createMockContext('3.5.3', { upgrade: true });
|
|
const config = context.config as AQEInitConfig;
|
|
|
|
const shouldOverwrite = context.options.upgrade || config.skills.overwrite;
|
|
expect(shouldOverwrite).toBe(true);
|
|
});
|
|
|
|
it('should overwrite when config.skills.overwrite is true', () => {
|
|
const context = createMockContext('3.5.3');
|
|
(context.config as AQEInitConfig).skills.overwrite = true;
|
|
const config = context.config as AQEInitConfig;
|
|
|
|
const shouldOverwrite = context.options.upgrade || config.skills.overwrite;
|
|
expect(shouldOverwrite).toBe(true);
|
|
});
|
|
|
|
it('should overwrite in auto mode when version differs', () => {
|
|
// Create existing config with older version
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
writeFileSync(configPath, 'version: "3.5.0"\n', 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3', { autoMode: true });
|
|
const config = context.config as AQEInitConfig;
|
|
const isVersionUpgrade = phase.detectVersionUpgrade(context);
|
|
|
|
const shouldOverwrite = context.options.upgrade || config.skills.overwrite ||
|
|
(context.options.autoMode && isVersionUpgrade);
|
|
|
|
expect(isVersionUpgrade).toBe(true);
|
|
expect(shouldOverwrite).toBe(true);
|
|
});
|
|
|
|
it('should NOT overwrite in auto mode when version matches', () => {
|
|
// Create existing config with same version
|
|
const configPath = join(testDir, '.agentic-qe', 'config.yaml');
|
|
writeFileSync(configPath, 'version: "3.5.3"\n', 'utf-8');
|
|
|
|
const context = createMockContext('3.5.3', { autoMode: true });
|
|
const config = context.config as AQEInitConfig;
|
|
const isVersionUpgrade = phase.detectVersionUpgrade(context);
|
|
|
|
const shouldOverwrite = context.options.upgrade || config.skills.overwrite ||
|
|
(context.options.autoMode && isVersionUpgrade);
|
|
|
|
expect(isVersionUpgrade).toBe(false);
|
|
expect(shouldOverwrite).toBe(false);
|
|
});
|
|
});
|
|
});
|