Files
MyIP/tests/tool-cache.test.js
T
Claude 44e897a48b Refactor(router): keep the homepage and tool pages alive
App.vue wraps the router view in a KeepAlive holding Home and the tool
page, so leaving for /tools/:slug and coming back neither re-runs the
homepage tests nor loses the scroll position; ToolPage (StandaloneTool
renamed) reads its slug reactively — the same instance now switches tool
on in-app navigation — and caches each visited tool per slug in its own
KeepAlive (max 8), dropping them all when the signed-in account goes
away (utils/tool-cache.js).

Cached pages pause while hidden: composables/use-route-active.js gives
useRouteActive / useActiveValue / useActiveEventListener, and the head
writer, the shortcut map, the scroll trackers, the ?q= watchers of ASN
Profile and IP Calculator, the User dialog triggers and the overlay
counter all act only for the page on screen. An overlay still open when
its page is left closes, as its portal lives outside the cached page.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GbLTGMZ45MV78qd2tHoco
2026-10-05 13:56:19 +00:00

30 lines
1.0 KiB
JavaScript

// shouldDropToolCache() — when ToolPage drops every cached tool (the auth
// epoch): the signed-in account went away, never on a first sign-in.
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { shouldDropToolCache } from '../frontend/utils/tool-cache.js';
describe('shouldDropToolCache()', () => {
it('drops on sign-out', () => {
assert.equal(shouldDropToolCache('uid-a', null), true);
});
it('drops on an account switch', () => {
assert.equal(shouldDropToolCache('uid-a', 'uid-b'), true);
});
it('keeps the cache on a first sign-in', () => {
assert.equal(shouldDropToolCache(null, 'uid-a'), false);
assert.equal(shouldDropToolCache(undefined, 'uid-a'), false);
});
it('keeps the cache while the same account stays signed in (token refresh)', () => {
assert.equal(shouldDropToolCache('uid-a', 'uid-a'), false);
});
it('keeps the cache while nobody is signed in', () => {
assert.equal(shouldDropToolCache(null, null), false);
});
});