chore: technical debt - remove instances of testing /future routes (#18032)

This commit is contained in:
Benny Joo
2024-12-06 02:53:00 +00:00
committed by GitHub
parent b8219c273d
commit 0c19606e19
9 changed files with 16 additions and 100 deletions
+1 -39
View File
@@ -1,20 +1,10 @@
import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
test.describe.configure({ mode: "parallel" });
const ensureAppDir = async (page: Page) => {
const dataNextJsRouter = await page.evaluate(() =>
window.document.documentElement.getAttribute("data-nextjs-router")
);
expect(dataNextJsRouter).toEqual("app");
};
testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
test.describe("apps/ A/B tests", () => {
test("should render the /apps/installed/[category]", async ({ page, users }) => {
const user = await users.create();
@@ -24,10 +14,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByRole("heading", { name: "Messaging" });
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
@@ -40,10 +26,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByRole("heading", { name: "Telegram" });
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
@@ -56,10 +38,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByRole("heading", { name: "Connect to Apple Server" });
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
@@ -72,10 +50,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByTestId("app-store-category-messaging");
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
@@ -88,10 +62,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByText(/messaging apps/i);
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
@@ -104,10 +74,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByTestId("horizontal-tab-upcoming");
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toHaveClass(/bg-emphasis/);
});
@@ -120,10 +86,6 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
const locator = page.getByText("Apple Calendar");
if (routeVariant === "future") {
await ensureAppDir(page);
}
await expect(locator).toBeVisible();
});
});
+1 -3
View File
@@ -1,16 +1,14 @@
import { expect } from "@playwright/test";
import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
import { installAppleCalendar } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
testBothFutureAndLegacyRoutes.describe("App Store - Authed", (routeVariant) => {
test.describe("App Store - Authed", () => {
test("should render /apps page", async ({ page, users, context }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
const user = await users.create();
await user.apiLogin();
@@ -5,11 +5,10 @@ import { verifyPassword } from "@calcom/features/auth/lib/verifyPassword";
import prisma from "@calcom/prisma";
import { test } from "../lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "../lib/future-legacy-routes";
test.afterEach(({ users }) => users.deleteAll());
testBothFutureAndLegacyRoutes.describe("Forgot password", async () => {
test.describe("Forgot password", async () => {
test("Can reset forgotten password", async ({ page, users }) => {
const user = await users.create();
+5 -6
View File
@@ -7,7 +7,6 @@ import { SchedulingType } from "@calcom/prisma/client";
import type { Schedule, TimeRange } from "@calcom/types/schedule";
import { test, todo } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
import {
bookFirstEvent,
bookOptinEvent,
@@ -63,7 +62,7 @@ test("check SSR and OG - User Event Type", async ({ page, users }) => {
todo("check SSR and OG - Team Event Type");
testBothFutureAndLegacyRoutes.describe("free user", () => {
test.describe("free user", () => {
test.beforeEach(async ({ page, users }) => {
const free = await users.create(freeUserObj);
await page.goto(`/${free.username}`);
@@ -99,7 +98,7 @@ testBothFutureAndLegacyRoutes.describe("free user", () => {
});
});
testBothFutureAndLegacyRoutes.describe("pro user", () => {
test.describe("pro user", () => {
test.beforeEach(async ({ page, users }) => {
const pro = await users.create();
await page.goto(`/${pro.username}`);
@@ -343,7 +342,7 @@ testBothFutureAndLegacyRoutes.describe("pro user", () => {
});
});
testBothFutureAndLegacyRoutes.describe("prefill", () => {
test.describe("prefill", () => {
test("logged in", async ({ page, users }) => {
const prefill = await users.create({ name: "Prefill User" });
await prefill.apiLogin();
@@ -400,7 +399,7 @@ testBothFutureAndLegacyRoutes.describe("prefill", () => {
});
});
testBothFutureAndLegacyRoutes.describe("Booking on different layouts", () => {
test.describe("Booking on different layouts", () => {
test.beforeEach(async ({ page, users }) => {
const user = await users.create();
await page.goto(`/${user.username}`);
@@ -457,7 +456,7 @@ testBothFutureAndLegacyRoutes.describe("Booking on different layouts", () => {
});
});
testBothFutureAndLegacyRoutes.describe("Booking round robin event", () => {
test.describe("Booking round robin event", () => {
test.beforeEach(async ({ page, users }) => {
const teamMatesObj = [{ name: "teammate-1" }];
+2 -3
View File
@@ -5,7 +5,6 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
import { randomString } from "@calcom/lib/random";
import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
import {
bookTimeSlot,
createNewEventType,
@@ -18,7 +17,7 @@ import {
test.describe.configure({ mode: "parallel" });
testBothFutureAndLegacyRoutes.describe("Event Types A/B tests", () => {
test.describe("Event Types A/B tests", () => {
test("should render the /future/event-types page", async ({ page, users }) => {
const user = await users.create();
@@ -32,7 +31,7 @@ testBothFutureAndLegacyRoutes.describe("Event Types A/B tests", () => {
});
});
testBothFutureAndLegacyRoutes.describe("Event Types tests", () => {
test.describe("Event Types tests", () => {
test.describe("user", () => {
test.beforeEach(async ({ page, users }) => {
const user = await users.create();
@@ -1,33 +0,0 @@
import { test } from "./fixtures";
export type RouteVariant = "future" | "legacy";
const routeVariants = ["future", "legacy"];
/**
* Small wrapper around test.describe().
* When using testbothFutureLegacyRoutes.describe() instead of test.describe(), this will run the specified
* tests twice. One with the pages route, and one with the new app dir "future" route. It will also add the route variant
* name to the test name for easier debugging.
* Finally it also adds a parameter routeVariant to your testBothFutureAndLegacyRoutes.describe() callback, which
* can be used to do any conditional rendering in the test for a specific route variant (should be as little
* as possible).
*
* See apps/web/playwright/event-types.e2e.ts for an example.
*/
export const testBothFutureAndLegacyRoutes = {
describe: (testName: string, testFn: (routeVariant: RouteVariant) => void) => {
routeVariants.forEach((routeVariant) => {
test.describe(`${testName} -- ${routeVariant}`, () => {
if (routeVariant === "future") {
test.beforeEach(({ context }) => {
context.addCookies([
{ name: "x-calcom-future-routes-override", value: "1", url: "http://localhost:3000" },
]);
});
}
testFn(routeVariant as RouteVariant);
});
});
},
};
+3 -4
View File
@@ -2,14 +2,13 @@ import { expect } from "@playwright/test";
import { login } from "./fixtures/users";
import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
import { localize } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
// a test to logout requires both a succesfull login as logout, to prevent
// a doubling of tests failing on logout & logout, we can group them.
testBothFutureAndLegacyRoutes.describe("user can login & logout succesfully", async () => {
test.describe("user can login & logout succesfully", async () => {
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
@@ -45,7 +44,7 @@ testBothFutureAndLegacyRoutes.describe("user can login & logout succesfully", as
});
});
testBothFutureAndLegacyRoutes.describe("Login and logout tests", () => {
test.describe("Login and logout tests", () => {
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
@@ -58,7 +57,7 @@ testBothFutureAndLegacyRoutes.describe("Login and logout tests", () => {
await expect(page.locator(`[data-testid=login-form]`)).toBeVisible();
});
testBothFutureAndLegacyRoutes.describe("Login flow validations", async () => {
test.describe("Login flow validations", async () => {
test("Should warn when user does not exist", async ({ page }) => {
const alertMessage = (await localize("en"))("incorrect_email_password");
+1 -3
View File
@@ -3,18 +3,16 @@ import { expect } from "@playwright/test";
import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth } from "@calcom/web/playwright/lib/testUtils";
import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
test.describe.configure({ mode: "parallel" });
testBothFutureAndLegacyRoutes.describe("Payment", (routeVariant) => {
test.describe("Payment", () => {
test.describe("user", () => {
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test("should create a mock payment for a user", async ({ context, users, page }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
test.skip(process.env.MOCK_PAYMENT_APP_ENABLED === undefined, "Skipped as Stripe is not installed");
const user = await users.create();
+2 -7
View File
@@ -5,7 +5,6 @@ import { prisma } from "@calcom/prisma";
import { SchedulingType } from "@calcom/prisma/enums";
import { test, todo } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";
import {
bookTimeSlot,
confirmReschedule,
@@ -16,10 +15,8 @@ import {
test.describe.configure({ mode: "parallel" });
testBothFutureAndLegacyRoutes.describe("Teams A/B tests", (routeVariant) => {
test.describe("Teams A/B tests", () => {
test("should render the /teams page", async ({ page, users, context }) => {
// TODO: Revert until OOM issue is resolved
test.skip(routeVariant === "future", "Future route not ready yet");
const user = await users.create();
await user.apiLogin();
@@ -34,7 +31,7 @@ testBothFutureAndLegacyRoutes.describe("Teams A/B tests", (routeVariant) => {
});
});
testBothFutureAndLegacyRoutes.describe("Teams - NonOrg", (routeVariant) => {
test.describe("Teams - NonOrg", () => {
test.afterEach(({ users }) => users.deleteAll());
test("Can create a booking for Collective EventType", async ({ page, users }) => {
@@ -120,7 +117,6 @@ testBothFutureAndLegacyRoutes.describe("Teams - NonOrg", (routeVariant) => {
});
test("Non admin team members cannot create team in org", async ({ page, users }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
const teamMateName = "teammate-1";
const owner = await users.create(undefined, {
@@ -155,7 +151,6 @@ testBothFutureAndLegacyRoutes.describe("Teams - NonOrg", (routeVariant) => {
});
test("Can create team with same name as user", async ({ page, users }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
const user = await users.create();
// Name to be used for both user and team
const uniqueName = user.username!;