Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara committed Apr 10, 2024
1 parent d425062 commit b4532a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 29 additions & 0 deletions apps/web/playwright/booking-pages.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "@playwright/test";
import { JSDOM } from "jsdom";

import { randomString } from "@calcom/lib/random";
import { SchedulingType } from "@calcom/prisma/client";
Expand All @@ -22,6 +23,34 @@ test.afterEach(async ({ users }) => {
await users.deleteAll();
});

test("check SSR and OG", async ({ page, users }) => {
const name = "Test User";
const user = await users.create({
name,
});
const [response] = await Promise.all([
// This promise resolves to the main resource response
page.waitForResponse(
(response) => response.url().includes(`/${user.username}/30-min`) && response.status() === 200
),

// Trigger the page navigation
page.goto(`/${user.username}/30-min`),
]);
const ssrResponse = await response.text();
const document = new JSDOM(ssrResponse).window.document;

const titleText = document.querySelector("title")?.textContent;
const ogImage = document.querySelector('meta[property="og:image"]')?.getAttribute("content");
expect(titleText).toContain(name);
// Verify that there is correct URL that would generate the awesome OG image
expect(ogImage).toContain(
"/_next/image?w=1200&q=100&url=%2Fapi%2Fsocial%2Fog%2Fimage%3Ftype%3Dmeeting%26title%3D"
);
// Verify Organizer Name in the URL
expect(ogImage).toContain("meetingProfileName%3DTest%2520User%26");
});

testBothFutureAndLegacyRoutes.describe("free user", () => {
test.beforeEach(async ({ page, users }) => {
const free = await users.create(freeUserObj);
Expand Down
1 change: 0 additions & 1 deletion packages/features/bookings/components/BookerSeo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const BookerSeo = (props: BookerSeoProps) => {
bookingData,
} = props;
const { t } = useLocale();
console.log("BookerSeo Event Params", { username, eventSlug, isTeamEvent, org: entity.orgSlug ?? null });
const { data: event } = trpc.viewer.public.event.useQuery(
{
username,
Expand Down

0 comments on commit b4532a7

Please sign in to comment.