Adds missing cleanups to e2e tests

This commit is contained in:
zomars committed 2023-03-01 16:35:28 -07:00
1 parent c76847a8f1
commit e5e8c33c34
16 files changed
+37 -48

No files matched your search

+2 -1
View File
@@ -4,6 +4,8 @@ import { test } from "./lib/fixtures";
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("App Store - Authed", () => {
test("Browse apple-calendar and try to install", async ({ page, users }) => {
const pro = await users.create();
@@ -12,7 +14,6 @@ test.describe("App Store - Authed", () => {
await page.click('[data-testid="app-store-app-card-apple-calendar"]');
await page.click('[data-testid="install-app-button"]');
await expect(page.locator(`text=Connect to Apple Server`)).toBeVisible();
await pro.delete();
});
test("Installed Apps - Navigation", async ({ page, users }) => {
@@ -2,6 +2,8 @@ import { expect } from "@playwright/test";
import { test } from "../lib/fixtures";
test.afterEach(({ users }) => users.deleteAll());
test("Can delete user account", async ({ page, users }) => {
const user = await users.create({
username: "delete-me",
@@ -2,6 +2,8 @@ import { expect } from "@playwright/test";
import { test } from "../lib/fixtures";
test.afterEach(({ users }) => users.deleteAll());
test("Can reset forgotten password", async ({ page, users }) => {
test.skip(process.env.NEXT_PUBLIC_IS_E2E !== "1", "It shouldn't if we can't skip email");
const user = await users.create();
@@ -47,6 +49,4 @@ test("Can reset forgotten password", async ({ page, users }) => {
await page.waitForSelector("[data-testid=dashboard-shell]");
await expect(page.locator("[data-testid=dashboard-shell]")).toBeVisible();
await users.deleteAll();
});
+1 -6
View File
@@ -10,15 +10,13 @@ import {
} from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
test.afterEach(async ({ users }) => users.deleteAll());
test.describe("free user", () => {
test.beforeEach(async ({ page, users }) => {
const free = await users.create();
await page.goto(`/${free.username}`);
});
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test("cannot book same slot multiple times", async ({ page }) => {
// Click first event type
@@ -58,9 +56,6 @@ test.describe("pro user", () => {
const pro = await users.create();
await page.goto(`/${pro.username}`);
});
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test("pro user's page has at least 2 visible events", async ({ page }) => {
// await page.pause();
+1 -1
View File
@@ -24,6 +24,6 @@ test.describe("Change Password Test", () => {
const toast = await page.waitForSelector("div[class*='data-testid-toast-success']");
await expect(toast).toBeTruthy();
expect(toast).toBeTruthy();
});
});
@@ -7,6 +7,8 @@ import {
selectSecondAvailableTimeSlotNextMonth,
} from "./lib/testUtils";
test.afterEach(({ users }) => users.deleteAll());
test("dynamic booking", async ({ page, users }) => {
const pro = await users.create();
await pro.login();
@@ -55,8 +57,6 @@ test("dynamic booking", async ({ page, users }) => {
const cancelledHeadline = await page.locator('[data-testid="cancelled-headline"]').innerText();
await expect(cancelledHeadline).toBe("This event is cancelled");
expect(cancelledHeadline).toBe("This event is cancelled");
});
await users.deleteAll();
});
@@ -88,6 +88,8 @@ async function expectToContainValidPreviewIframe(
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("Embed Code Generator Tests", () => {
test.beforeEach(async ({ users }) => {
const pro = await users.create();
+5 -8
View File
@@ -1,7 +1,7 @@
import type { Page, WorkerInfo } from "@playwright/test";
import type Prisma from "@prisma/client";
import { MembershipRole, Prisma as PrismaType } from "@prisma/client";
import { hash } from "bcryptjs";
import { hashSync as hash } from "bcryptjs";
import dayjs from "@calcom/dayjs";
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
@@ -10,8 +10,8 @@ import { prisma } from "@calcom/prisma";
import type { TimeZoneEnum } from "./types";
// Don't import hashPassword from app as that ends up importing next-auth and initializing it before NEXTAUTH_URL can be updated during tests.
export async function hashPassword(password: string) {
const hashedPassword = await hash(password, 12);
export function hashPassword(password: string) {
const hashedPassword = hash(password, 12);
return hashedPassword;
}
@@ -297,17 +297,14 @@ type CustomUserOptsKeys = "username" | "password" | "completedOnboarding" | "loc
type CustomUserOpts = Partial<Pick<Prisma.User, CustomUserOptsKeys>> & { timeZone?: TimeZoneEnum };
// creates the actual user in the db.
const createUser = async (
workerInfo: WorkerInfo,
opts?: CustomUserOpts | null
): Promise<PrismaType.UserCreateInput> => {
const createUser = (workerInfo: WorkerInfo, opts?: CustomUserOpts | null): PrismaType.UserCreateInput => {
// build a unique name for our user
const uname = `${opts?.username || "user"}-${workerInfo.workerIndex}-${Date.now()}`;
return {
username: uname,
name: opts?.name,
email: `${uname}@example.com`,
password: await hashPassword(uname),
password: hashPassword(uname),
emailVerified: new Date(),
completedOnboarding: opts?.completedOnboarding ?? true,
timeZone: opts?.timeZone ?? dayjs.tz.guess(),
@@ -4,6 +4,7 @@ import { test } from "./lib/fixtures";
import { selectFirstAvailableTimeSlotNextMonth, todo } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
const IS_STRIPE_ENABLED = !!(
process.env.STRIPE_CLIENT_ID &&
@@ -32,9 +33,6 @@ test.describe("Stripe integration", () => {
await expect(
page.locator(`li:has-text("Stripe") >> [data-testid="stripe_payment-integration-disconnect-button"]`)
).toContainText("");
// Cleanup
await users.deleteAll();
});
});
@@ -70,9 +68,6 @@ test.describe("Stripe integration", () => {
// Make sure we're navigated to the success page
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
// Cleanup
await users.deleteAll();
});
todo("Pending payment booking should not be confirmed by default");
+1 -11
View File
@@ -159,6 +159,7 @@ test.afterEach(() => requestInterceptor.resetHandlers());
// Disable API mocking after the tests are done.
test.afterAll(() => requestInterceptor.close());
test.afterEach(({ users }) => users.deleteAll());
// TODO: Fix MSW mocking
test.fixme("Integrations", () => {
@@ -210,17 +211,6 @@ test.fixme("Integrations", () => {
});
};
test.describe("Zoom App", () => {
test.afterEach(async () => {
await prisma?.credential.deleteMany({
where: {
user: {
email: "pro@example.com",
},
type: "zoom_video",
},
});
});
test("Can add integration", async ({ page, users }) => {
const user = await users.create();
await user.login();
+3 -1
View File
@@ -1,9 +1,11 @@
import type { Page } from "@playwright/test";
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import type { IncomingMessage, ServerResponse } from "http";
import { createServer } from "http";
import noop from "lodash/noop";
import { test } from "./fixtures";
export function todo(title: string) {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(title, noop);
+2
View File
@@ -5,6 +5,8 @@ import { test } from "./lib/fixtures";
test.describe.configure({ mode: "serial" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("Onboarding", () => {
test.describe("Onboarding v2", () => {
test("Onboarding Flow", async ({ page, users }) => {
+2 -3
View File
@@ -14,10 +14,9 @@ const IS_STRIPE_ENABLED = !!(
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("Reschedule Tests", async () => {
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test("Should do a booking request reschedule from /bookings", async ({ page, users, bookings }) => {
const user = await users.create();
+6 -4
View File
@@ -1,14 +1,14 @@
import { expect } from "@playwright/test";
import { prisma } from "@calcom/prisma";
import { test } from "./lib/fixtures";
test.describe.configure({ mode: "parallel" });
test.describe("Teams", () => {
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test.afterEach(({ users }) => users.deleteAll());
test.describe("Teams", () => {
test("Can create teams via Wizard", async ({ page, users }) => {
const user = await users.create();
const inviteeEmail = `${user.username}+invitee@example.com`;
@@ -44,6 +44,8 @@ test.describe("Teams", () => {
await removeMemberButton.click();
await removeMemberButton.waitFor({ state: "hidden" });
expect(await page.locator('[data-testid="pending-member-item"]').count()).toBe(1);
// Cleanup here since this user is created without our fixtures.
await prisma.user.delete({ where: { email: inviteeEmail } });
});
await test.step("Can publish team", async () => {
+2
View File
@@ -3,6 +3,8 @@ import { expect } from "@playwright/test";
import { test } from "./lib/fixtures";
import { createHttpServer, selectFirstAvailableTimeSlotNextMonth, waitFor } from "./lib/testUtils";
test.afterEach(({ users }) => users.deleteAll());
test("add webhook & test that creating an event triggers a webhook call", async ({
page,
users,
+2 -2
View File
@@ -7,6 +7,8 @@ import { test } from "./lib/fixtures";
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("Wipe my Cal App Test", () => {
test("Browse upcoming bookings and validate button shows and triggering wipe my cal button", async ({
page,
@@ -47,7 +49,5 @@ test.describe("Wipe my Cal App Test", () => {
page.locator("data-testid=send_request").click();
// There will not be any today-bookings
await expect(page.locator('[data-testid="today-bookings"]')).toBeHidden();
await users.deleteAll();
});
});