The running view showed one fixed line for up to 15 minutes, which reads as a
hang. js/running-status.js maps elapsed run time to a line, starting neutral
("Searching Confluence…") and getting more playful at 20 s, 1, 2, 4, 7 and 11
minutes, in the same register as the Exit queue button. app.js re-evaluates
the line every 5 s from wall-clock time (correct after background-tab
throttling), restarts the clock when the running state is entered after a
queue wait, and stops the ticker when the view leaves the running state. The
backend streams no progress, so no line claims a specific activity.
44 lines
2.2 KiB
JavaScript
44 lines
2.2 KiB
JavaScript
/**
|
|
* Unit tests for the running-state status line helper (js/running-status.js).
|
|
*/
|
|
|
|
import { test, describe } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { formatRunningStatus, RUNNING_STATUS_STAGES, RUNNING_STATUS_TICK_MS } from '../js/running-status.js';
|
|
|
|
describe('formatRunningStatus', () => {
|
|
test('starts with the neutral line shown at submit time', () => {
|
|
assert.equal(formatRunningStatus(0), 'Searching Confluence…');
|
|
assert.equal(formatRunningStatus(19_999), 'Searching Confluence…');
|
|
});
|
|
|
|
test('advances through the playful stages at their boundaries', () => {
|
|
assert.equal(formatRunningStatus(20_000), 'Rummaging through the wiki…');
|
|
assert.equal(formatRunningStatus(59_999), 'Rummaging through the wiki…');
|
|
assert.equal(formatRunningStatus(60_000), "Reading everything so you don't have to…");
|
|
assert.equal(formatRunningStatus(120_000), 'Turning pages faster than a human could…');
|
|
assert.equal(formatRunningStatus(240_000), 'Lost in Confluence, found three more tabs…');
|
|
assert.equal(formatRunningStatus(420_000), 'Has anyone updated this page since 2019? Checking…');
|
|
assert.equal(formatRunningStatus(660_000), 'Still at it. If time runs out, it answers with what it found…');
|
|
});
|
|
|
|
test('stays on the last line past the protocol deadline', () => {
|
|
assert.equal(formatRunningStatus(900_000), RUNNING_STATUS_STAGES.at(-1).text);
|
|
assert.equal(formatRunningStatus(3_600_000), RUNNING_STATUS_STAGES.at(-1).text);
|
|
});
|
|
|
|
test('treats negative, NaN and non-number input as just started', () => {
|
|
assert.equal(formatRunningStatus(-5), 'Searching Confluence…');
|
|
assert.equal(formatRunningStatus(NaN), 'Searching Confluence…');
|
|
assert.equal(formatRunningStatus(undefined), 'Searching Confluence…');
|
|
});
|
|
|
|
test('stages are strictly increasing and start at zero', () => {
|
|
assert.equal(RUNNING_STATUS_STAGES[0].fromMs, 0);
|
|
for (let i = 1; i < RUNNING_STATUS_STAGES.length; i++) {
|
|
assert.ok(RUNNING_STATUS_STAGES[i].fromMs > RUNNING_STATUS_STAGES[i - 1].fromMs);
|
|
}
|
|
assert.ok(RUNNING_STATUS_TICK_MS < RUNNING_STATUS_STAGES[1].fromMs, 'first change must be reachable by the ticker');
|
|
});
|
|
});
|