Skip to content

test: test cases for POST selected-calendars#15873

Merged
keithwillcode merged 2 commits intocalcom:mainfrom
Lucas13032003:test-selected_calendars_post
Jul 24, 2024
Merged

test: test cases for POST selected-calendars#15873
keithwillcode merged 2 commits intocalcom:mainfrom
Lucas13032003:test-selected_calendars_post

Conversation

@Lucas13032003
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds unit tests for the POST /api/selected-calendars endpoint. It tests various scenarios including:

  • Non-admin users trying to set userId in the body.
  • Invalid request body scenarios.
  • Successful creation of selected calendars for both admin and non-admin users.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Run the unit tests added in this PR to verify different scenarios for the POST /api/selected-calendars endpoint.
  2. Ensure that the Prisma mock functions correctly simulate database interactions.
  3. Check for proper error handling when a non-admin user attempts to set userId in the request body.
  4. Validate that a 400 status code is returned for invalid request bodies.
  5. Confirm that the selected calendar is created successfully for both admin and non-admin users under the correct conditions.
  • Are there environment variables that should be set?
    No additional environment variables are required for these tests.
  • What are the minimal test data to have?
    Ensure that mock data is in place for user and selected calendar entities.
  • What is expected (happy path) to have (input and output)?
    For valid requests, the endpoint should create a selected calendar and return a 200 status code with the expected response data.
  • Any other important info that could help to test that PR
    Make sure to run the tests in an environment where the Prisma client is properly mocked.

Checklist

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 23, 2024

@Lucas13032003 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jul 23, 2024

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app Bot added the community Created by Linear-GitHub Sync label Jul 23, 2024
@graphite-app graphite-app Bot requested a review from a team July 23, 2024 01:13
@github-actions
Copy link
Copy Markdown
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "test-selected_calendars". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot Bot added api area: API, enterprise API, access token, OAuth automated-tests area: unit tests, e2e tests, playwright labels Jul 23, 2024
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Jul 23, 2024

Graphite Automations

"Add community label" took an action on this PR • (07/23/24)

1 label was added to this PR based on Keith Williams's automation.

"Add consumer team as reviewer" took an action on this PR • (07/23/24)

1 reviewer was added to this PR based on Keith Williams's automation.

});

req.userId = 333333;
req.isSystemWideAdmin = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For a non admin user you don't need to explicitly set req.isSystemWideAdmin = false, you can remove it.

@anikdhabal anikdhabal changed the title test-selected_calendars test: test cases for POST selected-calendars Jul 23, 2024
@github-actions
Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Eighty-four Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/apps 277.25 KB 504.91 KB 144.26% (🟢 -1.98%)
/apps/[slug] 294.63 KB 522.29 KB 149.22% (🟢 -2.04%)
/apps/[slug]/[...pages] 587.05 KB 814.71 KB 232.77% (🟢 -1.59%)
/apps/categories 254.3 KB 481.96 KB 137.70% (🟢 -1.78%)
/apps/categories/[category] 259.11 KB 486.76 KB 139.08% (🟢 -2.06%)
/apps/installation/[[...step]] 467.13 KB 694.79 KB 198.51% (🔴 +85.56%)
/apps/installed/[category] 278.23 KB 505.89 KB 144.54% (🟢 -1.82%)
/auth/saml-idp 12.22 KB 239.88 KB 68.54% (🟢 -20.80%)
/availability 426.65 KB 654.31 KB 186.95% (🟢 -1.65%)
/availability/[schedule] 410.52 KB 638.18 KB 182.34% (🟢 -1.66%)
/booking/[uid] 236.51 KB 464.17 KB 132.62% (🟡 +0.15%)
/booking/[uid]/embed 236.52 KB 464.17 KB 132.62% (🟡 +0.15%)
/bookings/[status] 324.31 KB 551.96 KB 157.70% (🟢 -1.68%)
/enterprise 254.35 KB 482.01 KB 137.72% (🟢 -1.79%)
/event-types 559.66 KB 787.31 KB 224.95% (🟢 -1.63%)
/event-types/[type] 435.43 KB 663.09 KB 189.45% (🟢 -1.74%)
/getting-started/[[...step]] 448.15 KB 675.8 KB 193.09% (🟡 +10.72%)
/insights 474.3 KB 701.95 KB 200.56% (🟢 -1.79%)
/more 253.86 KB 481.52 KB 137.58% (🟢 -1.79%)
/settings/admin 260.33 KB 487.99 KB 139.42% (🟢 -1.76%)
/settings/admin/apps 273.71 KB 501.37 KB 143.25% (🟢 -1.75%)
/settings/admin/apps/[category] 273.7 KB 501.35 KB 143.24% (🟢 -1.75%)
/settings/admin/flags 264.16 KB 491.82 KB 140.52% (🟢 -1.76%)
/settings/admin/impersonation 260.72 KB 488.38 KB 139.54% (🟢 -1.76%)
/settings/admin/lockedSMS 281.82 KB 509.47 KB 145.56% (🟢 -1.73%)
/settings/admin/lockedSMS/lockedSMSView 119.52 KB 347.17 KB 99.19% (🟢 -0.15%)
/settings/admin/oAuth 272.44 KB 500.1 KB 142.88% (🟢 -1.75%)
/settings/admin/oAuth/oAuthView 95.41 KB 323.07 KB 92.30% (🟢 -0.20%)
/settings/admin/orgMigrations/_OrgMigrationLayout 249.11 KB 476.77 KB 136.22% (🟢 -1.80%)
/settings/admin/orgMigrations/moveTeamToOrg 299.03 KB 526.69 KB 150.48% (🟢 -1.73%)
/settings/admin/orgMigrations/moveUserToOrg 318.86 KB 546.52 KB 156.15% (🟢 -1.71%)
/settings/admin/orgMigrations/removeTeamFromOrg 298.8 KB 526.45 KB 150.42% (🟢 -1.74%)
/settings/admin/orgMigrations/removeUserFromOrg 298.81 KB 526.46 KB 150.42% (🟢 -1.74%)
/settings/admin/organizations 262.22 KB 489.87 KB 139.96% (🟢 -1.76%)
/settings/admin/organizations/[id]/edit 260.88 KB 488.53 KB 139.58% (🟢 -1.76%)
/settings/admin/users 262.99 KB 490.64 KB 140.18% (🟢 -1.76%)
/settings/admin/users/[id]/edit 392.19 KB 619.85 KB 177.10% (🟢 -1.72%)
/settings/admin/users/add 391.86 KB 619.52 KB 177.00% (🟢 -1.72%)
/settings/billing 260.54 KB 488.19 KB 139.48% (🟢 -1.76%)
/settings/developer/api-keys 264.93 KB 492.59 KB 140.74% (🟢 -1.76%)
/settings/developer/webhooks 265.11 KB 492.76 KB 140.79% (🟢 -1.76%)
/settings/developer/webhooks/[id] 266.09 KB 493.74 KB 141.07% (🟢 -1.74%)
/settings/developer/webhooks/new 266.11 KB 493.77 KB 141.08% (🟢 -1.75%)
/settings/my-account/appearance 313.55 KB 541.21 KB 154.63% (🟢 -1.75%)
/settings/my-account/calendars 271.96 KB 499.61 KB 142.75% (🟢 -1.80%)
/settings/my-account/conferencing 272.86 KB 500.52 KB 143.00% (🟢 -1.79%)
/settings/my-account/general 376.04 KB 603.7 KB 172.49% (🟢 -1.76%)
/settings/my-account/out-of-office 265.56 KB 493.22 KB 140.92% (🟢 -1.76%)
/settings/my-account/profile 408.56 KB 636.22 KB 181.78% (🟢 -1.73%)
/settings/organizations/[id]/about 159.7 KB 387.36 KB 110.67% (🟡 +0.49%)
/settings/organizations/[id]/add-teams 159.7 KB 387.35 KB 110.67% (🟡 +0.49%)
/settings/organizations/admin-api 260.49 KB 488.14 KB 139.47% (🟢 -1.76%)
/settings/organizations/appearance 122.37 KB 350.03 KB 100.01% (🟢 -48.01%)
/settings/organizations/billing 260.57 KB 488.23 KB 139.49% (🟢 -1.76%)
/settings/organizations/dsync 293.19 KB 520.85 KB 148.81% (🟢 -1.76%)
/settings/organizations/general 348.88 KB 576.54 KB 164.73% (🟢 -1.76%)
/settings/organizations/members 400.05 KB 627.71 KB 179.35% (🟢 -1.75%)
/settings/organizations/new 159.71 KB 387.36 KB 110.68% (🟡 +0.48%)
/settings/organizations/privacy 266.09 KB 493.75 KB 141.07% (🟢 -1.76%)
/settings/organizations/profile 417.1 KB 644.75 KB 184.22% (🟡 +2.84%)
/settings/organizations/sso 271.16 KB 498.82 KB 142.52% (🟢 -1.76%)
/settings/organizations/teams/other 261.4 KB 489.05 KB 139.73% (🟢 -1.76%)
/settings/organizations/teams/other/[id]/appearance 273.31 KB 500.96 KB 143.13% (🟢 -1.71%)
/settings/organizations/teams/other/[id]/members 268 KB 495.66 KB 141.62% (🟢 -1.76%)
/settings/organizations/teams/other/[id]/profile 471.78 KB 699.43 KB 199.84% (🟢 -1.74%)
/settings/platform 258.96 KB 486.62 KB 139.03% (🟢 -1.78%)
/settings/platform/new 120.72 KB 348.37 KB 99.53% (🟡 +0.52%)
/settings/platform/oauth-clients/[clientId]/edit 257.27 KB 484.92 KB 138.55% (🟢 -1.78%)
/settings/platform/oauth-clients/create 256.41 KB 484.06 KB 138.30% (🟢 -1.78%)
/settings/security/impersonation 265.74 KB 493.4 KB 140.97% (🟢 -1.76%)
/settings/security/password 303.93 KB 531.59 KB 151.88% (🟢 -1.73%)
/settings/security/sso 270.61 KB 498.27 KB 142.36% (🟢 -1.76%)
/settings/security/two-factor-auth 269.22 KB 496.88 KB 141.97% (🟢 -1.76%)
/settings/teams 260.07 KB 487.72 KB 139.35% (🟢 -1.76%)
/settings/teams/[id]/appearance 273.3 KB 500.95 KB 143.13% (🟢 -1.71%)
/settings/teams/[id]/billing 260.57 KB 488.23 KB 139.49% (🟢 -1.76%)
/settings/teams/[id]/members 378.12 KB 605.78 KB 173.08% (🟢 -1.75%)
/settings/teams/[id]/profile 472.61 KB 700.26 KB 200.08% (🟢 -1.73%)
/settings/teams/new 193.05 KB 420.71 KB 120.20% (🟢 -1.81%)
/teams 254.09 KB 481.74 KB 137.64% (🟢 -1.78%)
/upgrade 254.21 KB 481.87 KB 137.68% (🟢 -1.79%)
/video/[uid] 291.31 KB 518.97 KB 148.28% (🟢 -0.15%)
/workflows 286.11 KB 513.77 KB 146.79% (🟢 -1.73%)
/workflows/[workflow] 414.4 KB 642.06 KB 183.45% (🟢 -1.51%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link
Copy Markdown
Contributor

@anikdhabal anikdhabal left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @Lucas13032003

@keithwillcode keithwillcode merged commit 07f14e4 into calcom:main Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth automated-tests area: unit tests, e2e tests, playwright community Created by Linear-GitHub Sync ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants