Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

complete onboarding e2e test

ThieryMichelbc3ba2b3f822
diff --git a/e2e/onboarding.spec.ts b/e2e/onboarding.spec.ts
index 384c54b7..0b070b0b 100644
--- a/e2e/onboarding.spec.ts
+++ b/e2e/onboarding.spec.ts
@@ -14,7 +14,90 @@ test("user onboarding", async ({ page }) => {
await page.getByRole("button", { name: "Create account" }).click();
await expect(page.getByText("What's next?")).toBeVisible();
+ await expect(page.getByText("1/3 done")).toBeVisible();
await expect(page.getByText("Install Atomic CRM")).toBeVisible();
await expect(page.getByText("Add your first contact")).toBeVisible();
await expect(page.getByText("Add your first note")).toBeVisible();
+
+ await page.getByText("New Contact").click();
+ await page.waitForLoadState("networkidle");
+ await page.getByLabel("She/Her").click();
+ await page.getByLabel("First name").fill("Jane");
+ await page.getByLabel("Last name").fill("Smith");
+ await page.getByLabel("Title").fill("CEO");
+ await page.getByLabel("Company").click();
+ await page.getByPlaceholder("Search...").fill("Smith Corp");
+ await page.getByText("Create Smith Corp").click();
+ await page
+ .getByRole("group", { name: "Email addresses" })
+ .getByRole("button", { name: "Add" })
+ .click();
+ await page
+ .getByRole("group", { name: "Email addresses" })
+ .getByRole("textbox", { name: "Email" })
+ .fill("[email protected]");
+
+ await page
+ .getByRole("group", { name: "Phone numbers" })
+ .getByRole("button", { name: "Add" })
+ .click();
+ await page
+ .getByRole("group", { name: "Phone numbers" })
+ .getByRole("textbox", { name: "Phone number" })
+ .fill("+1234567890");
+
+ await page
+ .getByLabel("LinkedIn URL")
+ .fill("https://www.linkedin.com/in/jane-smith");
+
+ await page
+ .getByLabel("Background info (bio, how you met, etc)")
+ .fill("Met at a conference.");
+
+ await page.getByLabel("Has newsletter").check();
+
+ await expect(page.getByLabel("Account manager *")).toHaveText("John Doe");
+
+ await page.getByRole("button", { name: "Save" }).click();
+
+ await page.waitForURL("**/contacts/*");
+ await page.waitForLoadState("networkidle");
+
+ await expect(page.getByText("Jane Smith")).toBeVisible();
+ await expect(page.getByText("CEO at Smith Corp")).toBeVisible();
+
+ await page.getByRole("link", { name: "Dashboard" }).click();
+ await page.waitForLoadState("networkidle");
+
+ await expect(page.getByText("2/3 done")).toBeVisible();
+
+ await page.getByRole("link", { name: "Add note" }).click();
+
+ await page.waitForLoadState("networkidle");
+
+ await page.getByPlaceholder("Add a note").fill("This is a note about Jane.");
+ await page.getByRole("button", { name: "Add this note" }).click();
+
+ await expect(page.getByText("Element created")).toBeVisible();
+ await page.waitForLoadState("networkidle");
+
+ await expect(page.getByText("You added a note")).toBeVisible();
+ await expect(page.getByText("This is a note about Jane.")).toBeVisible();
+
+ await page.getByRole("link", { name: "Dashboard" }).click();
+
+ await page.waitForLoadState("networkidle");
+
+ await expect(page.getByText("Latest Activity")).toBeVisible();
+ await expect(
+ page.getByText("Latest Activity").locator("xpath=../.."),
+ ).toHaveText(/You added company Smith Corp today at/);
+
+ await expect(
+ page.getByText("Latest Activity").locator("xpath=../.."),
+ ).toHaveText(/You added Jane Smith to Smith Corp today at/);
+
+ await expect(
+ page.getByText("Latest Activity").locator("xpath=../.."),
+ ).toHaveText(/You added a note about Jane Smith today at/);
});
diff --git a/playwright.config.ts b/playwright.config.ts
index 1513fd54..04aa260e 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -32,6 +32,7 @@ export default defineConfig({
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
+ actionTimeout: 5000,
},
/* Configure projects for major browsers */
diff --git a/src/components/admin/array-input.tsx b/src/components/admin/array-input.tsx
index 4e485533..7e76ed50 100644
--- a/src/components/admin/array-input.tsx
+++ b/src/components/admin/array-input.tsx
@@ -66,6 +66,8 @@ export const ArrayInput = (props: ArrayInputProps) => {
const parentSourceContext = useSourceContext();
const finalSource = parentSourceContext.getSource(arraySource);
+ const labelId = React.useId();
+
if (isPending) {
return <Skeleton className="w-full h-9" />;
}
@@ -78,10 +80,12 @@ export const ArrayInput = (props: ArrayInputProps) => {
className,
"w-full flex flex-col gap-2",
)}
+ aria-labelledby={labelId}
+ role="group"
name={finalSource}
{...sanitizeInputRestProps(rest)}
>
- <Label className="text-sm">
+ <Label className="text-sm" id={labelId}>
<FieldTitle
label={label}
source={arraySource}
diff --git a/src/components/admin/autocomplete-input.tsx b/src/components/admin/autocomplete-input.tsx
index 7782a071..722aebcf 100644
--- a/src/components/admin/autocomplete-input.tsx
+++ b/src/components/admin/autocomplete-input.tsx
@@ -110,6 +110,7 @@ export const AutocompleteInput = (
setFilters,
} = useChoicesContext(props);
const { id, field, isRequired } = useInput({ ...props, source });
+ const uniqueId = React.useId();
const translate = useTranslate();
const { placeholder = translate("ra.action.search", { _: "Search..." }) } =
props;
@@ -207,7 +208,7 @@ export const AutocompleteInput = (
<>
<FormField className={props.className} id={id} name={source}>
{props.label !== false && (
- <FormLabel>
+ <FormLabel id={uniqueId}>
<FieldTitle
label={props.label}
source={props.source ?? source}
@@ -223,6 +224,7 @@ export const AutocompleteInput = (
variant="outline"
role="combobox"
aria-expanded={open}
+ aria-labelledby={uniqueId}
className="w-full justify-between h-auto py-1.75 font-normal"
>
{selectedChoice ? (
diff --git a/src/components/admin/select-input.tsx b/src/components/admin/select-input.tsx
index 752c4336..26791c3d 100644
--- a/src/components/admin/select-input.tsx
+++ b/src/components/admin/select-input.tsx
@@ -14,7 +14,7 @@ import {
useTranslate,
} from "ra-core";
import type { ComponentProps, ReactElement } from "react";
-import { useCallback, useEffect } from "react";
+import { useCallback, useEffect, useId } from "react";
import { FormError, FormField, FormLabel } from "@/components/admin/form";
import { InputHelperText } from "@/components/admin/input-helper-text";
@@ -144,6 +144,7 @@ export const SelectInput = (props: SelectInputProps) => {
createValue,
createHintValue,
});
+ const labelId = useId();
const { id, field, isRequired } = useInput({
alwaysOn,
defaultValue,
@@ -212,7 +213,7 @@ export const SelectInput = (props: SelectInputProps) => {
className={cn("w-full min-w-20", className)}
>
{label !== "" && label !== false && (
- <FormLabel>
+ <FormLabel id={labelId}>
<FieldTitle
label={label}
source={source}
@@ -251,7 +252,7 @@ export const SelectInput = (props: SelectInputProps) => {
{...rest}
>
{label !== "" && label !== false && (
- <FormLabel>
+ <FormLabel id={labelId}>
<FieldTitle
label={label}
source={source}
@@ -273,6 +274,7 @@ export const SelectInput = (props: SelectInputProps) => {
<SelectTrigger
className={cn("w-full transition-all hover:bg-accent")}
disabled={field.disabled}
+ aria-labelledby={labelId}
>
<SelectValue placeholder={renderEmptyItemOption()} />
diff --git a/src/components/admin/simple-form-iterator.tsx b/src/components/admin/simple-form-iterator.tsx
index 5fa6f77f..4c13fac0 100644
--- a/src/components/admin/simple-form-iterator.tsx
+++ b/src/components/admin/simple-form-iterator.tsx
@@ -289,6 +289,7 @@ export const AddItemButton = (props: React.ComponentProps<"button">) => {
variant="ghost"
size="icon"
onClick={() => add()}
+ aria-label={translate("ra.action.add")}
className={cn("button-add", `button-add-${source}`, className)}
{...rest}
>