import { test } from '@japa/runner' import { historyRows } from '#services/planner' test.group('Planner / history rows', () => { test('a group planned for the first time: the ancient range below the low watermark, then the slices', ({ assert, }) => { const rows = historyRows(7, { low: 1001, high: 3500 }, 0, 1000) assert.deepEqual( rows.map((r) => [r.start_id, r.end_id, r.next_id, r.priority, r.status ?? 'planned']), [ [1, 1000, 1, 0, 'ancient'], [1001, 2000, 1001, 0, 'planned'], [2001, 3000, 2001, 400, 'planned'], [3001, 3500, 3001, 800, 'planned'], ] ) }) test('no ancient range when the group starts at article 1, nor when planning again', ({ assert, }) => { assert.deepEqual( historyRows(7, { low: 1, high: 1500 }, 0, 1000).map((r) => [r.start_id, r.end_id, r.status]), [ [1, 1000, undefined], [1001, 1500, undefined], ] ) // Planned before up to 3500: only the new articles, no second ancient range. assert.deepEqual( historyRows(7, { low: 1200, high: 4100 }, 3500, 1000).map((r) => [r.start_id, r.end_id]), [[3501, 4100]] ) }) })