Skip to content

Conversation

@ThyMinimalDev
Copy link
Contributor

@ThyMinimalDev ThyMinimalDev commented Jan 20, 2026

What does this PR do?

Ensures default calendars are created for organization users via the new CalendarsTasker in API v2. Uses Trigger.dev when async tasking is enabled (enableAsyncTasker config), and falls back to Bull queue with idempotent jobs when disabled.

Link to Devin run: https://app.devin.ai/sessions/71826d8b4e2d4185b532187371bfdc28
Requested by: morgan@cal.com (@ThyMinimalDev)

Updates since last revision

Added comprehensive test coverage for the CalendarsTasker integration:

  • Unit tests: 4 new tests for ensureDefaultCalendarsForUser when enableAsyncTasker is true
    • Verifies CalendarsTasker.dispatch is called with correct idempotency key
    • Verifies Bull queue is not used when async tasker is enabled
    • Verifies graceful error handling when tasker dispatch fails
    • Verifies early return for invalid emails
  • E2E test: Verifies ensureDefaultCalendarsForUser is called when creating organization membership
  • Config fix: Added **/*.spec.ts to biome test file exceptions for noExcessiveLinesPerFunction rule

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - no docs changes needed.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Unit tests: Run from apps/api/v2 directory:

    TZ=UTC npx jest --testPathPattern="organizations-delegation-credential.service.spec.ts"

    Expected: All 17 tests pass (13 existing + 4 new async tasker tests)

  2. E2E test: The new test verifies the service method is called when creating a membership via the API

  3. Manual testing:

    • Set enableAsyncTasker: true in config
    • Create an organization membership
    • Verify CalendarsTasker dispatches the ensureDefaultCalendars job with idempotency key

Human Review Checklist

  • Verify CalendarsTasker.dispatch call signature matches the actual service interface
  • Verify idempotency key format (${DEFAULT_CALENDARS_JOB}_${userId}) is correct
  • Verify the e2e test cleanup in finally block properly removes test data
  • Verify biome.json change to add **/*.spec.ts doesn't have unintended side effects on other spec files

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings

Summary by cubic

Ensures default calendars are created for organization users via the new CalendarsTasker in API v2. Uses Trigger.dev when async tasking is enabled, and falls back to Bull with idempotent jobs.

  • New Features

    • Added CalendarsTaskerModule to organizations, delegation credentials, and selected-calendars modules.
    • Updated delegation credential service to dispatch ensureDefaultCalendars jobs via CalendarsTasker (with idempotency), or Bull queue when disabled.
    • API docs: deprecated loggedInUsersTz for /calendars/busy-times and added timeZone; added eventTypeId filter to schedules; streamlined examples.
  • Dependencies

    • Exposed @calcom/platform-libraries/calendars and added build entry.
    • Added tsconfig path alias for platform calendars library.

Written for commit 820b7c6. Summary will update on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 8 files

- Add unit tests for CalendarsTasker.dispatch when enableAsyncTasker is true
- Add e2e test to verify ensureDefaultCalendarsForUser is called when creating membership
- Mock CalendarsTasker and ConfigService in unit tests
- Test both async (Trigger.dev) and sync (Bull queue) paths
- Fix missing return types on helper functions in e2e tests
- Add *.spec.ts to biome test file exceptions for noExcessiveLinesPerFunction rule

Co-Authored-By: morgan@cal.com <morgan@cal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only foundation size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants