cal.com
cal.com copied to clipboard
refactor: API POST /teams
Fixes https://github.com/calcom/cal.com/issues/9127
Loom: https://www.loom.com/share/c9e6c761be9b48d3847b176d458d81b1
This PR has 2 refactors:
- Allow admins to create teams on the behalf of other users.
- Create team only after receiving payment.
Allow admins to create teams on the behalf of other users
File apps/api/lib/validations/team.ts has been updated to allow passing "ownerId" in the request body to specify on behalf of who should the team be created. Notably, only admins can do this as seen by the "checkPermissions" in api/teams/_post.ts - if user is admin and "ownerId" is in the request body, then we specify "const effectiveUserId = isAdmin && ownerId ? ownerId : userId;" which is used to determine owner of the team.
Create team only after receiving payment
New Prisma model - "AwaitingPaymentTeam" has been added to schema.prisma in order to store team information submitted to api/teams/_post.ts. We need it because we can't store keys with boolean values in Stripe checkout metadata while we have "hideBookATeamMember": true / fase and "isPrivate": true / false as required properties when creating a team.
-
After receiving request api/teams/_post.ts will store team's data in the "AwaitingPaymentTeam" table, and create a new stripe checkout session where metadata contains id of the newly created "AwaitingPaymentTeam" and "ownerId". User will receive stripe link to pay:
-
After user pays, he / she will be re-directed to the success_url that was specified by "generateTeamCheckoutSession" when creating session in step 1, which is the api/teams/api/create.ts page. It will check stripe metadata "awaitingPaymentTeamId", fetch it and using the data create an actual team that is returned to user and the awaiting payment team is deleted.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| api | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jan 16, 2024 5:33pm |
| dev | ❌ Failed (Inspect) | Jan 16, 2024 5:33pm |
5 Ignored Deployments
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| ai | ⬜️ Ignored (Inspect) | Visit Preview | Jan 16, 2024 5:33pm | |
| cal | ⬜️ Ignored (Inspect) | Visit Preview | Jan 16, 2024 5:33pm | |
| cal-demo | ⬜️ Ignored (Inspect) | Visit Preview | Jan 16, 2024 5:33pm | |
| qa | ⬜️ Ignored (Inspect) | Visit Preview | Jan 16, 2024 5:33pm | |
| ui | ⬜️ Ignored (Inspect) | Visit Preview | Jan 16, 2024 5:33pm |
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.
Current Playwright Test Results Summary
✅ 386 Passing - ⚠️ 12 Flaky
Run may still be in progress, this comment will be updated as current testing workflow or job completes...
(Last updated on 01/16/2024 05:46:08pm UTC)
Run Details
Running Workflow PR Update on Github Actions
Commit: aedbe4fed8185b53af4007997fa8ee7b7b5343d3
Started: 01/16/2024 05:38:50pm UTC
⚠️ Flakes
📄 apps/web/playwright/booking/longTextQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Long Text Question and Each Other Question Booking With Long Text Question and Checkbox Group Question Long Text required and Checkbox Group not required
Retry 1 • Initial Attempt |
0.26% (1)1 / 379 runfailed over last 7 days |
2.37% (9)9 / 379 runsflaked over last 7 days |
📄 apps/web/playwright/login.2fa.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
2FA Tests should allow a user to enable 2FA and login using 2FA
Retry 1 • Initial Attempt |
0% (0)0 / 281 runsfailed over last 7 days |
35.23% (99)99 / 281 runsflaked over last 7 days |
📄 apps/web/playwright/booking/checkboxGroupQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Checkbox Group Question and Each Other Question Booking With Checkbox Group Question and Address Question Booking With Checkbox Group Question and Multi email Question Checkbox Group and Multi email not required
Retry 1 • Initial Attempt |
0.26% (1)1 / 381 runfailed over last 7 days |
2.10% (8)8 / 381 runsflaked over last 7 days |
📄 apps/web/playwright/payment-apps.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Payment app when more than one payment app is installed the price should be updated when changing settings
Retry 1 • Initial Attempt |
0% (0)0 / 382 runsfailed over last 7 days |
4.97% (19)19 / 382 runsflaked over last 7 days |
📄 apps/web/playwright/organization/organization-invitation.e2e.ts • 2 Flakes
Top 1 Common Error Messages
|
|
2 Test Cases Affected |
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Organization Email not matching orgAutoAcceptEmail Org Invitation
Retry 1 • Initial Attempt |
2.22% (9)9 / 406 runsfailed over last 7 days |
13.30% (54)54 / 406 runsflaked over last 7 days |
|
Organization Email matching orgAutoAcceptEmail and a Verified Organization Team Invitation
Retry 1 • Initial Attempt |
4.08% (16)16 / 392 runsfailed over last 7 days |
24.74% (97)97 / 392 runsflaked over last 7 days |
📄 apps/web/playwright/event-types.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Event Types tests user -- future Different Locations Tests Can add Organzer Phone Number location and book with it
Retry 1 • Initial Attempt |
2.22% (9)9 / 406 runsfailed over last 7 days |
3.69% (15)15 / 406 runsflaked over last 7 days |
📄 apps/web/playwright/oauth-provider.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
OAuth Provider should create valid access token & refresh token for team
Retry 1 • Initial Attempt |
0% (0)0 / 409 runsfailed over last 7 days |
20.29% (83)83 / 409 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 4 Flakes
Top 1 Common Error Messages
|
|
4 Test Cases Affected |
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Popup Tests should open Routing Forms embed on click
Retry 1 • Initial Attempt |
-1.98% (-8)-8 / 404 runsfailed over last 7 days |
43.07% (174)174 / 404 runsflaked over last 7 days |
|
Popup Tests should open embed iframe on click - Configured with light theme
Retry 1 • Initial Attempt |
2.17% (9)9 / 414 runsfailed over last 7 days |
54.35% (225)225 / 414 runsflaked over last 7 days |
|
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe according to system theme when no theme is configured through Embed API
Retry 1 • Initial Attempt |
2.72% (11)11 / 404 runsfailed over last 7 days |
76.24% (308)308 / 404 runsflaked over last 7 days |
|
Popup Tests should be able to reschedule
Retry 2 • Retry 1 • Initial Attempt |
13.58% (55)55 / 405 runsfailed over last 7 days |
81.98% (332)332 / 405 runsflaked over last 7 days |
📦 Next.js Bundle Analysis for @calcom/web
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌