E2E fixing attemps
This commit is contained in:
1 parent
43f479299a
commit
613e42ce70
2 files changed
+21
-23
No files matched your search
@@ -74,12 +74,15 @@ test.describe("free user", () => {
|
|||||||
test.describe("pro user", () => {
|
test.describe("pro user", () => {
|
||||||
test.use({ storageState: "playwright/artifacts/proStorageState.json" });
|
test.use({ storageState: "playwright/artifacts/proStorageState.json" });
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeAll(async () => {
|
||||||
await deleteAllBookingsByEmail("[email protected]");
|
await deleteAllBookingsByEmail("[email protected]");
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto("/pro");
|
await page.goto("/pro");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterAll(async () => {
|
||||||
await deleteAllBookingsByEmail("[email protected]");
|
await deleteAllBookingsByEmail("[email protected]");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,14 +93,9 @@ test.describe("pro user", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("book an event first day in next month", async ({ page }) => {
|
test("book an event first day in next month", async ({ page }) => {
|
||||||
// Click first event type
|
await bookFirstEvent(page);
|
||||||
await page.click('[data-testid="event-type-link"]');
|
|
||||||
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
||||||
await bookTimeSlot(page);
|
|
||||||
|
|
||||||
// Make sure we're navigated to the success page
|
|
||||||
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("can reschedule a booking", async ({ page }) => {
|
test("can reschedule a booking", async ({ page }) => {
|
||||||
await bookFirstEvent(page);
|
await bookFirstEvent(page);
|
||||||
|
|
||||||
@@ -120,7 +118,7 @@ test.describe("pro user", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.fixme("Can cancel the recently created booking and rebook the same timeslot", async ({ page }) => {
|
test("Can cancel the recently created booking and rebook the same timeslot", async ({ page }) => {
|
||||||
await bookFirstEvent(page);
|
await bookFirstEvent(page);
|
||||||
|
|
||||||
await page.goto("/bookings/upcoming");
|
await page.goto("/bookings/upcoming");
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { expect, test } from "@playwright/test";
|
|||||||
import { BookingStatus } from "@prisma/client";
|
import { BookingStatus } from "@prisma/client";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
import prisma from "@lib/prisma";
|
||||||
|
|
||||||
import { TestUtilCreateBookingOnUserId, TestUtilCreatePayment } from "./lib/dbSetup";
|
import { TestUtilCreateBookingOnUserId, TestUtilCreatePayment } from "./lib/dbSetup";
|
||||||
import { deleteAllBookingsByEmail } from "./lib/teardown";
|
import { deleteAllBookingsByEmail } from "./lib/teardown";
|
||||||
import { selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils";
|
import { selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils";
|
||||||
@@ -12,7 +14,7 @@ const IS_STRIPE_ENABLED = !!(
|
|||||||
process.env.STRIPE_PRIVATE_KEY
|
process.env.STRIPE_PRIVATE_KEY
|
||||||
);
|
);
|
||||||
const findUserByEmail = async (email: string) => {
|
const findUserByEmail = async (email: string) => {
|
||||||
return await prisma?.user.findFirst({
|
return await prisma.user.findFirst({
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
email: true,
|
email: true,
|
||||||
@@ -43,7 +45,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
|
|
||||||
test("Should do a booking request reschedule from /bookings", async ({ page }) => {
|
test("Should do a booking request reschedule from /bookings", async ({ page }) => {
|
||||||
const user = currentUser;
|
const user = currentUser;
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
slug: "30min",
|
slug: "30min",
|
||||||
@@ -69,7 +71,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
await page.goto("/bookings/cancelled");
|
await page.goto("/bookings/cancelled");
|
||||||
|
|
||||||
// Find booking that was recently cancelled
|
// Find booking that was recently cancelled
|
||||||
const booking = await prisma?.booking.findFirst({
|
const booking = await prisma.booking.findFirst({
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
uid: true,
|
uid: true,
|
||||||
@@ -87,7 +89,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
|
|
||||||
test("Should display former time when rescheduling availability", async ({ page }) => {
|
test("Should display former time when rescheduling availability", async ({ page }) => {
|
||||||
const user = currentUser;
|
const user = currentUser;
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
slug: "30min",
|
slug: "30min",
|
||||||
@@ -110,7 +112,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
|
|
||||||
test("Should display request reschedule send on bookings/cancelled", async ({ page }) => {
|
test("Should display request reschedule send on bookings/cancelled", async ({ page }) => {
|
||||||
const user = currentUser;
|
const user = currentUser;
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
slug: "30min",
|
slug: "30min",
|
||||||
@@ -132,7 +134,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
test("Should do a reschedule from user owner", async ({ page }) => {
|
test("Should do a reschedule from user owner", async ({ page }) => {
|
||||||
const user = currentUser;
|
const user = currentUser;
|
||||||
|
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
},
|
},
|
||||||
@@ -155,13 +157,11 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
|
|
||||||
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
||||||
|
|
||||||
await expect(page).toHaveURL(/.*success/);
|
|
||||||
|
|
||||||
// NOTE: remove if old booking should not be deleted
|
// NOTE: remove if old booking should not be deleted
|
||||||
const oldBooking = await prisma?.booking.findFirst({ where: { id: booking?.id } });
|
const oldBooking = await prisma.booking.findFirst({ where: { id: booking?.id } });
|
||||||
expect(oldBooking).toBeNull();
|
expect(oldBooking).toBeNull();
|
||||||
|
|
||||||
const newBooking = await prisma?.booking.findFirst({ where: { fromReschedule: booking?.uid } });
|
const newBooking = await prisma.booking.findFirst({ where: { fromReschedule: booking?.uid } });
|
||||||
expect(newBooking).not.toBeNull();
|
expect(newBooking).not.toBeNull();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -174,7 +174,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
"Skipped as stripe is not installed and user is missing credentials"
|
"Skipped as stripe is not installed and user is missing credentials"
|
||||||
);
|
);
|
||||||
|
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
slug: "paid",
|
slug: "paid",
|
||||||
@@ -208,7 +208,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
test("Paid rescheduling should go to success page", async ({ page }) => {
|
test("Paid rescheduling should go to success page", async ({ page }) => {
|
||||||
let user = currentUser;
|
let user = currentUser;
|
||||||
try {
|
try {
|
||||||
const eventType = await prisma?.eventType.findFirst({
|
const eventType = await prisma.eventType.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId: user?.id,
|
userId: user?.id,
|
||||||
slug: "paid",
|
slug: "paid",
|
||||||
@@ -232,7 +232,7 @@ test.describe("Reschedule Tests", async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await prisma?.payment.delete({
|
await prisma.payment.delete({
|
||||||
where: {
|
where: {
|
||||||
externalId: "DEMO_PAYMENT_FROM_DB",
|
externalId: "DEMO_PAYMENT_FROM_DB",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user