Some checks failed
deploy / deploy (push) Failing after 39s
Proof: npm test passed 164/164; npm run operator-dashboard:build passed; focused dashboard API client and UI static tests cover timeout, empty HTTP 500, and retry/error loading state. Assumptions: The current stuck dashboard is caused by a stale or unavailable local kubectl port-forward; the app should fail visibly and allow retry instead of waiting forever. Still fake: no public dashboard ingress is part of this turn; local dashboard access still depends on Kubernetes API/port-forward availability.
36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { fetchJson } from '../src/operator-dashboard/static/lib/api.js';
|
|
|
|
test('dashboard fetch helper reports empty upstream 500 responses', async (t) => {
|
|
const originalFetch = globalThis.fetch;
|
|
t.after(() => {
|
|
globalThis.fetch = originalFetch;
|
|
});
|
|
|
|
globalThis.fetch = async () => new Response('', { status: 500 });
|
|
|
|
await assert.rejects(
|
|
fetchJson('/api/session', { timeoutMs: 0 }),
|
|
/HTTP 500/,
|
|
);
|
|
});
|
|
|
|
test('dashboard fetch helper times out stale port-forward requests', async (t) => {
|
|
const originalFetch = globalThis.fetch;
|
|
t.after(() => {
|
|
globalThis.fetch = originalFetch;
|
|
});
|
|
|
|
globalThis.fetch = async (_url, options = {}) => new Promise((_resolve, reject) => {
|
|
options.signal?.addEventListener('abort', () => {
|
|
reject(Object.assign(new Error('aborted'), { name: 'AbortError' }));
|
|
});
|
|
});
|
|
|
|
await assert.rejects(
|
|
fetchJson('/api/bootstrap', { timeoutMs: 1 }),
|
|
/Request timed out after 1ms/,
|
|
);
|
|
});
|