Dynamic Dashboard with Widget Library
This commit is contained in:
@@ -1966,6 +1966,25 @@ async function main() {
|
||||
.filter((e) => e.source === `close:${yearClose.id}` && e.account_type === 'Retained earnings');
|
||||
if (!reEntries.length) throw new Error('Year-end roll-forward did not post a Retained Earnings entry');
|
||||
|
||||
// ---- Dashboard designer: per-user layout + depreciation aggregator ----------
|
||||
const freshLayout = await request('/api/dashboard/layout', { headers: auth });
|
||||
if (freshLayout.layout !== null && !Array.isArray(freshLayout.layout)) throw new Error('Dashboard layout endpoint returned an unexpected shape');
|
||||
const myLayout = [
|
||||
{ i: 'portfolio-stats-1', type: 'portfolio-stats', x: 0, y: 0, w: 12, h: 3 },
|
||||
{ i: 'asset-scanner-1', type: 'asset-scanner', x: 0, y: 3, w: 4, h: 5 }
|
||||
];
|
||||
await request('/api/dashboard/layout', { method: 'PUT', headers: auth, body: JSON.stringify({ layout: myLayout }) });
|
||||
const savedLayout = (await request('/api/dashboard/layout', { headers: auth })).layout;
|
||||
if (!Array.isArray(savedLayout) || savedLayout.length !== 2 || savedLayout[0].type !== 'portfolio-stats') throw new Error('Dashboard layout did not persist for the user');
|
||||
// Per-user isolation: a different user has an independent (empty) layout.
|
||||
const otherLayout = (await request('/api/dashboard/layout', { headers: limitedAuth })).layout;
|
||||
if (Array.isArray(otherLayout) && otherLayout.length) throw new Error('Dashboard layout leaked across users');
|
||||
|
||||
// Depreciation aggregator (company A has a depreciating GAAP asset from the close block).
|
||||
const deprAgg = await request('/api/dashboard/depreciation?year=2026', { headers: aHeaders });
|
||||
if (!Array.isArray(deprAgg.byBook) || !deprAgg.byBook.some((b) => b.book === 'GAAP')) throw new Error('Dashboard depreciation aggregator missing byBook/GAAP');
|
||||
if (!Array.isArray(deprAgg.byCategory)) throw new Error('Dashboard depreciation aggregator missing byCategory');
|
||||
|
||||
console.log('Smoke test passed');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user