diff --git a/tests/browser/workspace-system-diagnostics.spec.mjs b/tests/browser/workspace-system-diagnostics.spec.mjs index 9eb07de6..c0bcb963 100644 --- a/tests/browser/workspace-system-diagnostics.spec.mjs +++ b/tests/browser/workspace-system-diagnostics.spec.mjs @@ -123,6 +123,9 @@ test('meta-grid shows real database and source status, the pinned Viewer.js vers await expect(surface.locator('.meta-grid dt')).toHaveText(['Database', 'Sources', 'Viewer.js', 'Host renderers']); const images = report.checks.database.image_count; await expect(cell(page, 'Database')).toHaveText(new RegExp(`^Readable · [\\d.]+ (bytes|KB|MB|GB) · ${images.toLocaleString('en-US')} images?$`)); + // The size is the database's real size (`database_size_bytes`), never a missing key read as 0. + expect(report.database_info.database_size_bytes).toBeGreaterThan(0); + await expect(cell(page, 'Database')).not.toContainText('· 0 bytes ·'); const { configured, watching } = report.sources; await expect(cell(page, 'Sources')).toHaveText(configured ? `${configured} source${configured === 1 ? '' : 's'} · ${watching} watching` diff --git a/tests/js/workspace-system-diagnostics.test.js b/tests/js/workspace-system-diagnostics.test.js index 58348dae..65b0bddb 100644 --- a/tests/js/workspace-system-diagnostics.test.js +++ b/tests/js/workspace-system-diagnostics.test.js @@ -14,7 +14,7 @@ const SYSTEM = fs.readFileSync(path.join(__dirname, '../../web/js/workspace/syst const REPORT = { checks: { database: { status: 'ok', prompt_count: 4210, has_images_table: true, image_count: 19956 } }, - database_info: { database_path: 'user/__promptmanager/prompts.db', size_bytes: 1717986918 }, + database_info: { database_path: 'user/__promptmanager/prompts.db', database_size_bytes: 1717986918 }, sources: { configured: 2, effective: 2, watching: 2, unavailable: 0 }, viewerjs: '1.15.2', }; @@ -45,7 +45,7 @@ test('database text covers readable, not readable, busy and loading', async () = const { databaseText, LOADING, UNREADABLE } = await diagnostics; assert.equal(databaseText({ report: REPORT }), 'Readable · 1.6 GB · 19,956 images'); assert.equal(databaseText({ report: { ...REPORT, checks: { database: { status: 'ok', image_count: 1 } }, - database_info: { size_bytes: 2048 } } }), 'Readable · 2.0 KB · 1 image'); + database_info: { database_size_bytes: 2048 } } }), 'Readable · 2.0 KB · 1 image'); assert.equal(databaseText({ report: { checks: { database: { status: 'error', message: 'Database error: locked' } } } }), 'Not readable: Database error: locked'); assert.equal(databaseText({ loading: true }), LOADING); diff --git a/web/js/workspace/system-diagnostics.mjs b/web/js/workspace/system-diagnostics.mjs index 3541e9c0..40382ae0 100644 --- a/web/js/workspace/system-diagnostics.mjs +++ b/web/js/workspace/system-diagnostics.mjs @@ -114,7 +114,7 @@ export function databaseText(state) { const check = report?.checks?.database; if (check?.status !== 'ok') return `Not readable: ${check?.message || 'no answer from the database'}`; const images = Number.isSafeInteger(check.image_count) ? check.image_count : 0; - return `Readable · ${sizeText(report.database_info?.size_bytes)} · ${number(images)} ${noun(images, 'image')}`; + return `Readable · ${sizeText(report.database_info?.database_size_bytes)} · ${number(images)} ${noun(images, 'image')}`; }); }