test: add 20s timeout to 365d trends dashboard test

This commit is contained in:
2026-05-19 00:19:58 -07:00
parent ed85cc4b5e
commit 24b95eda9d
@@ -907,64 +907,68 @@ test('getTrendsDashboard keeps local-midnight session buckets separate', () => {
} }
}); });
test('getTrendsDashboard supports 365d range and caps day buckets at 365', () => { test(
const dbPath = makeDbPath(); 'getTrendsDashboard supports 365d range and caps day buckets at 365',
const db = new Database(dbPath); { timeout: 20_000 },
withMockNowMs('1772395200000', () => { () => {
try { const dbPath = makeDbPath();
ensureSchema(db); const db = new Database(dbPath);
withMockNowMs('1772395200000', () => {
try {
ensureSchema(db);
const videoId = getOrCreateVideoRecord(db, 'local:/tmp/365d-trends.mkv', { const videoId = getOrCreateVideoRecord(db, 'local:/tmp/365d-trends.mkv', {
canonicalTitle: '365d Trends', canonicalTitle: '365d Trends',
sourcePath: '/tmp/365d-trends.mkv', sourcePath: '/tmp/365d-trends.mkv',
sourceUrl: null, sourceUrl: null,
sourceType: SOURCE_TYPE_LOCAL, sourceType: SOURCE_TYPE_LOCAL,
}); });
const animeId = getOrCreateAnimeRecord(db, { const animeId = getOrCreateAnimeRecord(db, {
parsedTitle: '365d Trends', parsedTitle: '365d Trends',
canonicalTitle: '365d Trends', canonicalTitle: '365d Trends',
anilistId: null, anilistId: null,
titleRomaji: null, titleRomaji: null,
titleEnglish: null, titleEnglish: null,
titleNative: null, titleNative: null,
metadataJson: null, metadataJson: null,
}); });
linkVideoToAnimeRecord(db, videoId, { linkVideoToAnimeRecord(db, videoId, {
animeId, animeId,
parsedBasename: '365d-trends.mkv', parsedBasename: '365d-trends.mkv',
parsedTitle: '365d Trends', parsedTitle: '365d Trends',
parsedSeason: 1, parsedSeason: 1,
parsedEpisode: 1, parsedEpisode: 1,
parserSource: 'test', parserSource: 'test',
parserConfidence: 1, parserConfidence: 1,
parseMetadataJson: null, parseMetadataJson: null,
}); });
const insertDailyRollup = db.prepare( const insertDailyRollup = db.prepare(
` `
INSERT INTO imm_daily_rollups ( INSERT INTO imm_daily_rollups (
rollup_day, video_id, total_sessions, total_active_min, total_lines_seen, rollup_day, video_id, total_sessions, total_active_min, total_lines_seen,
total_tokens_seen, total_cards, CREATED_DATE, LAST_UPDATE_DATE total_tokens_seen, total_cards, CREATED_DATE, LAST_UPDATE_DATE
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`, `,
); );
// Seed 400 distinct rollup days so we can prove the 365d range caps at 365. // Seed 400 distinct rollup days so we can prove the 365d range caps at 365.
const latestRollupDay = 20513; const latestRollupDay = 20513;
const createdAtMs = '1772395200000'; const createdAtMs = '1772395200000';
for (let offset = 0; offset < 400; offset += 1) { for (let offset = 0; offset < 400; offset += 1) {
const rollupDay = latestRollupDay - offset; const rollupDay = latestRollupDay - offset;
insertDailyRollup.run(rollupDay, videoId, 1, 30, 4, 100, 2, createdAtMs, createdAtMs); insertDailyRollup.run(rollupDay, videoId, 1, 30, 4, 100, 2, createdAtMs, createdAtMs);
}
const dashboard = getTrendsDashboard(db, '365d', 'day');
assert.equal(dashboard.activity.watchTime.length, 365);
} finally {
db.close();
cleanupDbPath(dbPath);
} }
});
const dashboard = getTrendsDashboard(db, '365d', 'day'); },
);
assert.equal(dashboard.activity.watchTime.length, 365);
} finally {
db.close();
cleanupDbPath(dbPath);
}
});
});
test('getTrendsDashboard month grouping spans every touched calendar month and keeps progress monthly', () => { test('getTrendsDashboard month grouping spans every touched calendar month and keeps progress monthly', () => {
const dbPath = makeDbPath(); const dbPath = makeDbPath();