This commit is contained in:
Omar López 2022-03-08 15:40:31 -07:00 committed by GitHub
parent 4908b6fd01
commit 5908e5b14b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 40 deletions

View file

@ -2,7 +2,7 @@ import { expect, test } from "@playwright/test";
import prisma from "@lib/prisma"; import prisma from "@lib/prisma";
import { todo } from "./lib/testUtils"; import { selectFirstAvailableTimeSlotNextMonth, todo } from "./lib/testUtils";
const deleteBookingsByEmail = async (email: string) => const deleteBookingsByEmail = async (email: string) =>
prisma.booking.deleteMany({ prisma.booking.deleteMany({
@ -31,12 +31,8 @@ test.describe("free user", () => {
test("cannot book same slot multiple times", async ({ page }) => { test("cannot book same slot multiple times", async ({ page }) => {
// Click first event type // Click first event type
await page.click('[data-testid="event-type-link"]'); await page.click('[data-testid="event-type-link"]');
// Click [data-testid="incrementMonth"]
await page.click('[data-testid="incrementMonth"]'); await selectFirstAvailableTimeSlotNextMonth(page);
// Click [data-testid="day"]
await page.click('[data-testid="day"][data-disabled="false"]');
// Click [data-testid="time"]
await page.click('[data-testid="time"]');
// Navigate to book page // Navigate to book page
await page.waitForNavigation({ await page.waitForNavigation({
@ -98,17 +94,7 @@ 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 // Click first event type
await page.click('[data-testid="event-type-link"]'); await page.click('[data-testid="event-type-link"]');
// Click [data-testid="incrementMonth"] await selectFirstAvailableTimeSlotNextMonth(page);
await page.click('[data-testid="incrementMonth"]');
// @TODO: Find a better way to make test wait for full month change render to end
// so it can click up on the right day, also when resolve remove other todos
// Waiting for full month increment
await page.waitForTimeout(400);
// Click [data-testid="day"]
await page.click('[data-testid="day"][data-disabled="false"]');
// Click [data-testid="time"]
await page.click('[data-testid="time"]');
// --- fill form // --- fill form
await page.fill('[name="name"]', "Test Testson"); await page.fill('[name="name"]', "Test Testson");
await page.fill('[name="email"]', "test@example.com"); await page.fill('[name="email"]', "test@example.com");

View file

@ -1,7 +1,7 @@
import { expect, test } from "@playwright/test"; import { expect, test } from "@playwright/test";
import { hasIntegrationInstalled } from "../lib/integrations/getIntegrations"; import { hasIntegrationInstalled } from "../lib/integrations/getIntegrations";
import { todo } from "./lib/testUtils"; import { selectFirstAvailableTimeSlotNextMonth, todo } from "./lib/testUtils";
test.describe.serial("Stripe integration", () => { test.describe.serial("Stripe integration", () => {
test.skip(!hasIntegrationInstalled("stripe_payment"), "It should only run if Stripe is installed"); test.skip(!hasIntegrationInstalled("stripe_payment"), "It should only run if Stripe is installed");
@ -37,17 +37,7 @@ test.describe.serial("Stripe integration", () => {
test("Can book a paid booking", async ({ page }) => { test("Can book a paid booking", async ({ page }) => {
await page.goto("/pro/paid"); await page.goto("/pro/paid");
// Click [data-testid="incrementMonth"] await selectFirstAvailableTimeSlotNextMonth(page);
await page.click('[data-testid="incrementMonth"]');
// @TODO: Find a better way to make test wait for full month change render to end
// so it can click up on the right day, also when resolve remove other todos
// Waiting for full month increment
await page.waitForTimeout(400);
// Click [data-testid="day"]
await page.click('[data-testid="day"][data-disabled="false"]');
// Click [data-testid="time"]
await page.click('[data-testid="time"]');
// --- fill form // --- fill form
await page.fill('[name="name"]', "Stripe Stripeson"); await page.fill('[name="name"]', "Stripe Stripeson");
await page.fill('[name="email"]', "test@example.com"); await page.fill('[name="email"]', "test@example.com");

View file

@ -1,6 +1,6 @@
import { expect, test } from "@playwright/test"; import { expect, test } from "@playwright/test";
import { createHttpServer, todo, waitFor } from "./lib/testUtils"; import { createHttpServer, selectFirstAvailableTimeSlotNextMonth, todo, waitFor } from "./lib/testUtils";
test.describe("integrations", () => { test.describe("integrations", () => {
test.use({ storageState: "playwright/artifacts/proStorageState.json" }); test.use({ storageState: "playwright/artifacts/proStorageState.json" });
@ -38,14 +38,7 @@ test.describe("integrations", () => {
// --- Book the first available day next month in the pro user's "30min"-event // --- Book the first available day next month in the pro user's "30min"-event
await page.goto(`/pro/30min`); await page.goto(`/pro/30min`);
await page.click('[data-testid="incrementMonth"]'); await selectFirstAvailableTimeSlotNextMonth(page);
// @TODO: Find a better way to make test wait for full month change render to end
// so it can click up on the right day, also when resolve remove other todos
// Waiting for full month increment
await page.waitForTimeout(400);
await page.click('[data-testid="day"][data-disabled="false"]');
await page.click('[data-testid="time"]');
// --- fill form // --- fill form
await page.fill('[name="name"]', "Test Testson"); await page.fill('[name="name"]', "Test Testson");

View file

@ -1,4 +1,4 @@
import { test } from "@playwright/test"; import { Page, test } from "@playwright/test";
import { createServer, IncomingMessage, ServerResponse } from "http"; import { createServer, IncomingMessage, ServerResponse } from "http";
export function todo(title: string) { export function todo(title: string) {
@ -66,3 +66,13 @@ export async function waitFor(fn: () => Promise<unknown> | unknown, opts: { time
} }
} }
} }
export async function selectFirstAvailableTimeSlotNextMonth(page: Page) {
await page.click('[data-testid="incrementMonth"]');
// @TODO: Find a better way to make test wait for full month change render to end
// so it can click up on the right day, also when resolve remove other todos
// Waiting for full month increment
await page.waitForTimeout(400);
await page.click('[data-testid="day"][data-disabled="false"]');
await page.click('[data-testid="time"]');
}