Admin: add games from any list or itch.io collection (Check first, batches of 200, per-game ingest tracking from scripts/state/ingest_outcomes.json), followed collections and auto-approve run by the cron in one [auto] commit, bulk remove/edit up to 100 games in one commit, New games, Activity and Settings pages. D1 migration 0002 (applied to production before this merge). Policies (ToS, Privacy, Disclaimer, EN + VI) cover approval by the maintainer's rules; LEGAL_VERSION 2026-10-13. Web: the theme button shows the theme in use, no dark-mode flash (pre-paint script, hash in three CSPs), Charts tabs stay mounted (no rebuilt charts or replayed animations), 300 ms entrances, scrollbar gutter on mouse devices. Release 4.4.0 (changelog also covers #130). [skip-discuss] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { capBatches, summarize, type TrackedBatch } from './tracking'
|
|
|
|
const batch = (n: number, size: number): TrackedBatch => ({
|
|
id: String(n),
|
|
label: `b${n}`,
|
|
at: '2026-10-13T00:00:00Z',
|
|
urls: Array.from({ length: size }, (_, i) => `https://dev.itch.io/g${n}-${i}`),
|
|
})
|
|
|
|
describe('tracked batches', () => {
|
|
it('keeps the newest 20 batches and at most 10,000 URLs', () => {
|
|
expect(capBatches(Array.from({ length: 25 }, (_, i) => batch(i, 1))).map((b) => b.id)).toEqual(
|
|
Array.from({ length: 20 }, (_, i) => String(i)),
|
|
)
|
|
expect(capBatches([batch(1, 6000), batch(2, 5000), batch(3, 10)]).map((b) => b.id)).toEqual(['1'])
|
|
})
|
|
|
|
it('counts games per state', () => {
|
|
expect(
|
|
summarize([
|
|
{ url: 'a', state: 'added' },
|
|
{ url: 'b', state: 'added' },
|
|
{ url: 'c', state: 'dropped', outcome: 'paid' },
|
|
{ url: 'd', state: 'waiting' },
|
|
]),
|
|
).toEqual({ added: 2, waiting: 1, dropped: 1, unknown: 0 })
|
|
})
|
|
})
|