Feature/new onboarding page (#3377)
* [WIP] New design and components for onboarding page * saving work in progress * new fonts * [WIP] new onboarding page, initial page, components * WIP calendar connect * WIP availability new design * WIP onboarding page * WIP onboarding, working new availability form * WIP AvailabilitySchedule componente v2 * WIP availability with defaultSchedule * User profile view * Relocate new onboarding/getting-started page components * Steps test for onboarding v2 * Remove logs and unused code * remove any as types * Adding translations * Fixes translation text and css for step 4 * Deprecation note for old-getting-started * Added defaul events and refetch user query when finishing getting-started * Fix button text translation * Undo schedule v1 changes * Fix calendar switches state * Add cookie to save return-to when connecting calendar * Change useTranslation for useLocale instead * Change test to work with data-testid instead of hardcoded plain text due to translation * Fix skeleton containers for calendars * Style fixes * fix styles to match v2 * Fix styles and props types to match v2 design * Bugfix/router and console errors (#4206) * The loading={boolean} parameter is required, so this must be <Button /> * Fixes duplicate key error * Use zod and router.query.step directly to power state machine * use ul>li & divide for borders * Update apps/web/components/getting-started/steps-views/ConnectCalendars.tsx Co-authored-by: alannnc <[email protected]> * Linting * Deprecation notices and type fixes * Update CreateEventsOnCalendarSelect.tsx * Type fixes Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: zomars <[email protected]>
This commit is contained in:
48 files changed
+1714
-470
No files matched your search
@@ -237,7 +237,7 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {
|
||||
};
|
||||
};
|
||||
|
||||
type CustomUserOptsKeys = "username" | "password" | "plan" | "completedOnboarding" | "locale";
|
||||
type CustomUserOptsKeys = "username" | "password" | "plan" | "completedOnboarding" | "locale" | "name";
|
||||
type CustomUserOpts = Partial<Pick<Prisma.User, CustomUserOptsKeys>> & { timeZone?: TimeZoneEnum };
|
||||
|
||||
// creates the actual user in the db.
|
||||
@@ -251,7 +251,7 @@ const createUser = async (
|
||||
}-${Date.now()}`;
|
||||
return {
|
||||
username: uname,
|
||||
name: (opts?.username ?? opts?.plan ?? UserPlan.PRO).toUpperCase(),
|
||||
name: opts?.name === undefined ? (opts?.plan ?? UserPlan.PRO).toUpperCase() : opts?.name,
|
||||
plan: opts?.plan ?? UserPlan.PRO,
|
||||
email: `${uname}@example.com`,
|
||||
password: await hashPassword(uname),
|
||||
|
||||
@@ -1,51 +1,159 @@
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
import { UserPlan } from "@prisma/client";
|
||||
|
||||
import { test } from "./lib/fixtures";
|
||||
|
||||
test.describe("Onboarding", () => {
|
||||
test.beforeEach(async ({ users }) => {
|
||||
const onboardingUser = await users.create({ completedOnboarding: false });
|
||||
await onboardingUser.login();
|
||||
});
|
||||
test.afterEach(({ users }) => users.deleteAll());
|
||||
test.describe.configure({ mode: "parallel" });
|
||||
|
||||
test("redirects to /getting-started after login", async ({ page }) => {
|
||||
await page.goto("/event-types");
|
||||
await page.waitForNavigation({
|
||||
url(url) {
|
||||
return url.pathname === "/getting-started";
|
||||
},
|
||||
test.describe("Onboarding", () => {
|
||||
test.describe("Onboarding v2", () => {
|
||||
test("test onboarding v2 new user first step", async ({ page, users }) => {
|
||||
const user = await users.create({ plan: UserPlan.TRIAL, completedOnboarding: false, name: "new user" });
|
||||
await user.login();
|
||||
await page.goto("/getting-started");
|
||||
|
||||
// First step
|
||||
await page.waitForSelector("text=Welcome to Cal.com");
|
||||
const usernameInput = await page.locator("input[name=username]");
|
||||
await usernameInput.fill("new user onboarding");
|
||||
|
||||
const nameInput = await page.locator("input[name=name]");
|
||||
await nameInput.fill("new user 2");
|
||||
|
||||
const timezoneSelect = await page.locator("input[role=combobox]");
|
||||
await timezoneSelect.click();
|
||||
const timezoneOption = await page.locator("text=Eastern Time");
|
||||
await timezoneOption.click();
|
||||
|
||||
const nextButtonUserProfile = await page.locator("button[type=submit]");
|
||||
await nextButtonUserProfile.click();
|
||||
|
||||
await expect(page).toHaveURL(/.*connected-calendar/);
|
||||
|
||||
const userComplete = await user.self();
|
||||
expect(userComplete.name).toBe("new user 2");
|
||||
});
|
||||
|
||||
test("test onboarding v2 new user second step", async ({ page, users }) => {
|
||||
const user = await users.create({ plan: UserPlan.TRIAL, completedOnboarding: false, name: "new user" });
|
||||
await user.login();
|
||||
await page.goto("/getting-started/connected-calendar");
|
||||
|
||||
// Second step
|
||||
|
||||
const nextButtonCalendar = await page.locator("button[data-testid=save-calendar-button]");
|
||||
const isDisabled = await nextButtonCalendar.isDisabled();
|
||||
await expect(isDisabled).toBe(true);
|
||||
|
||||
const skipStepButton = await page.locator("a[data-testid=skip-step]");
|
||||
await skipStepButton.click();
|
||||
await expect(page).toHaveURL(/.*setup-availability/);
|
||||
// @TODO: make sure calendar UL list has at least 1 item
|
||||
});
|
||||
|
||||
test("test onboarding v2 new user third step", async ({ page, users }) => {
|
||||
const user = await users.create({ plan: UserPlan.TRIAL, completedOnboarding: false, name: "new user" });
|
||||
await user.login();
|
||||
await page.goto("/getting-started/setup-availability");
|
||||
|
||||
// Third step
|
||||
|
||||
const nextButtonAvailability = await page.locator("button[data-testid=save-availability]");
|
||||
const isDisabled = await nextButtonAvailability.isDisabled();
|
||||
await expect(isDisabled).toBe(false);
|
||||
|
||||
const skipStepButton = await page.locator("a[data-testid=skip-step]");
|
||||
await skipStepButton.click();
|
||||
await expect(page).toHaveURL(/.*user-profile/);
|
||||
});
|
||||
|
||||
test("test onboarding v2 new user fourth step", async ({ page, users }) => {
|
||||
const user = await users.create({ plan: UserPlan.TRIAL, completedOnboarding: false, name: "new user" });
|
||||
await user.login();
|
||||
await page.goto("/getting-started/user-profile");
|
||||
|
||||
// Fourth step
|
||||
|
||||
const finishButton = await page.locator("button[type=submit]");
|
||||
const bioInput = await page.locator("input[name=bio]");
|
||||
await bioInput.fill("Something about me");
|
||||
const isDisabled = await finishButton.isDisabled();
|
||||
await expect(isDisabled).toBe(false);
|
||||
await finishButton.click();
|
||||
|
||||
await expect(page).toHaveURL(/.*event-types/);
|
||||
|
||||
const userComplete = await user.self();
|
||||
expect(userComplete.bio).toBe("Something about me");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Onboarding", () => {
|
||||
test("update onboarding username via localstorage", async ({ page, users }) => {
|
||||
const [onboardingUser] = users.get();
|
||||
/**
|
||||
* TODO:
|
||||
* We need to come up with a better test since all test are run in an incognito window.
|
||||
* Meaning that all localstorage access is null here.
|
||||
* Let's try saving the desiredUsername in the metadata instead
|
||||
*/
|
||||
test.fixme();
|
||||
await page.addInitScript(() => {
|
||||
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
||||
window.localStorage.setItem("username", "alwaysavailable");
|
||||
}, {});
|
||||
// Try to go getting started with a available username
|
||||
await page.goto("/getting-started");
|
||||
// Wait for useEffectUpdate to run
|
||||
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
const updatedUser = await prisma.user.findUnique({
|
||||
where: { id: onboardingUser.id },
|
||||
select: { id: true, username: true },
|
||||
test.describe("Onboarding v2 required field test", () => {
|
||||
test("test onboarding v2 new user first step required fields", async ({ page, users }) => {
|
||||
const user = await users.create({
|
||||
plan: UserPlan.TRIAL,
|
||||
completedOnboarding: false,
|
||||
name: null,
|
||||
username: null,
|
||||
});
|
||||
|
||||
expect(updatedUser?.username).toBe("alwaysavailable");
|
||||
await user.login();
|
||||
await page.goto("/getting-started");
|
||||
|
||||
// First step
|
||||
const nextButtonUserProfile = await page.locator("button[type=submit]");
|
||||
await nextButtonUserProfile.click();
|
||||
|
||||
const requiredName = await page.locator("data-testid=required");
|
||||
await expect(requiredName).toHaveText(/required/i);
|
||||
});
|
||||
|
||||
test("test onboarding v2 new user fourth step required fields", async ({ page, users }) => {
|
||||
const user = await users.create({
|
||||
plan: UserPlan.TRIAL,
|
||||
completedOnboarding: false,
|
||||
});
|
||||
|
||||
await user.login();
|
||||
await page.goto("/getting-started/user-profile");
|
||||
|
||||
// Fourth step
|
||||
await page.waitForSelector("text=Nearly there!");
|
||||
const finishButton = await page.locator("button[type=submit]");
|
||||
await finishButton.click();
|
||||
|
||||
const requiredBio = await page.locator("data-testid=required");
|
||||
await expect(requiredBio).toHaveText(/required/i);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Onboarding redirects", () => {
|
||||
test("redirects to /getting-started after login", async ({ page }) => {
|
||||
await page.goto("/event-types");
|
||||
await page.waitForNavigation();
|
||||
});
|
||||
|
||||
// @TODO: temporary disabled due to flakiness
|
||||
// test("test onboarding v2 new user simulate add calendar redirect", async ({ page, users }) => {
|
||||
// const user = await users.create({
|
||||
// plan: UserPlan.TRIAL,
|
||||
// completedOnboarding: false,
|
||||
// });
|
||||
|
||||
// await user.login();
|
||||
// const url = await page.url();
|
||||
// await page.context().addCookies([
|
||||
// {
|
||||
// name: "return-to",
|
||||
// value: "/getting-started/connected-calendar",
|
||||
// expires: 9999999999,
|
||||
// url,
|
||||
// },
|
||||
// ]);
|
||||
|
||||
// await page.goto("/apps/installed");
|
||||
|
||||
// await expect(page).toHaveURL(/.*connected-calendar/);
|
||||
// });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user