Scheduling infrastructure for absolutely everyone.
test: add apple calendar testing (#10137)
Wesley5eb3af54b3e8
diff --git a/.env.example b/.env.exampleindex 20bef8f8aa6..22816b653ed 100644--- a/.env.example+++ b/.env.example@@ -215,3 +215,8 @@ PROJECT_ID_VERCEL=TEAM_ID_VERCEL=# Get it from: https://vercel.com/account/tokensAUTH_BEARER_TOKEN_VERCEL=++# - APPLE CALENDAR+# Used for E2E tests on Apple Calendar+E2E_TEST_APPLE_CALENDAR_EMAIL=""+E2E_TEST_APPLE_CALENDAR_PASSWORD=""diff --git a/.github/workflows/e2e-app-store.yml b/.github/workflows/e2e-app-store.ymlindex 9b824f1e811..3ce655f4cb4 100644--- a/.github/workflows/e2e-app-store.yml+++ b/.github/workflows/e2e-app-store.yml@@ -41,6 +41,8 @@ jobs:CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}GOOGLE_LOGIN_ENABLED: ${{ vars.CI_GOOGLE_LOGIN_ENABLED }}NEXTAUTH_SECRET: ${{ secrets.CI_NEXTAUTH_SECRET }}diff --git a/.github/workflows/e2e-embed-react.yml b/.github/workflows/e2e-embed-react.ymlindex 6a1cbbf2722..5b356246c77 100644--- a/.github/workflows/e2e-embed-react.yml+++ b/.github/workflows/e2e-embed-react.yml@@ -38,6 +38,8 @@ jobs:CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}GOOGLE_LOGIN_ENABLED: ${{ vars.CI_GOOGLE_LOGIN_ENABLED }}NEXTAUTH_SECRET: ${{ secrets.CI_NEXTAUTH_SECRET }}diff --git a/.github/workflows/e2e-embed.yml b/.github/workflows/e2e-embed.ymlindex a162858006f..dd6870665af 100644--- a/.github/workflows/e2e-embed.yml+++ b/.github/workflows/e2e-embed.yml@@ -41,6 +41,8 @@ jobs:CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}GOOGLE_LOGIN_ENABLED: ${{ vars.CI_GOOGLE_LOGIN_ENABLED }}NEXTAUTH_SECRET: ${{ secrets.CI_NEXTAUTH_SECRET }}diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex d4c41d2c6cd..424619bf358 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -40,6 +40,8 @@ jobs:CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}EMAIL_SERVER_HOST: ${{ secrets.CI_EMAIL_SERVER_HOST }}EMAIL_SERVER_PORT: ${{ secrets.CI_EMAIL_SERVER_PORT }}diff --git a/.github/workflows/production-build-without-database.yml b/.github/workflows/production-build-without-database.ymlindex 32ef0785f7a..4e510662435 100644--- a/.github/workflows/production-build-without-database.yml+++ b/.github/workflows/production-build-without-database.yml@@ -7,6 +7,8 @@ env:ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}GOOGLE_LOGIN_ENABLED: ${{ vars.CI_GOOGLE_LOGIN_ENABLED }}NEXTAUTH_SECRET: ${{ secrets.CI_NEXTAUTH_SECRET }}diff --git a/.github/workflows/production-build.yml b/.github/workflows/production-build.ymlindex 1a9a211b9f9..3ea85d6141a 100644--- a/.github/workflows/production-build.yml+++ b/.github/workflows/production-build.yml@@ -7,6 +7,8 @@ env:ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}+ E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}+ E2E_TEST_APPLE_CALENDAR_PASSWORD: ${{ secrets.E2E_TEST_APPLE_CALENDAR_PASSWORD }}GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }}GOOGLE_LOGIN_ENABLED: ${{ vars.CI_GOOGLE_LOGIN_ENABLED }}NEXTAUTH_SECRET: ${{ secrets.CI_NEXTAUTH_SECRET }}diff --git a/apps/web/playwright/app-store.e2e.ts b/apps/web/playwright/app-store.e2e.tsindex 92b2371da06..bf6ada85615 100644--- a/apps/web/playwright/app-store.e2e.ts+++ b/apps/web/playwright/app-store.e2e.ts@@ -1,6 +1,7 @@import { expect } from "@playwright/test";import { test } from "./lib/fixtures";+import { installAppleCalendar } from "./lib/testUtils";test.describe.configure({ mode: "parallel" });@@ -10,10 +11,9 @@ test.describe("App Store - Authed", () => {test("Browse apple-calendar and try to install", async ({ page, users }) => {const pro = await users.create();await pro.apiLogin();- await page.goto("/apps/categories/calendar");- await page.click('[data-testid="app-store-app-card-apple-calendar"]');- await page.waitForURL("/apps/apple-calendar");- await page.click('[data-testid="install-app-button"]');++ await installAppleCalendar(page);+await expect(page.locator(`text=Connect to Apple Server`)).toBeVisible();});@@ -31,9 +31,8 @@ test.describe("App Store - Authed", () => {test.describe("App Store - Unauthed", () => {test("Browse apple-calendar and try to install", async ({ page }) => {- await page.goto("/apps/categories/calendar");- await page.click('[data-testid="app-store-app-card-apple-calendar"]');- await page.click('[data-testid="install-app-button"]');+ await installAppleCalendar(page);+await expect(page.locator(`[data-testid="login-form"]`)).toBeVisible();});});diff --git a/apps/web/playwright/apple-calendar.e2e.ts b/apps/web/playwright/apple-calendar.e2e.tsnew file mode 100644index 00000000000..4bdbe7e4d9f--- /dev/null+++ b/apps/web/playwright/apple-calendar.e2e.ts@@ -0,0 +1,35 @@+/* eslint-disable @typescript-eslint/no-non-null-assertion */+import { expect } from "@playwright/test";++import { test } from "./lib/fixtures";+import { installAppleCalendar } from "./lib/testUtils";++test.describe.configure({ mode: "parallel" });++test.afterEach(({ users }) => users.deleteAll());++const APPLE_CALENDAR_EMAIL = process.env.E2E_TEST_APPLE_CALENDAR_EMAIL!;+const APPLE_CALENDAR_PASSWORD = process.env.E2E_TEST_APPLE_CALENDAR_PASSWORD!;++const SHOULD_SKIP_TESTS = !APPLE_CALENDAR_EMAIL || !APPLE_CALENDAR_PASSWORD;++test.describe("Apple Calendar", () => {+ // eslint-disable-next-line playwright/no-skipped-test+ test.skip(SHOULD_SKIP_TESTS, "Skipping due to missing the testing credentials");++ test("Should be able to install and login on Apple Calendar", async ({ page, users }) => {+ const user = await users.create();+ await user.apiLogin();++ await installAppleCalendar(page);++ await expect(page.locator('[data-testid="apple-calendar-form"]')).toBeVisible();++ await page.fill('[data-testid="apple-calendar-email"]', APPLE_CALENDAR_EMAIL);+ await page.fill('[data-testid="apple-calendar-password"]', APPLE_CALENDAR_PASSWORD);+ await page.click('[data-testid="apple-calendar-login-button"]');++ await expect(page.getByText("Apple Calendar")).toBeVisible();+ await expect(page.getByText(APPLE_CALENDAR_EMAIL)).toBeVisible();+ });+});diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.tsindex 4ef9eaaa43f..01af6761467 100644--- a/apps/web/playwright/lib/testUtils.ts+++ b/apps/web/playwright/lib/testUtils.ts@@ -183,3 +183,10 @@ export async function gotoRoutingLink({// HACK: There seems to be some issue with the inputs to the form getting reset if we don't wait.await new Promise((resolve) => setTimeout(resolve, 1000));}++export async function installAppleCalendar(page: Page) {+ await page.goto("/apps/categories/calendar");+ await page.click('[data-testid="app-store-app-card-apple-calendar"]');+ await page.waitForURL("/apps/apple-calendar");+ await page.click('[data-testid="install-app-button"]');+}diff --git a/packages/app-store/applecalendar/pages/setup/index.tsx b/packages/app-store/applecalendar/pages/setup/index.tsxindex ac77a2eedfa..0bef9573c6b 100644--- a/packages/app-store/applecalendar/pages/setup/index.tsx+++ b/packages/app-store/applecalendar/pages/setup/index.tsx@@ -64,13 +64,17 @@ export default function AppleCalendarSetup() {router.push(json.url);}}}>- <fieldset className="space-y-2" disabled={form.formState.isSubmitting}>+ <fieldset+ className="space-y-2"+ disabled={form.formState.isSubmitting}+ data-testid="apple-calendar-form"><TextFieldrequiredtype="text"{...form.register("username")}label="Apple ID"placeholder="[email protected]"+ data-testid="apple-calendar-email"/><TextFieldrequired@@ -79,6 +83,7 @@ export default function AppleCalendarSetup() {label={t("password")}placeholder="•••••••••••••"autoComplete="password"+ data-testid="apple-calendar-password"/></fieldset>@@ -87,7 +92,10 @@ export default function AppleCalendarSetup() {<Button type="button" color="secondary" onClick={() => router.back()}>{t("cancel")}</Button>- <Button type="submit" loading={form.formState.isSubmitting}>+ <Button+ type="submit"+ loading={form.formState.isSubmitting}+ data-testid="apple-calendar-login-button">{t("save")}</Button></div>diff --git a/packages/embeds/embed-core/playwright/lib/testUtils.ts b/packages/embeds/embed-core/playwright/lib/testUtils.tsindex 716a6d73410..e1afa3aa49c 100644--- a/packages/embeds/embed-core/playwright/lib/testUtils.ts+++ b/packages/embeds/embed-core/playwright/lib/testUtils.ts@@ -153,3 +153,10 @@ export async function rescheduleEvent(username: string, frame: Frame, page: Pageawait expect(frame.locator("[data-testid=success-page]")).toBeVisible();return booking;}++export async function installAppleCalendar(page: Page) {+ await page.goto("/apps/categories/calendar");+ await page.click('[data-testid="app-store-app-card-apple-calendar"]');+ await page.waitForURL("/apps/apple-calendar");+ await page.click('[data-testid="install-app-button"]');+}diff --git a/turbo.json b/turbo.jsonindex 5d6eb147dca..ec76639de81 100644--- a/turbo.json+++ b/turbo.json@@ -193,6 +193,8 @@"DAILY_API_KEY","DAILY_SCALE_PLAN","DEBUG",+ "E2E_TEST_APPLE_CALENDAR_EMAIL",+ "E2E_TEST_APPLE_CALENDAR_PASSWORD","EMAIL_FROM","EMAIL_SERVER_HOST","EMAIL_SERVER_PASSWORD",