fix: Flakiness in tests (#12929)
This commit is contained in:
1 parent
c4792c55fe
commit
55c9efec3e
13 files changed
+134
-60
No files matched your search
@@ -1,14 +1,11 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { test as base } from "@playwright/test";
|
||||
import type { API } from "mailhog";
|
||||
import mailhog from "mailhog";
|
||||
|
||||
import { IS_MAILHOG_ENABLED } from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import type { ExpectedUrlDetails } from "../../../../playwright.config";
|
||||
import { createBookingsFixture } from "../fixtures/bookings";
|
||||
import { createEmailsFixture } from "../fixtures/emails";
|
||||
import { createEmbedsFixture } from "../fixtures/embeds";
|
||||
import { createFeatureFixture } from "../fixtures/features";
|
||||
import { createOrgsFixture } from "../fixtures/orgs";
|
||||
@@ -27,7 +24,7 @@ export interface Fixtures {
|
||||
embeds: ReturnType<typeof createEmbedsFixture>;
|
||||
servers: ReturnType<typeof createServersFixture>;
|
||||
prisma: typeof prisma;
|
||||
emails?: API;
|
||||
emails: ReturnType<typeof createEmailsFixture>;
|
||||
routingForms: ReturnType<typeof createRoutingFormsFixture>;
|
||||
bookingPage: ReturnType<typeof createBookingPageFixture>;
|
||||
features: ReturnType<typeof createFeatureFixture>;
|
||||
@@ -84,14 +81,7 @@ export const test = base.extend<Fixtures>({
|
||||
await use(createRoutingFormsFixture());
|
||||
},
|
||||
emails: async ({}, use) => {
|
||||
if (IS_MAILHOG_ENABLED) {
|
||||
const mailhogAPI = mailhog();
|
||||
await use(mailhogAPI);
|
||||
} else {
|
||||
//FIXME: Ideally we should error out here. If someone is running tests with mailhog disabled, they should be aware of it
|
||||
logger.warn("Mailhog is not enabled - Skipping Emails verification");
|
||||
await use(undefined);
|
||||
}
|
||||
await use(createEmailsFixture());
|
||||
},
|
||||
bookingPage: async ({ page }, use) => {
|
||||
const bookingPage = createBookingPageFixture(page);
|
||||
|
||||
@@ -6,13 +6,14 @@ import type { IncomingMessage, ServerResponse } from "http";
|
||||
import { createServer } from "http";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { noop } from "lodash";
|
||||
import type { API, Messages } from "mailhog";
|
||||
import type { Messages } from "mailhog";
|
||||
import { totp } from "otplib";
|
||||
|
||||
import type { Prisma } from "@calcom/prisma/client";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
import type { IntervalLimit } from "@calcom/types/Calendar";
|
||||
|
||||
import type { createEmailsFixture } from "../fixtures/emails";
|
||||
import type { Fixtures } from "./fixtures";
|
||||
import { test } from "./fixtures";
|
||||
|
||||
@@ -218,11 +219,15 @@ export async function getEmailsReceivedByUser({
|
||||
emails,
|
||||
userEmail,
|
||||
}: {
|
||||
emails?: API;
|
||||
emails?: ReturnType<typeof createEmailsFixture>;
|
||||
userEmail: string;
|
||||
}): Promise<Messages | null> {
|
||||
if (!emails) return null;
|
||||
return emails.search(userEmail, "to");
|
||||
const matchingEmails = await emails.search(userEmail, "to");
|
||||
if (!matchingEmails?.total) {
|
||||
console.log(`No emails received by ${userEmail}`);
|
||||
}
|
||||
return matchingEmails;
|
||||
}
|
||||
|
||||
export async function expectEmailsToHaveSubject({
|
||||
@@ -231,7 +236,7 @@ export async function expectEmailsToHaveSubject({
|
||||
booker,
|
||||
eventTitle,
|
||||
}: {
|
||||
emails?: API;
|
||||
emails?: ReturnType<typeof createEmailsFixture>;
|
||||
organizer: { name?: string | null; email: string };
|
||||
booker: { name: string; email: string };
|
||||
eventTitle: string;
|
||||
|
||||
Reference in new issue
Block a user