All checks were successful
deploy / deploy (push) Successful in 1m0s
Proof: Added PostgreSQL-backed quote lifecycle statistics for all-time, monthly, weekly, daily, hourly, and five-minute windows; wired authenticated dashboard API, live WebSocket counters, history-writer refresh before pruning, and dashboard controls; validated with targeted tests, full npm test, and operator dashboard build. Assumptions: Unique quote counts are keyed by durable quote_id, quote windows use the first durable lifecycle timestamp in UTC with Monday UTC weeks, and missing identifiers or timestamps are represented as unavailable evidence instead of fabricated quote identities. Still fake: Fee-aware PnL, cashflow, oracle-deviation, size distribution, matched-only analytics, and reconstruction of already-pruned detail remain outside this turn.
67 lines
3.4 KiB
JavaScript
67 lines
3.4 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, /minNotional: bodyField\(body, 'min_notional', 'minNotional'\)/);
|
|
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 exposes authenticated durable quote lifecycle lookup API', () => {
|
|
assert.match(source, /quote-lifecycle/);
|
|
assert.match(source, /lifecycleLookupMatch/);
|
|
assert.match(source, /loadQuoteLifecycleLookupEvidence/);
|
|
assert.match(source, /buildQuoteLifecycleLookupResponse/);
|
|
assert.match(source, /quote_lifecycle_identifier_required/);
|
|
assert.match(source, /quote_lifecycle_not_found/);
|
|
assert.match(source, /payload\.ok \? 200 : 404/);
|
|
});
|
|
|
|
test('operator dashboard exposes authenticated persisted quote lifecycle statistics API', () => {
|
|
assert.match(source, /\/api\/strategy\/quote-lifecycle\/statistics/);
|
|
assert.match(source, /loadQuoteLifecycleStatisticsPayload/);
|
|
assert.match(source, /refreshQuoteLifecycleStatistics/);
|
|
assert.match(source, /loadQuoteLifecycleStatistics/);
|
|
assert.match(source, /quote_lifecycle_statistics/);
|
|
});
|
|
|
|
test('operator dashboard bootstrap does not synchronously refresh intent request outcomes', () => {
|
|
assert.match(source, /loadRecentIntentRequests\(pool, \{[\s\S]*refreshOutcomes: false/);
|
|
});
|
|
|
|
test('operator dashboard disconnects backpressured websocket clients before buffering unbounded updates', () => {
|
|
assert.match(source, /isDashboardWebSocketBackpressured/);
|
|
assert.match(source, /dashboard_websocket_backpressure_disconnect/);
|
|
assert.match(source, /buffered_amount: Number\(socket\.bufferedAmount \|\| 0\)/);
|
|
assert.match(source, /socket\.terminate\?\.\(\)/);
|
|
});
|