Conversation
… test - Add timestamp-based unique identifiers for usernames, emails, team slugs, and event type slugs - Implement proper error handling in test cleanup with null checks and try-catch blocks - Prevents PrismaClientKnownRequestError: Unique constraint failed on email fields - Fixes TypeError: Cannot read properties of undefined (reading 'id') in cleanup - All 114 integration tests now pass (previously 113/114) Co-Authored-By: zomars@cal.com <zomars@me.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
WalkthroughThe integration test setup for event types was updated to ensure unique test data by appending timestamps to identifiers. Cleanup logic was improved with error handling, conditional deletions based on resource existence, and logging of cleanup failures to enhance test isolation and robustness. Changes
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/trpc/server/routers/viewer/eventTypes/listWithTeam.handler.integration-test.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-playwright". (The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (5)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
✅ No security or compliance issues detected. Reviewed everything up to 6664aa2. Security Overview
Detected Code Changes
Reply to this PR with |
Graphite Automations"Add foundation team as reviewer" took an action on this PR • (07/14/25)1 reviewer was added to this PR based on Keith Williams's automation. |
E2E results are ready! |
… listWithTeam integration test
Originally by: zomars
# fix: resolve unique constraint violations in listWithTeam integration test
## Summary
Fixed a failing integration test in `listWithTeam.handler.integration-test.ts` that was causing unique constraint violations. The test was using hardcoded email addresses and slugs that persisted between test runs, causing failures when the same test data already existed in the database.
**Key changes:**
- Added timestamp-based unique identifiers for usernames, emails, team slugs, and event type slugs
- Implemented robust error handling in test cleanup with null checks and try-catch blocks
- Test success rate improved from 113/114 to 114/114 (100% pass rate)
**Root cause:** The test used static values like `testuser-lwt-1@example.com` and `team-1-lwt` that violated unique constraints on subsequent test runs.
## Review & Testing Checklist for Human
- [ ] **Verify test passes consistently** - Run `TZ=UTC yarn test -- --integrationTestsOnly` multiple times to ensure the fix is robust
- [ ] **Check timestamp uniqueness approach** - Confirm that `Date.now()` provides sufficient uniqueness for concurrent test scenarios
- [ ] **Validate cleanup logic** - Ensure the new error handling in `afterAll` properly cleans up test data without masking real errors
- [ ] **Test multiple rapid runs** - Execute the test suite several times in quick succession to verify no race conditions exist
---
### Diagram
```mermaid
%%{ init : { "theme" : "default" }}%%
graph TD
Test["packages/trpc/server/routers/viewer/eventTypes/<br/>listWithTeam.handler.integration-test.ts"]:::major-edit
Handler["listWithTeam.handler"]:::context
UserModel["User (Prisma Model)"]:::context
TeamModel["Team (Prisma Model)"]:::context
EventTypeModel["EventType (Prisma Model)"]:::context
Test --> Handler
Test --> UserModel
Test --> TeamModel
Test --> EventTypeModel
Test -- "creates with unique timestamps" --> UserModel
Test -- "creates with unique slugs" --> TeamModel
Test -- "creates with unique slugs" --> EventTypeModel
subgraph Legend
L1[Major Edit]:::major-edit
L2[Minor Edit]:::minor-edit
L3[Context/No Edit]:::context
end
classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
```
### Notes
- This fix addresses the PrismaClientKnownRequestError: Unique constraint failed on the fields: (`email`) that was preventing the integration test suite from achieving 100% pass rate
- The solution maintains test isolation by ensuring each test run creates truly unique database records
- Session requested by @zomars: https://app.devin.ai/sessions/3d62b140e87c424ab80c9ed76ac298ca
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Tests**
* Improved test reliability by ensuring unique test data for each run and enhancing cleanup procedures for better error handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
fix: resolve unique constraint violations in listWithTeam integration test
Summary
Fixed a failing integration test in
listWithTeam.handler.integration-test.tsthat was causing unique constraint violations. The test was using hardcoded email addresses and slugs that persisted between test runs, causing failures when the same test data already existed in the database.Key changes:
Root cause: The test used static values like
testuser-lwt-1@example.comandteam-1-lwtthat violated unique constraints on subsequent test runs.Review & Testing Checklist for Human
TZ=UTC yarn test -- --integrationTestsOnlymultiple times to ensure the fix is robustDate.now()provides sufficient uniqueness for concurrent test scenariosafterAllproperly cleans up test data without masking real errorsDiagram
%%{ init : { "theme" : "default" }}%% graph TD Test["packages/trpc/server/routers/viewer/eventTypes/<br/>listWithTeam.handler.integration-test.ts"]:::major-edit Handler["listWithTeam.handler"]:::context UserModel["User (Prisma Model)"]:::context TeamModel["Team (Prisma Model)"]:::context EventTypeModel["EventType (Prisma Model)"]:::context Test --> Handler Test --> UserModel Test --> TeamModel Test --> EventTypeModel Test -- "creates with unique timestamps" --> UserModel Test -- "creates with unique slugs" --> TeamModel Test -- "creates with unique slugs" --> EventTypeModel subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
email) that was preventing the integration test suite from achieving 100% pass rateSummary by CodeRabbit