test: fix cron email CI expectations#1853
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors email-preferences tests to use isolated user state and a shared reset helper, adds Bento-configuration gating for certain cron_email tests, and updates cron_email error-case expectations and test inputs to reflect new validation/error behaviors. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/email-preferences.test.ts`:
- Around line 39-44: The helper resetEmailPreferences silently ignores Supabase
errors; update it (the async function resetEmailPreferences that calls
getSupabaseClient().from('users').update(...).eq('id', USER_ID_EMAIL_PREFS)) to
capture the update response, check for response.error (and/or non-OK status),
and throw or fail the test when an error exists so the reset cannot silently
fail and leak state to other tests; ensure the error message includes context
(e.g., "resetEmailPreferences failed") and the Supabase error details.
- Around line 54-65: Reorder the test lifecycle hooks so they follow the
required sequence: beforeAll → beforeEach → afterEach → afterAll; specifically
move the beforeEach(async () => { await resetEmailPreferences() }) so it appears
before the afterEach and afterAll blocks (retaining the afterEach(async () => {
await resetEmailPreferences() }) and afterAll(async () => { await
resetAppData(APPNAME_PREFS); await resetEmailPreferences() }) unchanged),
ensuring the hooks around resetEmailPreferences and resetAppData remain but
follow the correct hook order.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3cf6bb57-0646-42d6-ae91-6974cb363677
📒 Files selected for processing (4)
tests/TEST_USER_MATRIX.mdtests/email-preferences.test.tstests/error-cases.test.tstests/trigger-error-cases.test.ts
|



Summary (AI generated)
/triggers/cron_emailtest expectations with the current validation orderMotivation (AI generated)
The backend test workflow was failing because several cron email tests asserted response shapes that no longer match the current handler behavior, and one preference test assumed Bento-backed notification fan-out was active in CI. That created deterministic failures that looked like flaky test interactions.
Business Impact (AI generated)
This restores green CI for the backend suite, reduces noise around false regression failures, and makes the email preference tests safer to run in parallel by containing their user-state mutations.
Test Plan (AI generated)
bun lintbun lint:backendbun run supabase:with-env -- bunx vitest run tests/email-preferences.test.ts tests/error-cases.test.ts tests/trigger-error-cases.test.tsbun run test:allGenerated with AI
Summary by CodeRabbit