Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: reset the overview scan cache with a fake clock instead of an extra export (#12994)

[._.]/ Adam Eivy39bb9087aa41
diff --git a/server/services/dataManager.js b/server/services/dataManager.js
index 2c6012a6ad..ece9e1090f 100644
--- a/server/services/dataManager.js
+++ b/server/services/dataManager.js
@@ -365,7 +365,7 @@ async function getDirSizeAndCount(dirPath, { strict = false } = {}) {
const OVERVIEW_SCAN_TTL_MS = 30_000;
const overviewScans = new Map();
-export function invalidateOverviewScan() {
+function invalidateOverviewScan() {
overviewScans.clear();
}
diff --git a/server/services/dataManager.strict.test.js b/server/services/dataManager.strict.test.js
index 7b7f66e89c..2780604ed1 100644
--- a/server/services/dataManager.strict.test.js
+++ b/server/services/dataManager.strict.test.js
@@ -42,12 +42,15 @@ vi.mock('./dataManagerBusy.js', () => ({
updateDetachedBusy: vi.fn(async () => ({ busy: false })),
}));
-const { getDataOverview, deleteBackup, invalidateOverviewScan } = await import('./dataManager.js');
+const { getDataOverview, deleteBackup } = await import('./dataManager.js');
+afterAll(() => vi.useRealTimers());
afterAll(() => rmSync(testDataRoot, { recursive: true, force: true }));
+// Each case starts past the overview scan's 30s TTL so no result carries over.
+let clock = Date.now();
beforeEach(() => {
- invalidateOverviewScan();
+ vi.useFakeTimers({ toFake: ['Date'], now: (clock += 60_000) });
mocks.statErrorPath = null; mocks.countErrorPath = null; mocks.virtualCount = 0;
rmSync(testDataRoot, { recursive: true, force: true });
mkdirSync(join(testDataRoot, 'cache'), { recursive: true });