mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
65457ccc84
Address verification findings from user-perspective review of IMP-00 through IMP-10: - Implement 8 missing env var kill switches (AQE_MICROCOMPACT, AQE_RETRY_DISABLED, AQE_SESSION_DURABILITY, AQE_PROMPT_CACHE_LATCH, AQE_FAST_PATHS, AQE_HOOKS_SSRF_DISABLED, AQE_COMPACTION_DISABLED, AQE_PLUGINS_DISABLED) - Add 5 missing test files: parallel-prefetch, session-durability-middleware, and plugin sources (local, github, npm) — 40 new tests - Add kill switch test coverage for all 8 env vars — 10 new tests - Fix stdout log leak: redirect [ParserRegistry], [ContinueGateIntegration], timestamped logs, and other internal prefixes to stderr - Update plan doc verification matrix with correct test file names (37 files) - Add user-perspective verification report 466 tests pass across 37 IMP test files. Build clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { LocalPluginSource } from '../../../src/plugins/sources/local';
|
|
|
|
// Mock fs module
|
|
vi.mock('fs', async () => {
|
|
const actual = await vi.importActual<typeof import('fs')>('fs');
|
|
return {
|
|
...actual,
|
|
existsSync: vi.fn(),
|
|
readFileSync: vi.fn(),
|
|
};
|
|
});
|
|
|
|
const VALID_MANIFEST = JSON.stringify({
|
|
name: 'test-plugin',
|
|
version: '1.0.0',
|
|
description: 'A test plugin',
|
|
author: 'Test Author',
|
|
domains: ['test-generation'],
|
|
entryPoint: 'index.js',
|
|
});
|
|
|
|
describe('LocalPluginSource', () => {
|
|
let source: LocalPluginSource;
|
|
|
|
beforeEach(() => {
|
|
source = new LocalPluginSource();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('should have type "local"', () => {
|
|
expect(source.type).toBe('local');
|
|
});
|
|
|
|
describe('resolve', () => {
|
|
it('should resolve a manifest from a local directory', async () => {
|
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
vi.mocked(fs.readFileSync).mockReturnValue(VALID_MANIFEST);
|
|
|
|
const manifest = await source.resolve('/path/to/plugin');
|
|
|
|
expect(fs.existsSync).toHaveBeenCalledWith(
|
|
path.resolve('/path/to/plugin', 'qe-plugin.json'),
|
|
);
|
|
expect(manifest.name).toBe('test-plugin');
|
|
expect(manifest.version).toBe('1.0.0');
|
|
});
|
|
|
|
it('should throw if qe-plugin.json does not exist', async () => {
|
|
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
|
|
await expect(source.resolve('/missing')).rejects.toThrow('No qe-plugin.json found');
|
|
});
|
|
});
|
|
|
|
describe('getPluginPath', () => {
|
|
it('should return the absolute path of an existing directory', async () => {
|
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
|
|
const result = await source.getPluginPath('/some/plugin');
|
|
|
|
expect(result).toBe(path.resolve('/some/plugin'));
|
|
});
|
|
|
|
it('should throw if the directory does not exist', async () => {
|
|
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
|
|
await expect(source.getPluginPath('/nonexistent')).rejects.toThrow(
|
|
'Plugin directory does not exist',
|
|
);
|
|
});
|
|
});
|
|
});
|