chore: fix all Typescript warnings (#8618)

* [CAL-1517] fix all Typescript warnings

* solve conflicts

* Update stripeCheckoutSession.handler.ts

Parse is a guard, so even though the variable is unused the parse itself is needed.

* Update ToolbarPlugin.tsx

Don't change dependency tree

---------

Co-authored-by: gitstart-calcom <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-06-06 11:59:57 +00:00
1 parent 87e1ad7115
commit 2dbc73c75b
106 files changed
+425 -319

No files matched your search

@@ -15,10 +15,11 @@ test("Can delete user account", async ({ page, users }) => {
await page.goto(`/settings/my-account/profile`);
await page.waitForLoadState("networkidle");
await page.click("[data-testid=delete-account]");
if (!user.username) throw Error(`Test user doesn't have a username`);
expect(user.username).toBeTruthy();
const $passwordField = page.locator("[data-testid=password]");
await $passwordField.fill(user.username);
await $passwordField.fill(String(user.username));
await Promise.all([
page.waitForURL((url) => url.pathname === "/auth/logout"),
@@ -5,9 +5,10 @@ import { test } from "../lib/fixtures";
test.afterEach(({ users }) => users.deleteAll());
test("Can reset forgotten password", async ({ page, users }) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(process.env.NEXT_PUBLIC_IS_E2E !== "1", "It shouldn't if we can't skip email");
const user = await users.create();
const newPassword = `${user.username!}-123`;
const newPassword = `${user.username}-123`;
// Got to reset password flow
await page.goto("/auth/forgot-password");
+3 -2
View File
@@ -10,12 +10,13 @@ test.describe("Change Password Test", () => {
await pro.login();
// Go to http://localhost:3000/settings/security
await page.goto("/settings/security/password");
if (!pro.username) throw Error("Test user doesn't have a username");
expect(pro.username).toBeTruthy();
await page.waitForLoadState("networkidle");
// Fill form
await page.locator('[name="oldPassword"]').fill(pro.username);
await page.locator('[name="oldPassword"]').fill(String(pro.username));
const $newPasswordField = page.locator('[name="newPassword"]');
$newPasswordField.fill(`${pro.username}Aa1111`);
@@ -50,6 +50,7 @@ test.describe("Change username on settings", () => {
test("User can update to PREMIUM username", async ({ page, users }, testInfo) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(!IS_STRIPE_ENABLED, "It should only run if Stripe is installed");
// eslint-disable-next-line playwright/no-skipped-test
test.skip(IS_SELF_HOSTED, "It shouldn't run on self hosted");
const user = await users.create();
@@ -11,6 +11,7 @@ test.afterEach(({ users }) => users.deleteAll());
// Due to some reason for Dynamic booking cancellation, daily video api_key is not set which causes cancellation to fail.
// This test is skipped until the issue is resolved in GH actions.
// eslint-disable-next-line playwright/no-skipped-test
test.skip("dynamic booking", async ({ page, users }) => {
const pro = await users.create();
await pro.login();
+1 -1
View File
@@ -69,7 +69,7 @@ test.describe("Event Types tests", () => {
'[data-testid="event-types"] a[href^="/event-types/"] >> nth=0'
);
const href = await firstElement.getAttribute("href");
if (!href) throw new Error("No href found for event type");
expect(href).toBeTruthy();
const [eventTypeId] = new URL(WEBAPP_URL + href).pathname.split("/").reverse();
const firstTitle = await page.locator(`[data-testid=event-type-title-${eventTypeId}]`).innerText();
const firstFullSlug = await page.locator(`[data-testid=event-type-slug-${eventTypeId}]`).innerText();
+3 -3
View File
@@ -58,7 +58,7 @@ export const createBookingsFixture = (page: Page) => {
status,
},
});
const bookingFixture = createBookingFixture(booking, store.page!);
const bookingFixture = createBookingFixture(booking, store.page);
store.bookings.push(bookingFixture);
return bookingFixture;
},
@@ -80,7 +80,7 @@ const createBookingFixture = (booking: Booking, page: Page) => {
return {
id: store.booking.id,
uid: store.booking.uid,
self: async () => (await prisma.booking.findUnique({ where: { id: store.booking.id } }))!,
delete: async () => (await prisma.booking.delete({ where: { id: store.booking.id } }))!,
self: async () => await prisma.booking.findUnique({ where: { id: store.booking.id } }),
delete: async () => await prisma.booking.delete({ where: { id: store.booking.id } }),
};
};
+3 -3
View File
@@ -36,7 +36,7 @@ export const createPaymentsFixture = (page: Page) => {
},
},
});
const paymentFixture = createPaymentFixture(payment, store.page!);
const paymentFixture = createPaymentFixture(payment, store.page);
store.payments.push(paymentFixture);
return paymentFixture;
},
@@ -57,7 +57,7 @@ const createPaymentFixture = (payment: Payment, page: Page) => {
// self is a reflective method that return the Prisma object that references this fixture.
return {
id: store.payment.id,
self: async () => (await prisma.payment.findUnique({ where: { id: store.payment.id } }))!,
delete: async () => (await prisma.payment.delete({ where: { id: store.payment.id } }))!,
self: async () => await prisma.payment.findUnique({ where: { id: store.payment.id } }),
delete: async () => await prisma.payment.delete({ where: { id: store.payment.id } }),
};
};
+3 -2
View File
@@ -233,7 +233,7 @@ export const createUsersFixture = (page: Page, workerInfo: WorkerInfo) => {
},
});
}
const userFixture = createUserFixture(user, store.page!);
const userFixture = createUserFixture(user, store.page);
store.users.push(userFixture);
return userFixture;
},
@@ -261,6 +261,7 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {
// self is a reflective method that return the Prisma object that references this fixture.
const self = async () =>
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(await prisma.user.findUnique({ where: { id: store.user.id }, include: { eventTypes: true } }))!;
return {
id: user.id,
@@ -277,7 +278,7 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {
debug: async (message: string | Record<string, JSONValue>) => {
await prisma.user.update({ where: { id: store.user.id }, data: { metadata: { debug: message } } });
},
delete: async () => (await prisma.user.delete({ where: { id: store.user.id } }))!,
delete: async () => await prisma.user.delete({ where: { id: store.user.id } }),
};
};
@@ -38,12 +38,12 @@ test.describe("Stripe integration", () => {
test("Can book a paid booking", async ({ page, users }) => {
const user = await users.create();
const eventType = user.eventTypes.find((e) => e.slug === "paid")!;
const eventType = user.eventTypes.find((e) => e.slug === "paid");
await user.login();
await page.goto("/apps/installed");
await user.getPaymentCredential();
await page.goto(`${user.username}/${eventType.slug}`);
await page.goto(`${user.username}/${eventType?.slug}`);
await selectFirstAvailableTimeSlotNextMonth(page);
// --- fill form
await page.fill('[name="name"]', "Stripe Stripeson");
+2 -1
View File
@@ -1,5 +1,6 @@
import type { Page, Route } from "@playwright/test";
import { expect } from "@playwright/test";
import type { DefaultBodyType } from "msw";
import { rest } from "msw";
import { setupServer } from "msw/node";
import { v4 as uuidv4 } from "uuid";
@@ -42,7 +43,7 @@ const addOauthBasedIntegration = async function ({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
verify: (config: { requestHeaders: any; params: URLSearchParams; code: string }) => {
status: number;
body: any;
body: DefaultBodyType;
};
};
}) {
+3 -3
View File
@@ -24,11 +24,11 @@ export const deleteAllBookingsByEmail = async (
});
export const deleteEventTypeByTitle = async (title: string) => {
const event = (await prisma.eventType.findFirst({
const event = await prisma.eventType.findFirst({
select: { id: true },
where: { title: title },
}))!;
await prisma.eventType.delete({ where: { id: event.id } });
});
await prisma.eventType.delete({ where: { id: event?.id } });
};
export const deleteAllWebhooksByEmail = async (email: string) => {
+1
View File
@@ -46,6 +46,7 @@ export function createHttpServer(opts: { requestHandler?: RequestHandler } = {})
// listen on random port
server.listen(0);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const port: number = (server.address() as any).port;
const url = `http://localhost:${port}`;
return {
@@ -65,7 +65,7 @@ test.describe("Manage Booking Questions", () => {
},
});
const teamId = team?.id ?? 0;
const teamId = team?.id;
const webhookReceiver = await addWebhook(undefined, teamId);
await test.step("Go to First Team Event", async () => {
@@ -86,7 +86,8 @@ async function runTestStepsCommonForTeamAndUserEventType(
webhookReceiver: {
port: number;
close: () => import("http").Server;
requestList: (import("http").IncomingMessage & { body?: unknown })[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
requestList: (import("http").IncomingMessage & { body?: any })[];
url: string;
},
bookerVariant: BookerVariants
@@ -175,7 +176,7 @@ async function runTestStepsCommonForTeamAndUserEventType(
const [request] = webhookReceiver.requestList;
const payload = (request.body as any).payload as any;
const payload = request.body.payload;
expect(payload.responses).toMatchObject({
email: {
@@ -212,7 +213,9 @@ async function runTestStepsCommonForTeamAndUserEventType(
await test.step("Do a reschedule and notice that we can't book without giving a value for rescheduleReason", async () => {
const page = previewTabPage;
await rescheduleFromTheLinkOnPage({ page, bookerVariant });
await rescheduleFromTheLinkOnPage({ page });
// eslint-disable-next-line playwright/no-page-pause
await page.pause();
await expectErrorToBeThereFor({ page, name: "rescheduleReason" });
});
}
@@ -368,7 +371,7 @@ async function rescheduleFromTheLinkOnPage({
bookerVariant,
}: {
page: Page;
bookerVariant: BookerVariants;
bookerVariant?: BookerVariants;
}) {
await page.locator('[data-testid="reschedule-link"]').click();
await page.waitForLoadState();
+1 -3
View File
@@ -76,9 +76,7 @@ test.describe("Onboarding", () => {
const userComplete = await user.self();
const userCompleteBio = userComplete.bio ? userComplete.bio : "";
expect(userCompleteBio.replace("<p><br></p>", "").length).toBe(0);
expect(userComplete.bio?.replace("<p><br></p>", "").length).toBe(0);
});
});
});
+3 -3
View File
@@ -39,9 +39,9 @@ testBothBookers.describe("Reschedule Tests", async () => {
const updatedBooking = await booking.self();
expect(updatedBooking.rescheduled).toBe(true);
expect(updatedBooking.cancellationReason).toBe("I can't longer have it");
expect(updatedBooking.status).toBe(BookingStatus.CANCELLED);
expect(updatedBooking?.rescheduled).toBe(true);
expect(updatedBooking?.cancellationReason).toBe("I can't longer have it");
expect(updatedBooking?.status).toBe(BookingStatus.CANCELLED);
await booking.delete();
});
+4 -2
View File
@@ -14,7 +14,7 @@ test.describe("BOOKING_CREATED", async () => {
test("add webhook & test that creating an event triggers a webhook call", async ({
page,
users,
}, testInfo) => {
}, _testInfo) => {
const webhookReceiver = createHttpServer();
const user = await users.create();
const [eventType] = user.eventTypes;
@@ -51,7 +51,8 @@ test.describe("BOOKING_CREATED", async () => {
});
const [request] = webhookReceiver.requestList;
const body = request.body as any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const body: any = request.body;
// remove dynamic properties that differs depending on where you run the tests
const dynamic = "[redacted/dynamic]";
@@ -305,6 +306,7 @@ test.describe("BOOKING_REQUESTED", async () => {
expect(webhookReceiver.requestList.length).toBe(1);
});
const [request] = webhookReceiver.requestList;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const body = request.body as any;
// remove dynamic properties that differs depending on where you run the tests