Skip to content

fix(tests): resolve flaky integration tests caused by slug collisions#128

Open
iulspop wants to merge 1 commit intojanhesters:mainfrom
iulspop:fix/flaky-integration-tests-slug-collisions
Open

fix(tests): resolve flaky integration tests caused by slug collisions#128
iulspop wants to merge 1 commit intojanhesters:mainfrom
iulspop:fix/flaky-integration-tests-slug-collisions

Conversation

@iulspop
Copy link
Contributor

@iulspop iulspop commented Feb 9, 2026

Summary

  • Make factory-generated organization slugs unique by default (append cuid suffix) to prevent collisions from faker's limited company name pool
  • Make happy-path test names unique with createId() so route-produced slugs don't collide with stale data
  • Properly await global setup's ensureStripeProductsAndPricesExist() instead of fire-and-forget

Closes #127

Test plan

  • Integration tests pass 5 consecutive full-suite runs (242/242 tests each)
  • Verify no regressions in unit tests and happy-dom tests

🤖 Generated with Claude Code

@iulspop iulspop force-pushed the fix/flaky-integration-tests-slug-collisions branch from 3439d5c to 158288f Compare February 9, 2026 21:26
Factory-generated organization slugs now include a unique cuid suffix to
prevent collisions from faker's limited company name pool. Tests that
assert on route-produced slugs use unique names with createId(). Global
setup properly awaits Stripe seeding instead of fire-and-forget.

Closes janhesters#127

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iulspop iulspop force-pushed the fix/flaky-integration-tests-slug-collisions branch from 158288f to bdef9f0 Compare February 9, 2026 21:30
Copy link
Owner

@janhesters janhesters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iulspop thank you so much for this PR 🙌

I really appreciate you digging into the flaky tests.

That said, I think we should investigate this a bit more deeply and see if we can arrive at a more elegant fix.

My gut feeling is that the underlying issue might be in our test setup rather than the individual test cases. Instead of working around it in the tests, I’d prefer to understand what’s actually causing the collisions.

A couple of thoughts:

  1. Regarding slug collisions:
    If we’re seeing slug collisions, that suggests our middleware isn’t doing what it’s supposed to. We have logic that should prevent collisions (see here). If that’s failing, that’s something we should address directly.

  2. Regarding name collisions:
    Did you notice these collisions happening within the same test run, or only across different runs?

    • If it’s across runs, that could point to issues in our cleanup logic. Ideally, all integration tests with Vitest should use onTestFinished to clean up any data they create. Our Playwright E2E tests also usually have explicit teardown logic at the end.
    • If it’s within the same run, then maybe the right fix is to tweak createPopulatedOrganization() so it appends the id to the organization name by default, rather than adjusting individual tests.

Would you be willing to take a closer look and help us figure out what’s really going on here?

@iulspop
Copy link
Contributor Author

iulspop commented Feb 11, 2026

Would you be willing to take a closer look and help us figure out what’s really going on here?

Yes, I will and get back to you. ETA a week.

@janhesters
Copy link
Owner

@iulspop Sounds good, thank you!

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.

Integration tests are flaky due to slug collisions from faker's limited name pool

2 participants