Skip to content

Fix test suite (failing on every PR since Sept 2025) - #7

Merged
rphovley merged 1 commit into
mainfrom
fix/test-suite-green
Oct 23, 2026
Merged

rphovley merged 1 commit into
mainfrom
fix/test-suite-green

Conversation

@rphovley

Copy link
Copy Markdown
Member

Summary

The Run Tests workflow has failed on every PR since September 2025, so the CVE PRs (#5, #6) show red checks for reasons unrelated to their changes. This PR gets the suite to 114/114 passing.

Import-time crash (the CI failure)

  • SlackOAuthService built an EbbEncryption at module load, which throws when SLACK_ENCRYPTION_KEY is unset. Every test file imports the app, so all 13 files died before running a single test. It is now constructed lazily on first encrypt/decrypt.

Stale tests

  • LicenseService.startFreeTrial checks getLicenseByUserId, not getActiveLicenseByUserId.
  • LicenseRepo.updateLicenseByStripePaymentId was renamed to updateLicenseByCustomerId.
  • Checkout webhook updates now set expiration_date: null (commit 9c176e0).
  • Discord weekly-report embed title is 📊 Weekly Report Reminder.

mock.module leaks between files

Bun's mock.module replaces a module for the whole run, not just the current file. Two license-repo stubs leaked into the checkout e2e tests, and the idempotency test's NotificationEngine stub leaked into the WebhookService tests. Fixed by using spyOn for LicenseRepo and restoring the real modules in afterAll for the notification tests.

Local convenience

  • TEST_DB_PORT can override the test database port when 5433 is taken locally. CI behaviour is unchanged.

Test plan

  • bun test locally: 114 pass, 0 fail, two consecutive runs
  • Run Tests workflow green on this PR

🤖 Generated with Claude Code

The Run Tests workflow has failed on every PR since September 2025.

- SlackOAuthService constructed EbbEncryption at import time, so every test
  file crashed on load when SLACK_ENCRYPTION_KEY was unset. Construct it
  lazily on first encrypt/decrypt instead.
- Update tests that drifted from the code: LicenseService now checks
  getLicenseByUserId, LicenseRepo.updateLicenseByStripePaymentId was renamed
  to updateLicenseByCustomerId, checkout updates now set expiration_date to
  null, and the Discord weekly-report embed title changed.
- Bun's mock.module applies to every test file in the run. The LicenseRepo
  stubs in two files leaked into the checkout e2e tests and the
  NotificationEngine stub leaked into WebhookService tests. Use spies for
  LicenseRepo and restore the real modules in afterAll for the notification
  tests.
- Allow TEST_DB_PORT to override the test database port for local runs
  where 5433 is already taken.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@rphovley
rphovley merged commit abc585f into main Oct 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant