adjust the kpi card minigraph to be limited by publish cutoff time

This commit is contained in:
Alberto-Audrix committed 2026-09-07 14:30:55 +07:00
1 parent 3ba6fed189
commit 155a24c7bd
3 files changed
+73 -10

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';
import { isOnOrBeforeVisibleDate, throughVisibleDate } from '../visibility.ts';
describe('throughVisibleDate', () => {
const rows = [{ date: '2026-09-05' }, { date: '2026-09-06' }, { date: '2026-09-07' }];
it('drops rows after the publish cutoff', () => {
expect(throughVisibleDate(rows, '2026-09-06')).toEqual([
{ date: '2026-09-05' },
{ date: '2026-09-06' },
]);
});
it('returns all rows when cutoff is missing', () => {
expect(throughVisibleDate(rows, undefined)).toEqual(rows);
expect(throughVisibleDate(rows, null)).toEqual(rows);
});
});
describe('isOnOrBeforeVisibleDate', () => {
it('rejects dates after the cutoff', () => {
expect(isOnOrBeforeVisibleDate('2026-09-07', '2026-09-06')).toBe(false);
});
it('accepts dates on or before the cutoff', () => {
expect(isOnOrBeforeVisibleDate('2026-09-06', '2026-09-06')).toBe(true);
expect(isOnOrBeforeVisibleDate('2026-09-05', '2026-09-06')).toBe(true);
});
it('rejects empty dates', () => {
expect(isOnOrBeforeVisibleDate(null, '2026-09-06')).toBe(false);
expect(isOnOrBeforeVisibleDate(undefined, '2026-09-06')).toBe(false);
});
});