From 9befe9997e48261b67ee1680db45ad5a9be6e4c7 Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Tue, 31 Mar 2026 04:09:43 -0700 Subject: [PATCH] test: add formatLastSeen verification tests across all time ranges --- muxplex/frontend/tests/test_app.mjs | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/muxplex/frontend/tests/test_app.mjs b/muxplex/frontend/tests/test_app.mjs index 5f0e085..9851bd2 100644 --- a/muxplex/frontend/tests/test_app.mjs +++ b/muxplex/frontend/tests/test_app.mjs @@ -3181,3 +3181,33 @@ test('openLoginPopup handles URL with trailing slash', () => { assert.strictEqual(openCalls[0], 'http://work:8088/login', 'should strip trailing slash then append /login'); }); +// --- formatLastSeen (auto-recovery detection) --- + +test('formatLastSeen returns seconds for recent timestamps', () => { + const thirtySecondsAgo = Date.now() - 30000; + assert.match(app.formatLastSeen(thirtySecondsAgo), /^\d+s ago$/); +}); + +test('formatLastSeen returns minutes for older timestamps', () => { + const fiveMinutesAgo = Date.now() - 5 * 60 * 1000; + assert.match(app.formatLastSeen(fiveMinutesAgo), /^\d+m ago$/); +}); + +test('formatLastSeen returns hours for much older timestamps', () => { + const threeHoursAgo = Date.now() - 3 * 3600 * 1000; + assert.match(app.formatLastSeen(threeHoursAgo), /^\d+h ago$/); +}); + +test('formatLastSeen returns days for very old timestamps', () => { + const twoDaysAgo = Date.now() - 2 * 86400 * 1000; + assert.match(app.formatLastSeen(twoDaysAgo), /^\d+d ago$/); +}); + +test('formatLastSeen returns Never for null', () => { + assert.strictEqual(app.formatLastSeen(null), 'Never'); +}); + +test('formatLastSeen returns Never for undefined', () => { + assert.strictEqual(app.formatLastSeen(undefined), 'Never'); +}); +