Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce test time for onboarding e2e test #18403

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 73 additions & 80 deletions apps/web/playwright/onboarding.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,93 +1,86 @@
/* eslint-disable playwright/no-skipped-test */
import { expect } from "@playwright/test";

import { IdentityProvider } from "@calcom/prisma/enums";

import { test } from "./lib/fixtures";

test.describe.configure({ mode: "serial" });
test.describe.configure({ mode: "parallel" });

test.afterEach(({ users }) => users.deleteAll());

test.describe("Onboarding", () => {
test.describe("Onboarding v2", () => {
const testOnboarding = (identityProvider: IdentityProvider) => {
test(`Onboarding Flow - ${identityProvider} user`, async ({ page, users }) => {
const user = await users.create({
completedOnboarding: false,
name: null,
identityProvider,
});
await user.apiLogin();
await page.goto("/getting-started");
// tests whether the user makes it to /getting-started
// after login with completedOnboarding false
await page.waitForURL("/getting-started");

await test.step("step 1 - User Settings", async () => {
// Check required fields
await page.locator("button[type=submit]").click();
await expect(page.locator("data-testid=required")).toBeVisible();

// happy path
await page.locator("input[name=username]").fill("new user onboarding");
await page.locator("input[name=name]").fill("new user 2");
await page.locator("input[role=combobox]").click();
await page
.locator("*")
.filter({ hasText: /^Europe\/London/ })
.first()
.click();
await page.locator("button[type=submit]").click();

await expect(page).toHaveURL(/.*connected-calendar/);

const userComplete = await user.self();
expect(userComplete.name).toBe("new user 2");
});

await test.step("step 2 - Connected Calendar", async () => {
const isDisabled = await page.locator("button[data-testid=save-calendar-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();

await expect(page).toHaveURL(/.*connected-video/);
});

await test.step("step 3 - Connected Video", async () => {
const isDisabled = await page.locator("button[data-testid=save-video-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();

await expect(page).toHaveURL(/.*setup-availability/);
});

await test.step("step 4 - Setup Availability", async () => {
const isDisabled = await page.locator("button[data-testid=save-availability]").isDisabled();
await expect(isDisabled).toBe(false);
// same here, skip this step.
await page.locator("button[data-testid=save-availability]").click();

await expect(page).toHaveURL(/.*user-profile/);
});

await test.step("step 5- User Profile", async () => {
await page.locator("button[type=submit]").click();

// should redirect to /event-types after onboarding
await page.waitForURL("/event-types");

const userComplete = await user.self();

expect(userComplete.bio?.replace("<p><br></p>", "").length).toBe(0);
});
const testOnboarding = (identityProvider: IdentityProvider) => {
test(`Onboarding Flow - ${identityProvider} user`, async ({ page, users }) => {
const user = await users.create({
completedOnboarding: false,
name: null,
identityProvider,
});
};
await user.apiLogin();
await page.goto("/getting-started");
// tests whether the user makes it to /getting-started
// after login with completedOnboarding false
await page.waitForURL("/getting-started");

await test.step("step 1 - User Settings", async () => {
// Check required fields
await page.locator("button[type=submit]").click();
await expect(page.locator("data-testid=required")).toBeVisible();

// happy path
await page.locator("input[name=username]").fill("new user onboarding");
await page.locator("input[name=name]").fill("new user 2");
await page.locator("input[role=combobox]").click();
await page
.locator("*")
.filter({ hasText: /^Europe\/London/ })
.first()
.click();
await page.locator("button[type=submit]").click();

await expect(page).toHaveURL(/.*connected-calendar/);

const userComplete = await user.self();
expect(userComplete.name).toBe("new user 2");
});

await test.step("step 2 - Connected Calendar", async () => {
const isDisabled = await page.locator("button[data-testid=save-calendar-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();
await expect(page).toHaveURL(/.*connected-video/);
});

await test.step("step 3 - Connected Video", async () => {
const isDisabled = await page.locator("button[data-testid=save-video-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();
await expect(page).toHaveURL(/.*setup-availability/);
});

await test.step("step 4 - Setup Availability", async () => {
const isDisabled = await page.locator("button[data-testid=save-availability]").isDisabled();
await expect(isDisabled).toBe(false);
// same here, skip this step.

await page.locator("button[data-testid=save-availability]").click();
await expect(page).toHaveURL(/.*user-profile/);
});

await test.step("step 5- User Profile", async () => {
await page.locator("button[type=submit]").click();
// should redirect to /event-types after onboarding
await page.waitForURL("/event-types");

const userComplete = await user.self();
expect(userComplete.bio?.replace("<p><br></p>", "").length).toBe(0);
});
});
};

testOnboarding(IdentityProvider.GOOGLE);
testOnboarding(IdentityProvider.CAL);
testOnboarding(IdentityProvider.SAML);
});
testOnboarding(IdentityProvider.GOOGLE);
testOnboarding(IdentityProvider.CAL);
testOnboarding(IdentityProvider.SAML);
});
Loading