unrip/test/operator-dashboard-app-static.test.mjs
philipp edfa14f37e
Some checks failed
deploy / deploy (push) Failing after 34s
Add dashboard pair controls
Proof: npm test passed 171/171; npm run operator-dashboard:build passed; regression tests cover pair activation/pause fail-closed behavior, per-pair edge controls, and asset deposit address exposure.

Assumptions: Activating a directed pair is operator-approved live-funds-adjacent control; trading still requires existing DB strategy config, price route, armed services, and inventory, so unsupported imported assets remain blocked.

Still fake: no new price routes or liquidity discovery were added; non-current pairs without routes/config remain visible but cannot trade.
2026-05-13 12:51:35 +02:00

28 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = readFileSync(new URL('../src/apps/operator-dashboard.mjs', import.meta.url), 'utf8');
test('operator dashboard awaits API handler promises so request errors reach the top-level catch', () => {
assert.equal(source.includes('return await handleApiRequest({ req, res, url, auth });'), true);
assert.equal(source.includes('return handleApiRequest({ req, res, url, auth });'), false);
});
test('operator dashboard control proxy catches upstream failures before sending JSON response', () => {
assert.match(source, /dashboard_control_failed/);
assert.match(source, /buildDashboardControlErrorResponse/);
assert.match(source, /failure.statusCode/);
});
test('operator dashboard requests enough asset catalog rows for the current 1Click import', () => {
assert.match(source, /loadAssetCatalogSummary\(pool,\s*\{\s*limit:\s*250\s*\}\)/);
assert.doesNotMatch(source, /loadAssetCatalogSummary\(pool,\s*\{\s*limit:\s*80\s*\}\)/);
});
test('operator dashboard exposes DB-backed pair activation and pause controls', () => {
assert.match(source, /setTradingPairMode/);
assert.match(source, /pauseTradingPair/);
assert.match(source, /control\.action === 'set-pair-mode'/);
assert.match(source, /control\.action === 'pause-pair'/);
});