E2E tests refactoring (#1318)

* Adds test todos

* Can't seem to change locales

* WIP playwright test refactoring

* jest-playwright cleanup

* Test fixes

* Test fixes

* More test fixes

* WIP: Testing fixes

* More test fixes

* Removes unused files

* Installs missing browsers for e2e

* ts-node fixes

* ts-check fixes

* Type fixes

* Fixes e2e

* FFS

* Renamex webhook snapshot

* Fixes webhook cross-platform

* Renamed webhook snapshot

* Apply suggestions from code review

Co-authored-by: Max Schmitt <[email protected]>

* Removes kont dependency

* Cleanup playwright options

* Next.js cache optimizations on CI

* Uses cache on e2e as well

* Fixme is introducing side-effects

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Bailey Pumfleet <[email protected]>
Co-authored-by: Max Schmitt <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-12-15 16:25:49 +00:00
1 parent 972402be2c
commit e6f71c81bb
21 files changed
+521 -847

No files matched your search

+27 -50
View File
@@ -1,41 +1,44 @@
import { kont } from "kont";
import { expect, test } from "@playwright/test";
import { loginProvider } from "./lib/loginProvider";
import { createHttpServer, waitFor } from "./lib/testUtils";
import { createHttpServer, todo, waitFor } from "./lib/testUtils";
jest.setTimeout(60e3);
jest.retryTimes(3);
test.describe("integrations", () => {
test.use({ storageState: "playwright/artifacts/proStorageState.json" });
describe("webhooks", () => {
const ctx = kont()
.useBeforeEach(
loginProvider({
user: "pro",
path: "/integrations",
waitForSelector: '[data-testid="new_webhook"]',
})
)
.done();
test.beforeEach(async ({ page }) => {
await page.goto("/integrations");
});
test("add webhook & test that creating an event triggers a webhook call", async () => {
const { page } = ctx;
todo("Can add Zoom integration");
todo("Can add Stripe integration");
todo("Can add Google Calendar");
todo("Can add Office 365 Calendar");
todo("Can add CalDav Calendar");
todo("Can add Apple Calendar");
test("add webhook & test that creating an event triggers a webhook call", async ({ page }, testInfo) => {
const webhookReceiver = createHttpServer();
// --- add webhook
await page.click('[data-testid="new_webhook"]');
await expect(page).toHaveSelector("[data-testid='WebhookDialogForm']");
expect(page.locator(`[data-testid='WebhookDialogForm']`)).toBeVisible();
await page.fill('[name="subscriberUrl"]', webhookReceiver.url);
await page.click("[type=submit]");
// dialog is closed
await expect(page).not.toHaveSelector("[data-testid='WebhookDialogForm']");
expect(page.locator(`[data-testid='WebhookDialogForm']`)).not.toBeVisible();
// page contains the url
await expect(page).toHaveSelector(`text='${webhookReceiver.url}'`);
expect(page.locator(`text='${webhookReceiver.url}'`)).toBeDefined();
// --- Book the first available day next month in the pro user's "30min"-event
await page.goto(`http://localhost:3000/pro/30min`);
await page.goto(`/pro/30min`);
await page.click('[data-testid="incrementMonth"]');
await page.click('[data-testid="day"][data-disabled="false"]');
await page.click('[data-testid="time"]');
@@ -67,35 +70,9 @@ describe("webhooks", () => {
// if we change the shape of our webhooks, we can simply update this by clicking `u`
// console.log("BODY", body);
expect(body).toMatchInlineSnapshot(`
Object {
"createdAt": "[redacted/dynamic]",
"payload": Object {
"additionInformation": "[redacted/dynamic]",
"attendees": Array [
Object {
"email": "[email protected]",
"name": "Test Testson",
"timeZone": "[redacted/dynamic]",
},
],
"description": "",
"destinationCalendar": null,
"endTime": "[redacted/dynamic]",
"metadata": Object {},
"organizer": Object {
"email": "[email protected]",
"name": "Pro Example",
"timeZone": "[redacted/dynamic]",
},
"startTime": "[redacted/dynamic]",
"title": "30min between Pro Example and Test Testson",
"type": "30min",
"uid": "[redacted/dynamic]",
},
"triggerEvent": "BOOKING_CREATED",
}
`);
// Text files shouldn't have platform specific suffixes
testInfo.snapshotSuffix = "";
expect(JSON.stringify(body)).toMatchSnapshot(`webhookResponse.txt`);
webhookReceiver.close();
});