Skip to content

Scheduling infrastructure for absolutely everyone.

E2E and paid bookings fixes

zomars06702aa48aff
diff --git a/apps/web/ee/components/stripe/Payment.tsx b/apps/web/ee/components/stripe/Payment.tsx
index e1ae9dd2bb3..c6157114b2d 100644
--- a/apps/web/ee/components/stripe/Payment.tsx
+++ b/apps/web/ee/components/stripe/Payment.tsx
@@ -35,6 +35,7 @@ type Props = {
eventType: { id: number };
user: { username: string | null };
location?: string | null;
+ bookingId: number;
};
type States =
@@ -86,6 +87,7 @@ export default function PaymentComponent(props: Props) {
type: props.eventType.id,
user: props.user.username,
name,
+ bookingId: props.bookingId,
};
if (props.location) {
diff --git a/apps/web/ee/components/stripe/PaymentPage.tsx b/apps/web/ee/components/stripe/PaymentPage.tsx
index 08606bdd678..d1bfd3e8358 100644
--- a/apps/web/ee/components/stripe/PaymentPage.tsx
+++ b/apps/web/ee/components/stripe/PaymentPage.tsx
@@ -137,6 +137,7 @@ const PaymentPage: FC<PaymentPageProps> = (props) => {
eventType={props.eventType}
user={props.user}
location={props.booking.location}
+ bookingId={props.booking.id}
/>
</Elements>
)}
diff --git a/apps/web/ee/pages/payment/[uid].tsx b/apps/web/ee/pages/payment/[uid].tsx
index 23b44b9003d..fd7021b9b8e 100644
--- a/apps/web/ee/pages/payment/[uid].tsx
+++ b/apps/web/ee/pages/payment/[uid].tsx
@@ -21,6 +21,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
bookingId: true,
booking: {
select: {
+ id: true,
description: true,
title: true,
startTime: true,
diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts
index 05dcc2b58ba..52bf93f912a 100644
--- a/apps/web/pages/api/book/event.ts
+++ b/apps/web/pages/api/book/event.ts
@@ -769,6 +769,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
try {
const [firstStripeCredential] = user.credentials.filter((cred) => cred.type == "stripe_payment");
+ if (!firstStripeCredential) return res.status(500).json({ message: "Missing payment credentials" });
+
if (!booking.user) booking.user = user;
const payment = await handlePayment(evt, eventType, firstStripeCredential, booking);
diff --git a/apps/web/pages/success.tsx b/apps/web/pages/success.tsx
index 52b0e715e50..45ef3ff8a0b 100644
--- a/apps/web/pages/success.tsx
+++ b/apps/web/pages/success.tsx
@@ -636,7 +636,9 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const recurringEventIdQuery = asStringOrNull(context.query.recur);
const typeSlug = asStringOrNull(context.query.eventSlug) ?? "15min";
const dynamicEventName = asStringOrNull(context.query.eventName) ?? "";
- const bookingId = parseInt(context.query.bookingId as string);
+ if (typeof context.query.bookingId !== "string") return { notFound: true } as const;
+ const bookingId = parseInt(context.query.bookingId);
+ //http://localhost:3000/success?date=2022-06-02T02%3A00%3A00-06%3A00&type=5&user=pro&name=Stripe%20Stripeson
if (isNaN(typeId)) {
return {
diff --git a/apps/web/playwright/booking-pages.test.ts b/apps/web/playwright/booking-pages.test.ts
index 1df5137ee74..59814f3688f 100644
--- a/apps/web/playwright/booking-pages.test.ts
+++ b/apps/web/playwright/booking-pages.test.ts
@@ -85,7 +85,7 @@ test.describe("pro user", () => {
test("pro user's page has at least 2 visible events", async ({ page }) => {
// await page.pause();
- const $eventTypes = await page.locator("[data-testid=event-types] > *");
+ const $eventTypes = page.locator("[data-testid=event-types] > *");
expect(await $eventTypes.count()).toBeGreaterThanOrEqual(2);
});
@@ -102,7 +102,7 @@ test.describe("pro user", () => {
await bookFirstEvent(page);
await page.goto("/bookings/upcoming");
- await page.locator('[data-testid="reschedule"]').click();
+ await page.locator('[data-testid="reschedule"]').nth(0).click();
await page.locator('[data-testid="edit"]').click();
await page.waitForNavigation({
url: (url) => {
diff --git a/apps/web/playwright/dynamic-booking-pages.test.ts b/apps/web/playwright/dynamic-booking-pages.test.ts
index fe0c257603a..0f73b459ee2 100644
--- a/apps/web/playwright/dynamic-booking-pages.test.ts
+++ b/apps/web/playwright/dynamic-booking-pages.test.ts
@@ -8,6 +8,8 @@ import {
selectSecondAvailableTimeSlotNextMonth,
} from "./lib/testUtils";
+test.describe.configure({ mode: "parallel" });
+
test.describe("dynamic booking", () => {
test.use({ storageState: "playwright/artifacts/proStorageState.json" });
@@ -17,7 +19,7 @@ test.describe("dynamic booking", () => {
await page.goto("/pro+free");
});
- test.afterAll(async () => {
+ test.afterEach(async () => {
// delete test bookings
await deleteAllBookingsByEmail("[email protected]");
await deleteAllBookingsByEmail("[email protected]");
@@ -36,7 +38,7 @@ test.describe("dynamic booking", () => {
// Logged in
await page.goto("/bookings/upcoming");
- await page.locator('[data-testid="reschedule"]').click();
+ await page.locator('[data-testid="reschedule"]').nth(0).click();
await page.locator('[data-testid="edit"]').click();
await page.waitForNavigation({
url: (url) => {
diff --git a/apps/web/playwright/reschedule.test.ts b/apps/web/playwright/reschedule.test.ts
index d21cdbaae48..60459fae72d 100644
--- a/apps/web/playwright/reschedule.test.ts
+++ b/apps/web/playwright/reschedule.test.ts
@@ -58,7 +58,7 @@ test.describe("Reschedule Tests", async () => {
await page.goto("/bookings/upcoming");
- await page.locator('[data-testid="reschedule"]').click();
+ await page.locator('[data-testid="reschedule"]').nth(0).click();
await page.locator('[data-testid="reschedule_request"]').click();