Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/CAL-3578
Browse files Browse the repository at this point in the history
  • Loading branch information
vachmara committed May 6, 2024
2 parents 96a2fa0 + 0e431ba commit 994d8b0
Show file tree
Hide file tree
Showing 80 changed files with 1,636 additions and 369 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cache-clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
cleanup:
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -21,7 +21,7 @@ jobs:
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
e2e:
timeout-minutes: 20
name: E2E tests (${{ matrix.shard }}/${{ strategy.job-total }})
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-8vcpu-ubuntu-2204
services:
postgres:
image: postgres:13
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
analyze:
needs: build
if: always()
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/dangerous-git-checkout
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
changes:
name: Detect changes
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-2vcpu-ubuntu-2204
permissions:
pull-requests: read
outputs:
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
required:
needs: [changes, lint, type-check, test, build, build-api-v1, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
if: always()
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: fail if conditional jobs failed
if: needs.changes.outputs.has-files-requiring-all-checks == 'true' && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled'))
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
test:
timeout-minutes: 20
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/dangerous-git-checkout
Expand Down
1 change: 1 addition & 0 deletions apps/api/v1/lib/validations/booking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ export const schemaBookingReadPublic = Booking.extend({
metadata: true,
status: true,
responses: true,
fromReschedule: true,
});
5 changes: 5 additions & 0 deletions apps/api/v1/pages/api/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ const swaggerHandler = withSwagger({
type: "string",
example: "Europe/London",
},
fromReschedule: {
type: "string",
nullable: true,
format: "uuid",
},
attendees: {
type: "array",
items: {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build && yarn workspace @calcom/platform-libraries build",
"dev": "yarn dev:build && docker-compose up -d && yarn copy-swagger-module && yarn start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "SKIP_DOCS_GENERATION=1 node ./dist/apps/api/v2/src/main.js",
"start:prod": "node ./dist/apps/api/v2/src/main.js",
"test": "yarn dev:build && jest",
"test:watch": "yarn dev:build && jest --watch",
"test:cov": "yarn dev:build && jest --coverage",
Expand Down
4 changes: 1 addition & 3 deletions apps/api/v2/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const run = async () => {
try {
bootstrap(app);
const port = app.get(ConfigService<AppConfig, true>).get("api.port", { infer: true });
if (process.env.SKIP_DOCS_GENERATION !== "1") {
void generateSwagger(app);
}
void generateSwagger(app);
await app.listen(port);
logger.log(`Application started on port: ${port}`);
} catch (error) {
Expand Down
18 changes: 16 additions & 2 deletions apps/api/v2/src/modules/timezones/services/timezones.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { RedisService } from "@/modules/redis/redis.service";
import { Injectable } from "@nestjs/common";

import { cityTimezonesHandler } from "@calcom/platform-libraries";
import type { CityTimezones } from "@calcom/platform-libraries";

@Injectable()
export class TimezonesService {
async getCityTimeZones() {
return cityTimezonesHandler();
private cacheKey = "cityTimezones";

constructor(private readonly redisService: RedisService) {}

async getCityTimeZones(): Promise<CityTimezones> {
const cachedTimezones = await this.redisService.redis.get(this.cacheKey);
if (!cachedTimezones) {
const timezones = await cityTimezonesHandler();
await this.redisService.redis.set(this.cacheKey, JSON.stringify(timezones), "EX", 60 * 60 * 24);

return timezones;
} else {
return JSON.parse(cachedTimezones) as CityTimezones;
}
}
}
3 changes: 2 additions & 1 deletion apps/api/v2/src/modules/timezones/timezones.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { RedisModule } from "@/modules/redis/redis.module";
import { TimezonesController } from "@/modules/timezones/controllers/timezones.controller";
import { TimezonesService } from "@/modules/timezones/services/timezones.service";
import { Module } from "@nestjs/common";

@Module({
imports: [],
imports: [RedisModule],
providers: [TimezonesService],
controllers: [TimezonesController],
exports: [TimezonesService],
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
`}</style>
</head>
<body
className="dark:bg-darkgray-50 todesktop:!bg-transparent bg-subtle antialiased"
className="dark:bg-darkgray-50 bg-subtle antialiased"
style={
isEmbed
? {
Expand Down
6 changes: 3 additions & 3 deletions apps/web/modules/videos/views/videos-single-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export default function JoinCall(props: PageProps) {
/>
) : (
<img
className="fixed z-10 hidden sm:inline-block"
className="fixed z-10 inline-block h-4"
src={`${WEBSITE_URL}/cal-logo-word-dark.svg`}
alt="Logo"
style={{
top: 32,
left: 32,
top: 9,
left: "calc(50% - 45px)",
}}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@tremor/react": "^2.0.0",
"@types/turndown": "^5.0.1",
"@unkey/ratelimit": "^0.1.1",
"@upstash/redis": "^1.21.0",
"@vercel/edge-config": "^0.1.1",
"@vercel/edge-functions-ui": "^0.2.1",
"@vercel/og": "^0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MyDocument extends Document<Props> {
</Head>

<body
className="dark:bg-darkgray-50 todesktop:!bg-transparent bg-subtle antialiased"
className="dark:bg-darkgray-50 bg-subtle antialiased"
style={
isEmbed
? {
Expand Down
44 changes: 4 additions & 40 deletions apps/web/playwright/organization/booking.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";

import { getOrgUsernameFromEmail } from "@calcom/features/auth/signup/utils/getOrgUsernameFromEmail";
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
import { MembershipRole, SchedulingType } from "@calcom/prisma/enums";

import { test } from "../lib/fixtures";
Expand All @@ -14,6 +13,7 @@ import {
testName,
} from "../lib/testUtils";
import { expectExistingUserToBeInvitedToOrganization } from "../team/expects";
import { gotoPathAndExpectRedirectToOrgDomain } from "./lib/gotoPathAndExpectRedirectToOrgDomain";
import { acceptTeamOrOrgInvite, inviteExistingUserToOrganization } from "./lib/inviteUser";

test.describe("Bookings", () => {
Expand Down Expand Up @@ -380,11 +380,11 @@ test.describe("Bookings", () => {

await test.step("Booking through old link redirects to new link on org domain", async () => {
const event = await userOutsideOrganization.getFirstEventAsOwner();
await expectRedirectToOrgDomain({
await gotoPathAndExpectRedirectToOrgDomain({
page,
org,
eventSlug: `/${usernameOutsideOrg}/${event.slug}`,
expectedEventSlug: `/${usernameInOrg}/${event.slug}`,
path: `/${usernameOutsideOrg}/${event.slug}`,
expectedPath: `/${usernameInOrg}/${event.slug}`,
});
// As the redirection correctly happens, the booking would work too which we have verified in previous step. But we can't test that with org domain as that domain doesn't exist.
});
Expand Down Expand Up @@ -463,39 +463,3 @@ async function expectPageToBeNotFound({ page, url }: { page: Page; url: string }
await page.goto(`${url}`);
await expect(page.locator(`text=${NotFoundPageTextAppDir}`)).toBeVisible();
}

async function expectRedirectToOrgDomain({
page,
org,
eventSlug,
expectedEventSlug,
}: {
page: Page;
org: { slug: string | null };
eventSlug: string;
expectedEventSlug: string;
}) {
if (!org.slug) {
throw new Error("Org slug is not defined");
}
page.goto(eventSlug).catch((e) => {
console.log("Expected navigation error to happen");
});

const orgSlug = org.slug;

const orgRedirectUrl = await new Promise(async (resolve) => {
page.on("request", (request) => {
if (request.isNavigationRequest()) {
const requestedUrl = request.url();
console.log("Requested navigation to", requestedUrl);
// Resolve on redirection to org domain
if (requestedUrl.includes(orgSlug)) {
resolve(requestedUrl);
}
}
});
});

expect(orgRedirectUrl).toContain(`${getOrgFullOrigin(org.slug)}${expectedEventSlug}`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";

import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";

export async function gotoPathAndExpectRedirectToOrgDomain({
page,
org,
path,
expectedPath,
}: {
page: Page;
org: { slug: string | null };
path: string;
expectedPath: string;
}) {
if (!org.slug) {
throw new Error("Org slug is not defined");
}
page.goto(path).catch((e) => {
console.log("Expected navigation error to happen");
});

const orgSlug = org.slug;

const orgRedirectUrl = await new Promise(async (resolve) => {
page.on("request", (request) => {
if (request.isNavigationRequest()) {
const requestedUrl = request.url();
console.log("Requested navigation to", requestedUrl);
// Resolve on redirection to org domain
if (requestedUrl.includes(orgSlug)) {
resolve(requestedUrl);
}
}
});
});

expect(orgRedirectUrl).toContain(`${getOrgFullOrigin(org.slug)}${expectedPath}`);
}
Loading

0 comments on commit 994d8b0

Please sign in to comment.