Expand test coverage across server, agent, and web; fix bugs found during audit.

Adds hundreds of unit/integration/e2e tests, fixes WS bcrypt auth, config merge, fleet analytics, agent schedule/log tail, and documents stale PROBLEMS items. Updates PROBLEMS.md, README, and test scripts; ignores local spread-kits and coverage dirs.
This commit is contained in:
AetherForge
2026-05-31 01:13:49 -07:00
parent 159747877c
commit ea6f54ad03
89 changed files with 5307 additions and 322 deletions

View File

@@ -0,0 +1,17 @@
import { expect, type Page } from '@playwright/test';
/** Matches server/internal/api/integration_test.go testAuthUser / testAuthPass. */
export const E2E_USER = process.env.AETHERFORGE_E2E_USER || 'testuser';
export const E2E_PASS = process.env.AETHERFORGE_E2E_PASS || 'testpass';
/** Seed this into the server data dir as users.json before first start (see tests/README.md). */
export const E2E_USERS_JSON = JSON.stringify({ [E2E_USER]: E2E_PASS });
export async function loginToDashboard(page: Page): Promise<void> {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'AetherForge' })).toBeVisible({ timeout: 15_000 });
await page.getByLabel('Username').fill(E2E_USER);
await page.getByLabel('Password').fill(E2E_PASS);
await page.getByRole('button', { name: /enter command deck/i }).click();
await expect(page.getByRole('heading', { name: 'Command Deck' })).toBeVisible({ timeout: 15_000 });
}

View File

@@ -0,0 +1,33 @@
import { expect, test } from '@playwright/test';
import { loginToDashboard } from './fixtures';
test.describe('Page smoke', () => {
test.beforeEach(async ({ page }) => {
await loginToDashboard(page);
});
test('Dashboard renders Command Deck', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Command Deck' })).toBeVisible();
await expect(page.getByText('Fleet Pipeline')).toBeVisible();
await expect(page.getByText('Machine Roster')).toBeVisible();
});
test('Agents renders Fleet Roster', async ({ page }) => {
await page.getByRole('link', { name: /Fleet Roster/i }).click();
await expect(page.getByRole('heading', { name: 'Fleet Roster' })).toBeVisible({ timeout: 10_000 });
await expect(page.getByText(/NODES/i)).toBeVisible();
});
test('Settings renders Calibrate', async ({ page }) => {
await page.getByRole('link', { name: /Calibrate/i }).click();
await expect(page.getByRole('heading', { name: 'Calibrate' })).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole('button', { name: 'Save Calibration' })).toBeVisible();
});
test('Builder renders The Forge', async ({ page }) => {
await page.getByRole('link', { name: /Forge/i }).click();
await expect(page.getByRole('heading', { name: 'The Forge' })).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole('heading', { name: 'Quick Forge' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Simple' })).toBeVisible();
});
});

View File

@@ -0,0 +1,72 @@
import { expect, test } from '@playwright/test';
import { loginToDashboard } from './fixtures';
const OFFLINE_AGENT = {
id: 'e2e-offline-agent',
name: 'Offline Node',
wallet: '4' + 'A'.repeat(94),
ip: '192.168.1.99',
version: '1.0.0',
status: 'offline',
cpu_cores: 4,
memory_gb: 8,
last_seen: new Date(Date.now() - 3600_000).toISOString(),
created_at: new Date().toISOString(),
hashrate_15s: 0,
hashrate_1m: 0,
hashrate_15m: 0,
shares_total: 0,
shares_good: 0,
shares_bad: 0,
cpu_usage_pct: 0,
memory_usage_pct: 0,
uptime_seconds: 0,
platform: 'windows',
arch: 'amd64',
};
test.describe('Remote actions UI', () => {
test.beforeEach(async ({ page }) => {
await page.route('**/api/v1/agents', async (route) => {
if (route.request().method() === 'GET' && route.request().url().endsWith('/agents')) {
await route.fulfill({ json: [OFFLINE_AGENT] });
return;
}
await route.continue();
});
await page.route('**/api/v1/agents/*/stats*', async (route) => {
await route.fulfill({ json: [] });
});
await page.route('**/api/v1/builds', async (route) => {
await route.fulfill({ json: [] });
});
await page.route('**/api/v1/server/info', async (route) => {
await route.fulfill({
json: {
version: 'test',
suggested_url: 'http://127.0.0.1:8989',
agent_count: 1,
online_count: 0,
},
});
});
await loginToDashboard(page);
await page.getByRole('link', { name: /Fleet Roster/i }).click();
await expect(page.getByRole('heading', { name: 'Fleet Roster' })).toBeVisible({ timeout: 10_000 });
await expect(page.getByText('Offline Node')).toBeVisible({ timeout: 10_000 });
});
test('detail panel disables remote actions for offline agent', async ({ page }) => {
await page.getByText('Offline Node').click();
const detail = page.locator('.agent-detail');
await expect(detail.getByRole('heading', { name: 'Remote Control' })).toBeVisible({ timeout: 10_000 });
await expect(detail.getByRole('button', { name: 'Screenshot' })).toBeDisabled();
await expect(detail.getByRole('button', { name: 'Pause' })).toBeDisabled();
});
test('compact row remote actions disabled when offline', async ({ page }) => {
await page.getByText('Offline Node').click();
const compact = page.locator('.agent-list-item.expanded');
await expect(compact.getByRole('button', { name: 'Pause' })).toBeDisabled();
});
});

View File

@@ -1,4 +1,5 @@
import { expect, test } from '@playwright/test';
import { loginToDashboard } from './fixtures';
test.describe('AetherForge smoke', () => {
test('health endpoint responds', async ({ request }) => {
@@ -9,20 +10,11 @@ test.describe('AetherForge smoke', () => {
});
test('login gate renders and accepts credentials', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'AetherForge' })).toBeVisible({ timeout: 15_000 });
await page.getByLabel('Username').fill('drjones');
await page.getByLabel('Password').fill('czapiewski');
await page.getByRole('button', { name: /enter command deck/i }).click();
await expect(page.getByRole('heading', { name: 'Command Deck' })).toBeVisible({ timeout: 15_000 });
await loginToDashboard(page);
});
test('forge page loads after login', async ({ page }) => {
await page.goto('/');
await page.getByLabel('Username').fill('drjones');
await page.getByLabel('Password').fill('czapiewski');
await page.getByRole('button', { name: /enter command deck/i }).click();
await expect(page.getByRole('heading', { name: 'Command Deck' })).toBeVisible({ timeout: 15_000 });
await loginToDashboard(page);
await page.getByRole('link', { name: /forge/i }).click();
await expect(page.getByRole('heading', { name: 'The Forge' })).toBeVisible({ timeout: 10_000 });
});