diff --git a/artifacts/api-server/tests/admin-app-opens-pagination.test.mjs b/artifacts/api-server/tests/admin-app-opens-pagination.test.mjs index b6e35be6..ca2abccb 100644 --- a/artifacts/api-server/tests/admin-app-opens-pagination.test.mjs +++ b/artifacts/api-server/tests/admin-app-opens-pagination.test.mjs @@ -61,6 +61,16 @@ before(async () => { assert.ok(appRes.rows[0], "no active app found to test against"); appId = appRes.rows[0].id; + // Walking pagination assumes totalCount is bounded. Other tests can leave + // app_opens rows behind (or seed/admin runs may have populated some) for + // the same app within the 7d window. Push any pre-existing rows for this + // app outside the window so totalCount reflects only the rows we insert. + await pool.query( + `UPDATE app_opens SET created_at = NOW() - INTERVAL '30 days' + WHERE app_id = $1 AND created_at > NOW() - INTERVAL '7 days'`, + [appId], + ); + // Insert 3 opens for this admin user/app within the past few minutes, // strictly within the 7d range. const now = Date.now();