E2E and paid bookings fixes

This commit is contained in:
zomars
2022-05-11 14:36:38 -06:00
parent f2988870d5
commit 06702aa48a
8 changed files with 16 additions and 6 deletions
@@ -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) {
@@ -137,6 +137,7 @@ const PaymentPage: FC<PaymentPageProps> = (props) => {
eventType={props.eventType}
user={props.user}
location={props.booking.location}
bookingId={props.booking.id}
/>
</Elements>
)}
+1
View File
@@ -21,6 +21,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
bookingId: true,
booking: {
select: {
id: true,
description: true,
title: true,
startTime: true,
+2
View File
@@ -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);
+3 -1
View File
@@ -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 {
+2 -2
View File
@@ -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) => {
@@ -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("pro@example.com");
await deleteAllBookingsByEmail("free@example.com");
@@ -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) => {
+1 -1
View File
@@ -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();