feat: Added e2e test paid booking should be able to be rescheduled (#10069)
* feat: Added e2e test paid booking should be able to be rescheduled * refactor: abstracted and simplied the logic * fix: stripe iframe isnt the first frame * fix: import expectpull/10083/head^2
parent
ef49fc4ce1
commit
0093b6faa5
|
@ -284,6 +284,7 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {
|
||||||
setupEventWithPrice(eventType, store.page),
|
setupEventWithPrice(eventType, store.page),
|
||||||
bookAndPaidEvent: async (eventType: Pick<Prisma.EventType, "slug">) =>
|
bookAndPaidEvent: async (eventType: Pick<Prisma.EventType, "slug">) =>
|
||||||
bookAndPaidEvent(user, eventType, store.page),
|
bookAndPaidEvent(user, eventType, store.page),
|
||||||
|
makePaymentUsingStripe: async () => makePaymentUsingStripe(store.page),
|
||||||
// ths is for developemnt only aimed to inject debugging messages in the metadata field of the user
|
// ths is for developemnt only aimed to inject debugging messages in the metadata field of the user
|
||||||
debug: async (message: string | Record<string, JSONValue>) => {
|
debug: async (message: string | Record<string, JSONValue>) => {
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
|
@ -398,7 +399,12 @@ export async function bookAndPaidEvent(
|
||||||
|
|
||||||
await Promise.all([page.waitForURL("/payment/*"), page.press('[name="email"]', "Enter")]);
|
await Promise.all([page.waitForURL("/payment/*"), page.press('[name="email"]', "Enter")]);
|
||||||
|
|
||||||
const stripeFrame = page.frameLocator("iframe").first();
|
await makePaymentUsingStripe(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function makePaymentUsingStripe(page: Page) {
|
||||||
|
const stripeElement = await page.locator(".StripeElement").first();
|
||||||
|
const stripeFrame = stripeElement.frameLocator("iframe").first();
|
||||||
await stripeFrame.locator('[name="number"]').fill("4242 4242 4242 4242");
|
await stripeFrame.locator('[name="number"]').fill("4242 4242 4242 4242");
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
await stripeFrame.locator('[name="expiry"]').fill(`${now.getMonth()} / ${now.getFullYear() + 1}`);
|
await stripeFrame.locator('[name="expiry"]').fill(`${now.getMonth()} / ${now.getFullYear() + 1}`);
|
||||||
|
|
|
@ -69,9 +69,31 @@ test.describe("Stripe integration", () => {
|
||||||
await expect(page.getByText("Unconfirmed")).toBeVisible();
|
await expect(page.getByText("Unconfirmed")).toBeVisible();
|
||||||
await expect(page.getByText("Pending payment").last()).toBeVisible();
|
await expect(page.getByText("Pending payment").last()).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Paid booking should be able to be rescheduled", async ({ page, users }) => {
|
||||||
|
const user = await users.create();
|
||||||
|
const eventType = user.eventTypes.find((e) => e.slug === "paid") as Prisma.EventType;
|
||||||
|
await user.apiLogin();
|
||||||
|
await page.goto("/apps/installed");
|
||||||
|
|
||||||
|
await user.getPaymentCredential();
|
||||||
|
await user.setupEventWithPrice(eventType);
|
||||||
|
await user.bookAndPaidEvent(eventType);
|
||||||
|
|
||||||
|
// Rescheduling the event
|
||||||
|
await Promise.all([page.waitForURL("/booking/*"), page.click('[data-testid="reschedule-link"]')]);
|
||||||
|
|
||||||
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForURL("/payment/*"),
|
||||||
|
page.click('[data-testid="confirm-reschedule-button"]'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await user.makePaymentUsingStripe();
|
||||||
|
});
|
||||||
todo("Payment should confirm pending payment booking");
|
todo("Payment should confirm pending payment booking");
|
||||||
todo("Payment should trigger a BOOKING_PAID webhook");
|
todo("Payment should trigger a BOOKING_PAID webhook");
|
||||||
todo("Paid booking should be able to be rescheduled");
|
|
||||||
todo("Paid booking should be able to be cancelled");
|
todo("Paid booking should be able to be cancelled");
|
||||||
todo("Cancelled paid booking should be refunded");
|
todo("Cancelled paid booking should be refunded");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue