Some checks failed
deploy / deploy (push) Failing after 33s
Proof: npm test (217/217), npm run operator-dashboard:build, and focused intent/trading-config tests cover DB-null request amount and slippage limits. Assumptions: removing request amount and slippage caps is explicitly operator-approved for the current live-funds workflow; preflight remains side-effect-free and submit remains separate. Still fake: request settlement truth still depends on inventory-delta attribution instead of venue-native terminal fill events.
41 lines
2.1 KiB
JavaScript
41 lines
2.1 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'/);
|
|
assert.match(source, /edgeBps: body\.edge_bps/);
|
|
assert.match(source, /maxNotional: body\.max_notional/);
|
|
assert.match(source, /requestMaxNotional: bodyField\(body, 'request_max_notional', 'requestMaxNotional'\)/);
|
|
assert.match(source, /requestMaxSlippageBps: bodyField\(body, 'request_max_slippage_bps', 'requestMaxSlippageBps'\)/);
|
|
});
|
|
|
|
test('operator dashboard API auth failures are JSON for frontend fetches', () => {
|
|
assert.match(source, /req\.url \|\| ''\)\.startsWith\('\/api\/'\)/);
|
|
assert.match(source, /sendJson\(res, 401, \{ error: 'authentication_required' \}\)/);
|
|
});
|
|
|
|
test('operator dashboard bootstrap does not synchronously refresh intent request outcomes', () => {
|
|
assert.match(source, /loadRecentIntentRequests\(pool, \{[\s\S]*refreshOutcomes: false/);
|
|
});
|