Files
calendar/apps/web/playwright/saml.e2e.ts
T
5ff52e1239 chore: add saml signup test / improve signup e2e test (#16849)
* add comment to signup-view

* add a basic test for saml button in signup

* add a test for cookie consent checkbox

* refactor and remove duplicates

* rename data-testid for saml button

* add test for saml

* remove code not needed

* better naming

* improve

* address code nit

* skip saml test when needed

* fix flag

* improve

* improve more

* refactor

* refactor

* refactor

* fix and add 1 more test

* remove tag

* remove unneeded code

* fix

* fix test

* it needs to be parallel mode

* reduce code

* simplify

* fix

* fix flake

* fix another flake

* add comments + refactor

---------

Co-authored-by: unknown <adhabal2002@gmail.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2024-10-01 09:34:20 +01:00

82 lines
3.4 KiB
TypeScript

import { expect } from "@playwright/test";
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
import { IS_PREMIUM_USERNAME_ENABLED } from "@calcom/lib/constants";
import { login } from "./fixtures/users";
import { test } from "./lib/fixtures";
test.describe.configure({ mode: "parallel" });
test.describe("SAML tests", () => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(!isSAMLLoginEnabled, "Skipping due to SAML login being disabled");
test("test SAML configuration UI with pro@example.com", async ({ page }) => {
// TODO: Figure out a way to use the users from fixtures here, right now we cannot set
// the SAML_ADMINS env variables dynamically
await login({ username: "pro", email: "pro@example.com", password: "pro" }, page);
// eslint-disable-next-line playwright/no-skipped-test
// Try to go Security page
await page.goto("/settings/security/sso");
// It should redirect you to the event-types page
// await page.waitForSelector("[data-testid=saml_config]");
});
test.describe("SAML Signup Flow Test", async () => {
test.beforeEach(async ({ page }) => {
await page.goto("/signup");
await expect(page.locator("text=Create your account")).toBeVisible(); // this prevents flaky test
await page.getByTestId("continue-with-saml-button").click();
await page.waitForSelector('[data-testid="saml-submit-button"]');
});
test("Submit button should be disabled without username", async ({ page }) => {
await page.locator('input[name="email"]').fill("tester123@example.com");
const submitButton = page.getByTestId("saml-submit-button");
await expect(submitButton).toBeVisible();
await expect(submitButton).toBeDisabled();
});
test("Submit button should be disabled without email", async ({ page }) => {
await page.locator('input[name="username"]').fill("tester123");
const submitButton = page.getByTestId("saml-submit-button");
await expect(submitButton).toBeVisible();
await expect(submitButton).toBeDisabled();
});
test("Password input should not exist", async ({ page }) => {
await expect(page.locator('input[name="password"]')).toBeHidden();
});
test("Checkbox for cookie consent does not need to be checked", async ({ page }) => {
// Fill form
await page.locator('input[name="username"]').fill("tester123");
await page.locator('input[name="email"]').fill("tester123@example.com");
const submitButton = page.getByTestId("saml-submit-button");
const checkbox = page.getByTestId("signup-cookie-content-checkbox");
await checkbox.check();
await expect(submitButton).toBeEnabled();
// the cookie consent checkbox does not need to be checked for user to proceed
await checkbox.uncheck();
await expect(submitButton).toBeEnabled();
});
test("Submit button should be disabled with a premium username", async ({ page }) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(!IS_PREMIUM_USERNAME_ENABLED, "Only run on Cal.com");
// Fill form
await page.locator('input[name="username"]').fill("pro");
await page.locator('input[name="email"]').fill("pro@example.com");
// Submit form
const submitButton = page.getByTestId("saml-submit-button");
await expect(submitButton).toBeDisabled();
});
});
});