Files
calendar/apps/web/playwright/integrations-stripe.test.ts
T
alannncGitHubPeer Richelsenzomarskodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
c890e8d06d feature/settings-username-update (#2306)
* WIP feature/settings-username-update

* WIP username change

* WIP downgrade stripe

* stripe downgrade and prorate preview

* new UI for username premium component

* Fix server side props

* Remove migration, changed field to metadata user

* WIP for update subscriptions

* WIP intent username table

* WIP saving and updating username via hooks

* WIP saving working username sub update

* WIP, update html to work with tests

* Added stripe test for username update go to stripe

* WIP username change test

* Working test for username change

* Fix timeout for flaky test

* Review changes, remove logs

* Move input username as a self contained component

* Self review changes

* Removing unnecesary arrow function

* Removed intentUsername table and now using user metadata

* Update website

* Update turbo.json

* Update e2e.yml

* Update yarn.lock

* Fixes for self host username update

* Revert yarn lock from main branch

* E2E fixes

* Centralizes username check

* Improvements

* WIP separate logic between premium and save username button

* WIP refactor username premium update

* Saving WIP

* WIP redo of username check

* WIP obtain action normal, update or downgrade

* Update username change components

* Fix test for change-username self host or cal server

* Fix user type for premiumTextfield

* Using now a global unique const to know if is selfhosted, css fixes

* Remove unused import

* Using dynamic import for username textfield, prevent submit on enter

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-06 13:31:07 -06:00

80 lines
2.9 KiB
TypeScript

import { expect } from "@playwright/test";
import { test } from "./lib/fixtures";
import { selectFirstAvailableTimeSlotNextMonth, todo } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
const IS_STRIPE_ENABLED = !!(
process.env.STRIPE_CLIENT_ID &&
process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY &&
process.env.STRIPE_PRIVATE_KEY
);
test.describe("Stripe integration", () => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(!IS_STRIPE_ENABLED, "It should only run if Stripe is installed");
test.describe("Stripe integration dashboard", () => {
test("Can add Stripe integration", async ({ page, users }) => {
const user = await users.create();
await user.login();
await page.goto("/apps/installed");
await user.getPaymentCredential();
/** If Stripe is added correctly we should see the "Disconnect" button */
await expect(
page.locator(`li:has-text("Stripe") >> [data-testid="integration-connection-button"]`)
).toContainText("Disconnect");
// Cleanup
await users.deleteAll();
});
});
test("Can book a paid booking", async ({ page, users }) => {
const user = await users.create();
const eventType = user.eventTypes.find((e) => e.slug === "paid")!;
await user.login();
await page.goto("/apps/installed");
await user.getPaymentCredential();
await page.goto(`${user.username}/${eventType.slug}`);
await selectFirstAvailableTimeSlotNextMonth(page);
// --- fill form
await page.fill('[name="name"]', "Stripe Stripeson");
await page.fill('[name="email"]', "test@example.com");
await Promise.all([page.waitForNavigation({ url: "/payment/*" }), page.press('[name="email"]', "Enter")]);
const stripeFrame = page
.frameLocator('iframe[src^="https://js.stripe.com/v3/elements-inner-card-"]')
.first();
// Fill [placeholder="Card number"]
await stripeFrame.locator('[placeholder="Card number"]').fill("4242 4242 4242 4242");
// Fill [placeholder="MM / YY"]
await stripeFrame.locator('[placeholder="MM / YY"]').fill("12 / 24");
// Fill [placeholder="CVC"]
await stripeFrame.locator('[placeholder="CVC"]').fill("111");
// Fill [placeholder="ZIP"]
await stripeFrame.locator('[placeholder="ZIP"]').fill("11111");
// Click button:has-text("Pay now")
await page.click('button:has-text("Pay now")');
// Make sure we're navigated to the success page
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
// Cleanup
await users.deleteAll();
});
todo("Pending payment booking should not be confirmed by default");
todo("Payment should confirm pending payment booking");
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("Cancelled paid booking should be refunded");
});