From 5c6d9a764754b14de90b8412b1b9c927a3170417 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:11:14 -0300 Subject: [PATCH 01/19] Added a log for pull_request --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a2895b1b2efb7d..a92a3ad7a8b1ce 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -49,6 +49,7 @@ jobs: with: script: | console.log('github.event.action', '${{ github.event.action }}'); + console.log('github.event.pull_request', ${{ github.event.pull_request }}); try { const sha = '${{ needs.changes.outputs.commit-sha }}'; console.log('sha', sha); From 7febdaf692a3e47c857f42a9ea5d32ca7bbbf1d8 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:15:46 -0300 Subject: [PATCH 02/19] Added labels logging --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a92a3ad7a8b1ce..63b2fc1bfa57c2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -49,7 +49,7 @@ jobs: with: script: | console.log('github.event.action', '${{ github.event.action }}'); - console.log('github.event.pull_request', ${{ github.event.pull_request }}); + console.log('github.event.pull_request.labels', ${{ github.event.pull_request.labels }}); try { const sha = '${{ needs.changes.outputs.commit-sha }}'; console.log('sha', sha); From ce291ee7e0091274027df921d532de35bf02a4e8 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:23:49 -0300 Subject: [PATCH 03/19] Using labels straight from event PR object --- .github/workflows/pr.yml | 62 ++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 63b2fc1bfa57c2..b15552a76d20cf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -50,38 +50,44 @@ jobs: script: | console.log('github.event.action', '${{ github.event.action }}'); console.log('github.event.pull_request.labels', ${{ github.event.pull_request.labels }}); - try { - const sha = '${{ needs.changes.outputs.commit-sha }}'; - console.log('sha', sha); - const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - commit_sha: sha - }); - - if (prs.length === 0) { + + if (${{ github.event }} && ${{ github.event.pull_request }}) { + labels = ${{ github.event.pull_request.labels }}; + } else { + try { + const sha = '${{ needs.changes.outputs.commit-sha }}'; + console.log('sha', sha); + const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: sha + }); + + if (prs.length === 0) { + core.setOutput('run-e2e', false); + console.log(`No pull requests found for commit SHA ${sha}`); + return; + } + + const pr = prs[0]; + console.log(`PR number: ${pr.number}`); + console.log(`PR title: ${pr.title}`); + console.log(`PR state: ${pr.state}`); + console.log(`PR URL: ${pr.html_url}`); + + labels = pr.labels.map(label => label.name); + } + catch (e) { core.setOutput('run-e2e', false); - console.log(`No pull requests found for commit SHA ${sha}`); - return; + console.log(e); } - - const pr = prs[0]; - console.log(`PR number: ${pr.number}`); - console.log(`PR title: ${pr.title}`); - console.log(`PR state: ${pr.state}`); - console.log(`PR URL: ${pr.html_url}`); - - const labels = pr.labels.map(label => label.name); - const labelFound = labels.includes('ready-for-e2e'); - console.log('PR #', pr.number); - console.log('Found the label?', labelFound); - core.setOutput('run-e2e', labelFound); - } - catch (e) { - core.setOutput('run-e2e', false); - console.log(e); } + const labelFound = labels.includes('ready-for-e2e'); + console.log('PR #', pr.number); + console.log('Found the label?', labelFound); + core.setOutput('run-e2e', labelFound); + type-check: name: Type check needs: [changes, check-label] From 7283309ea36afcbdbbbb9be547c184ece4b0d57c Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:27:29 -0300 Subject: [PATCH 04/19] Converting to JSON --- .github/workflows/pr.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b15552a76d20cf..5b884474bbd475 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -49,10 +49,12 @@ jobs: with: script: | console.log('github.event.action', '${{ github.event.action }}'); - console.log('github.event.pull_request.labels', ${{ github.event.pull_request.labels }}); + console.log('github.event.pull_request.labels', ${{ toJson(github.event.pull_request.labels) }}); - if (${{ github.event }} && ${{ github.event.pull_request }}) { - labels = ${{ github.event.pull_request.labels }}; + let labels = []; + + if (${{ toJson(github.event) }} && ${{ toJson(github.event.pull_request) }}) { + labels = ${{ toJson(github.event.pull_request.labels) }}; } else { try { const sha = '${{ needs.changes.outputs.commit-sha }}'; From e352554950f56dd799c077101e9989095073cd7a Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:32:50 -0300 Subject: [PATCH 05/19] Switching to use payload --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5b884474bbd475..9c2b841388d856 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -49,12 +49,12 @@ jobs: with: script: | console.log('github.event.action', '${{ github.event.action }}'); - console.log('github.event.pull_request.labels', ${{ toJson(github.event.pull_request.labels) }}); + console.log('github.event.pull_request.labels', context.payload.pull_request.labels); let labels = []; - if (${{ toJson(github.event) }} && ${{ toJson(github.event.pull_request) }}) { - labels = ${{ toJson(github.event.pull_request.labels) }}; + if (context.payload.pull_request) { + labels = context.payload.pull_request.labels; } else { try { const sha = '${{ needs.changes.outputs.commit-sha }}'; From 97387dfa525fe360cfed4db68055d6de5e7b84ca Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:36:25 -0300 Subject: [PATCH 06/19] Fixed issue with undefined pr --- .github/workflows/pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9c2b841388d856..e6eff3b64ddda3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -86,7 +86,6 @@ jobs: } const labelFound = labels.includes('ready-for-e2e'); - console.log('PR #', pr.number); console.log('Found the label?', labelFound); core.setOutput('run-e2e', labelFound); From 2ff909301b7fa725853ca5f3c19f0bd52a4665f1 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 18:41:40 -0300 Subject: [PATCH 07/19] Fixed non-mapping issue --- .github/workflows/pr.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e6eff3b64ddda3..8de74886561021 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -48,9 +48,6 @@ jobs: uses: actions/github-script@v7 with: script: | - console.log('github.event.action', '${{ github.event.action }}'); - console.log('github.event.pull_request.labels', context.payload.pull_request.labels); - let labels = []; if (context.payload.pull_request) { @@ -77,7 +74,7 @@ jobs: console.log(`PR state: ${pr.state}`); console.log(`PR URL: ${pr.html_url}`); - labels = pr.labels.map(label => label.name); + labels = pr.labels; } catch (e) { core.setOutput('run-e2e', false); @@ -85,7 +82,7 @@ jobs: } } - const labelFound = labels.includes('ready-for-e2e'); + const labelFound = labels.map(l => l.name).includes('ready-for-e2e'); console.log('Found the label?', labelFound); core.setOutput('run-e2e', labelFound); From 20466ea3dbf40677446f1fbd5a29732e67f62572 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sat, 22 Jun 2024 19:06:18 -0300 Subject: [PATCH 08/19] Removed the types --- .github/workflows/pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8de74886561021..ba3e7aa21e5c42 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -2,7 +2,6 @@ name: PR Update on: pull_request_target: - types: [opened, synchronize, reopened, labeled] branches: - main - gh-actions-test-branch From 4a9b72f0a84447ff3aa75a56a89f8fb4f19093f6 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 10:51:14 -0300 Subject: [PATCH 09/19] Added another cache key segment using the head commit sha --- .github/actions/cache-build/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/cache-build/action.yml b/.github/actions/cache-build/action.yml index 1849e475761152..72baa43cfc56cd 100644 --- a/.github/actions/cache-build/action.yml +++ b/.github/actions/cache-build/action.yml @@ -20,13 +20,14 @@ runs: key-2: ${{ hashFiles('apps/**/**.[jt]s', 'apps/**/**.[jt]sx', 'packages/**/**.[jt]s', 'packages/**/**.[jt]sx', '!**/node_modules') }} key-3: ${{ github.event.pull_request.number || github.ref }} key-4: ${{ github.sha }} + key-5: ${{ github.event.pull_request.head.sha }} with: path: | ${{ github.workspace }}/apps/web/.next ${{ github.workspace }}/apps/web/public/embed **/.turbo/** **/dist/** - key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }}-${{ env.key-5 }} - run: | export NODE_OPTIONS="--max_old_space_size=8192" yarn build From 7270f28c5667cc787ea71e18fd872c3829d63edc Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 22:47:19 -0300 Subject: [PATCH 10/19] Added separate workflow for labeled action --- .github/workflows/pr-labeled.yml | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/pr-labeled.yml diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml new file mode 100644 index 00000000000000..ca7a5464dbc2d1 --- /dev/null +++ b/.github/workflows/pr-labeled.yml @@ -0,0 +1,52 @@ +name: PR Labeled with ready-for-e2e + +on: + pull_request_target: + types: [labeled] + branches: + - main + - gh-actions-test-branch + workflow_dispatch: +jobs: + run-e2e-jobs: + name: Run E2E Jobs + runs-on: buildjet-2vcpu-ubuntu-2204 + permissions: + pull-requests: read + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/dangerous-git-checkout + + - name: Check Label and Retrigger Checks + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const labelName = github.context.payload.label.name; + const prNumber = github.context.payload.pull_request.number; + const owner = github.context.repo.owner; + const repo = github.context.repo.repo; + + if (labelName === 'ready-for-e2e') { + console.log(`Running E2E jobs for PR #${prNumber}...`); + + const checkRuns = await github.rest.checks.listForRef({ + owner, + repo, + ref: github.context.payload.pull_request.head.sha, + }); + + for (const check of checkRuns.data.check_runs) { + if (check.name.includes('e2e') { + await github.rest.actions.reRunJob({ + owner, + repo, + job_id: check.id, + }); + } + } + + console.log(`Triggered E2E checks for PR #${prNumber}`); + } else { + console.log(`Label ${labelName} does not trigger re-running checks.`); + } From 9d7b6204e0e1046477745d2a690563b28efc6d5e Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 22:51:55 -0300 Subject: [PATCH 11/19] Fixed syntax error --- .github/workflows/pr-labeled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index ca7a5464dbc2d1..4a5d10bcf1ef5d 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -37,7 +37,7 @@ jobs: }); for (const check of checkRuns.data.check_runs) { - if (check.name.includes('e2e') { + if (check.name.includes('e2e')) { await github.rest.actions.reRunJob({ owner, repo, From f0516cda75f2d437cb934b2c965f7247d91152f5 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 22:54:21 -0300 Subject: [PATCH 12/19] Fixing payload issue --- .github/workflows/pr-labeled.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index 4a5d10bcf1ef5d..3d888bd5138b63 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -22,10 +22,10 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const labelName = github.context.payload.label.name; - const prNumber = github.context.payload.pull_request.number; - const owner = github.context.repo.owner; - const repo = github.context.repo.repo; + const labelName = context.payload.label.name; + const prNumber = context.payload.pull_request.number; + const owner = context.repo.owner; + const repo = context.repo.repo; if (labelName === 'ready-for-e2e') { console.log(`Running E2E jobs for PR #${prNumber}...`); @@ -33,7 +33,7 @@ jobs: const checkRuns = await github.rest.checks.listForRef({ owner, repo, - ref: github.context.payload.pull_request.head.sha, + ref: context.payload.pull_request.head.sha, }); for (const check of checkRuns.data.check_runs) { From a33f59b5a8841ba9ff0e96aff36e2bec7046b8f2 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 22:56:24 -0300 Subject: [PATCH 13/19] Added log --- .github/workflows/pr-labeled.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index 3d888bd5138b63..8885510e924e46 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -37,6 +37,7 @@ jobs: }); for (const check of checkRuns.data.check_runs) { + console.log('check.name', check.name); if (check.name.includes('e2e')) { await github.rest.actions.reRunJob({ owner, From f4e1d09650e48e118e84389d6fb282f992bb8685 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 22:58:47 -0300 Subject: [PATCH 14/19] logging full object --- .github/workflows/pr-labeled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index 8885510e924e46..cbacb174a5eda7 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -37,7 +37,7 @@ jobs: }); for (const check of checkRuns.data.check_runs) { - console.log('check.name', check.name); + console.log('check', check); if (check.name.includes('e2e')) { await github.rest.actions.reRunJob({ owner, From c12466f4566bb2db1c4728f2331a46d6f98b635d Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 23:01:37 -0300 Subject: [PATCH 15/19] Put e2e back in the names to help find them --- .github/workflows/pr-labeled.yml | 1 + .github/workflows/pr.yml | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index cbacb174a5eda7..71f6db37427a6b 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -44,6 +44,7 @@ jobs: repo, job_id: check.id, }); + console.log(`Triggering job #${check.id}`); } } diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ba3e7aa21e5c42..1950fedf7bad67 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -135,28 +135,28 @@ jobs: secrets: inherit e2e: - name: Tests + name: e2e needs: [changes, check-label, build] if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/e2e.yml secrets: inherit e2e-app-store: - name: Tests + name: e2e-app-store needs: [changes, check-label, build] if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/e2e-app-store.yml secrets: inherit e2e-embed: - name: Tests + name: e2e-embed needs: [changes, check-label, build] if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/e2e-embed.yml secrets: inherit e2e-embed-react: - name: Tests + name: e2e-embed-react needs: [changes, check-label, build] if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/e2e-embed-react.yml From a76960607ff792e98d4a52f7869101703e4fb994 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 23 Jun 2024 23:04:07 -0300 Subject: [PATCH 16/19] Limited logging --- .github/workflows/pr-labeled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index 71f6db37427a6b..ce0e34a2e3a55c 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -37,7 +37,7 @@ jobs: }); for (const check of checkRuns.data.check_runs) { - console.log('check', check); + console.log('check.name', check.name); if (check.name.includes('e2e')) { await github.rest.actions.reRunJob({ owner, From ac22e61e52788d9ccaca0646e3238c3fbfce5cce Mon Sep 17 00:00:00 2001 From: supalarry Date: Mon, 24 Jun 2024 11:20:02 +0200 Subject: [PATCH 17/19] fix: v2 even-types versioning --- .../controllers/event-types.controller.ts | 4 ++-- apps/api/v2/src/lib/api-versions.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.ts b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.ts index 81c03a9066edd8..3669420db1ab14 100644 --- a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.ts +++ b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.ts @@ -13,7 +13,7 @@ import { } from "@/ee/event-types/event-types_2024_04_15/outputs/get-event-types.output"; import { UpdateEventTypeOutput } from "@/ee/event-types/event-types_2024_04_15/outputs/update-event-type.output"; import { EventTypesService_2024_04_15 } from "@/ee/event-types/event-types_2024_04_15/services/event-types.service"; -import { VERSION_2024_04_15_VALUE } from "@/lib/api-versions"; +import { VERSION_2024_04_15, VERSION_2024_06_11 } from "@/lib/api-versions"; import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator"; import { Permissions } from "@/modules/auth/decorators/permissions/permissions.decorator"; import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard"; @@ -45,7 +45,7 @@ import { PrismaClient } from "@calcom/prisma"; @Controller({ path: "/v2/event-types", - version: VERSION_2024_04_15_VALUE, + version: [VERSION_2024_04_15, VERSION_2024_06_11], }) @UseGuards(PermissionsGuard) @DocsTags("Event types") diff --git a/apps/api/v2/src/lib/api-versions.ts b/apps/api/v2/src/lib/api-versions.ts index f4352e3ef9e37f..d2347da2f31e3e 100644 --- a/apps/api/v2/src/lib/api-versions.ts +++ b/apps/api/v2/src/lib/api-versions.ts @@ -14,3 +14,4 @@ export const VERSION_2024_04_15_VALUE: VersionValue = VERSION_2024_04_15 as unkn export { VERSION_2024_06_11 }; export { VERSION_2024_06_14 }; +export { VERSION_2024_04_15 }; From 6dc17c6f6e953a2ba42dbe08081a1ce049d8ba8b Mon Sep 17 00:00:00 2001 From: supalarry Date: Mon, 24 Jun 2024 11:26:52 +0200 Subject: [PATCH 18/19] test: old v2 even-types request with VERSION_2024_06_11 --- .../event-types.controller.e2e-spec.ts | 20 ++++++++++++++++++- apps/api/v2/src/lib/api-versions.ts | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts index 5f0575015040e1..014b65f20db98c 100644 --- a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts @@ -24,7 +24,7 @@ import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository. import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { withApiAuth } from "test/utils/withApiAuth"; -import { SUCCESS_STATUS } from "@calcom/platform-constants"; +import { SUCCESS_STATUS, VERSION_2024_06_11, CAL_API_VERSION_HEADER } from "@calcom/platform-constants"; import { EventTypesByViewer, EventTypesPublic, @@ -302,6 +302,24 @@ describe("Event types Endpoints", () => { expect(responseBody.data.eventType.userId).toEqual(user.id); }); + it(`/GET/:id with version VERSION_2024_06_11`, async () => { + const response = await request(app.getHttpServer()) + .get(`/api/v2/event-types/${eventType.id}`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_06_11) + // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above + .set("Authorization", `Bearer whatever`) + .expect(200); + + const responseBody: GetEventTypeOutput = response.body; + + expect(responseBody.status).toEqual(SUCCESS_STATUS); + expect(responseBody.data).toBeDefined(); + expect(responseBody.data.eventType.id).toEqual(eventType.id); + expect(responseBody.data.eventType.title).toEqual(eventType.title); + expect(responseBody.data.eventType.slug).toEqual(eventType.slug); + expect(responseBody.data.eventType.userId).toEqual(user.id); + }); + it(`/GET/:username/public`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types/${username}/public`) diff --git a/apps/api/v2/src/lib/api-versions.ts b/apps/api/v2/src/lib/api-versions.ts index d2347da2f31e3e..62a70a4b83a372 100644 --- a/apps/api/v2/src/lib/api-versions.ts +++ b/apps/api/v2/src/lib/api-versions.ts @@ -12,6 +12,6 @@ export const VERSION_2024_06_14_VALUE: VersionValue = VERSION_2024_06_14 as unkn export const VERSION_2024_06_11_VALUE: VersionValue = VERSION_2024_06_11 as unknown as VersionValue; export const VERSION_2024_04_15_VALUE: VersionValue = VERSION_2024_04_15 as unknown as VersionValue; +export { VERSION_2024_04_15 }; export { VERSION_2024_06_11 }; export { VERSION_2024_06_14 }; -export { VERSION_2024_04_15 }; From ffae2884449d6f9fae8a44f67721770f2debf0d8 Mon Sep 17 00:00:00 2001 From: supalarry Date: Mon, 24 Jun 2024 11:29:46 +0200 Subject: [PATCH 19/19] test: old v2 even-types request with VERSION_2024_04_15 --- .../event-types.controller.e2e-spec.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts index 014b65f20db98c..a1d283c62bbdbb 100644 --- a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts @@ -24,7 +24,12 @@ import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository. import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { withApiAuth } from "test/utils/withApiAuth"; -import { SUCCESS_STATUS, VERSION_2024_06_11, CAL_API_VERSION_HEADER } from "@calcom/platform-constants"; +import { + SUCCESS_STATUS, + VERSION_2024_06_11, + VERSION_2024_04_15, + CAL_API_VERSION_HEADER, +} from "@calcom/platform-constants"; import { EventTypesByViewer, EventTypesPublic, @@ -154,6 +159,7 @@ describe("Event types Endpoints", () => { return request(app.getHttpServer()) .post("/api/v2/event-types") + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) .send(body) .expect(201) .then(async (response) => { @@ -184,6 +190,7 @@ describe("Event types Endpoints", () => { return request(app.getHttpServer()) .patch(`/api/v2/event-types/${eventType.id}`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) .send(body) .expect(200) .then(async (response) => { @@ -288,6 +295,7 @@ describe("Event types Endpoints", () => { it(`/GET/:id`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types/${eventType.id}`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(200); @@ -323,6 +331,7 @@ describe("Event types Endpoints", () => { it(`/GET/:username/public`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types/${username}/public`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(200); @@ -341,6 +350,7 @@ describe("Event types Endpoints", () => { it(`/GET/:username/:eventSlug/public`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types/${username}/${eventType.slug}/public`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(200); @@ -358,6 +368,7 @@ describe("Event types Endpoints", () => { it(`/GET/`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(200); @@ -377,6 +388,7 @@ describe("Event types Endpoints", () => { it(`/GET/public/:username/`, async () => { const response = await request(app.getHttpServer()) .get(`/api/v2/event-types/${username}/public`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(200); @@ -393,13 +405,17 @@ describe("Event types Endpoints", () => { it(`/GET/:id not existing`, async () => { await request(app.getHttpServer()) .get(`/api/v2/event-types/1000`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) // note: bearer token value mocked using "withApiAuth" for user which id is used when creating event type above .set("Authorization", `Bearer whatever`) .expect(404); }); it("should delete schedule", async () => { - return request(app.getHttpServer()).delete(`/api/v2/event-types/${eventType.id}`).expect(200); + return request(app.getHttpServer()) + .delete(`/api/v2/event-types/${eventType.id}`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_04_15) + .expect(200); }); afterAll(async () => {