AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend/onboarding): a left-out expert's tick takes a mouse click again (#15957)
Reinier van der Leer64bc646ed20c
diff --git a/autogpt_platform/frontend/playwright.tooltip.config.ts b/autogpt_platform/frontend/playwright.tooltip.config.tsindex a2e4778d99..22bbfbeee3 100644--- a/autogpt_platform/frontend/playwright.tooltip.config.ts+++ b/autogpt_platform/frontend/playwright.tooltip.config.ts@@ -2,7 +2,7 @@ import { defineConfig, devices } from "@playwright/test";export default defineConfig({testDir: "./src/playwright",- testMatch: "tooltip-interaction.browser.spec.ts",+ testMatch: "*.browser.spec.ts",forbidOnly: true,retries: 0,timeout: 60000,diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/HireStep/components/RecommendedExpertCard.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/HireStep/components/RecommendedExpertCard.tsxindex d9dcb7f1f5..04bd67bc3c 100644--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/HireStep/components/RecommendedExpertCard.tsx+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/HireStep/components/RecommendedExpertCard.tsx@@ -37,7 +37,7 @@ export function RecommendedExpertCard({<divclassName={cn(EXPERT_CARD_CLASS,- "relative",+ "relative isolate",isHired ? "border-zinc-900" : "border-zinc-200",)}data-testid="hire-step-expert"@@ -45,14 +45,15 @@ export function RecommendedExpertCard({>{isHired ? null : (// The wizard's own pick badge (SelectableCard), as a toggle: ticked- // cards are what the step's primary action hires.+ // cards are what the step's primary action hires. z-10 lifts it over the+ // faded header; the card's `isolate` keeps it under the list's edge fades.<buttontype="button"aria-pressed={isIncluded}aria-label={`Include ${expert.name}`}disabled={disabled}onClick={onToggleIncluded}- className="absolute right-2 top-2 flex size-7 items-center justify-center rounded-full disabled:cursor-not-allowed"+ className="absolute right-2 top-2 z-10 flex size-7 items-center justify-center rounded-full disabled:cursor-not-allowed"><spanclassName={cn(diff --git a/autogpt_platform/frontend/src/playwright/hire-step-card.browser.spec.ts b/autogpt_platform/frontend/src/playwright/hire-step-card.browser.spec.tsnew file mode 100644index 0000000000..35f6a56be3--- /dev/null+++ b/autogpt_platform/frontend/src/playwright/hire-step-card.browser.spec.ts@@ -0,0 +1,37 @@+import { expect, test } from "@playwright/test";++test("a left-out expert's tick takes a mouse click to put them back in", async ({+ page,+}) => {+ await page.goto("/src/playwright/hire-step-card/index.html");+ const tick = page.getByRole("button", { name: "Include Maria" });+ await expect(tick).toHaveAttribute("aria-pressed", "true");++ for (const pressed of ["false", "true"]) {+ await page.evaluate(() =>+ Promise.all(document.getAnimations().map((a) => a.finished)),+ );+ const box = await tick.boundingBox();+ expect(box).not.toBeNull();+ await page.mouse.click(box!.x + box!.width / 2, box!.y + box!.height / 2);+ await expect(tick).toHaveAttribute("aria-pressed", pressed);+ }+});++test("the tick stays under a z-10 overlay of the list, like its edge fades", async ({+ page,+}) => {+ await page.goto("/src/playwright/hire-step-card/index.html?covered");+ const tick = await page+ .getByRole("button", { name: "Include Maria" })+ .boundingBox();+ const overlay = await page.getByTestId("overlay").boundingBox();+ expect(tick).not.toBeNull();+ expect(overlay).not.toBeNull();+ const size = { width: tick!.width, height: tick!.height };+ const overTick = await page.screenshot({ clip: { ...tick!, ...size } });+ const overBlank = await page.screenshot({+ clip: { x: overlay!.x + 2, y: overlay!.y + 2, ...size },+ });+ expect(overTick.equals(overBlank)).toBe(true);+});diff --git a/autogpt_platform/frontend/src/playwright/hire-step-card/index.html b/autogpt_platform/frontend/src/playwright/hire-step-card/index.htmlnew file mode 100644index 0000000000..807206fb8b--- /dev/null+++ b/autogpt_platform/frontend/src/playwright/hire-step-card/index.html@@ -0,0 +1,11 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <title>Hire step card fixture</title>+ </head>+ <body>+ <div id="root"></div>+ <script type="module" src="./main.tsx"></script>+ </body>+</html>diff --git a/autogpt_platform/frontend/src/playwright/hire-step-card/main.tsx b/autogpt_platform/frontend/src/playwright/hire-step-card/main.tsxnew file mode 100644index 0000000000..50774786d4--- /dev/null+++ b/autogpt_platform/frontend/src/playwright/hire-step-card/main.tsx@@ -0,0 +1,34 @@+import { useState } from "react";+import { createRoot } from "react-dom/client";+import { RecommendedExpertCard } from "@/app/(no-navbar)/onboarding/steps/HireStep/components/RecommendedExpertCard";+import "@/app/globals.css";++function Fixture() {+ const [isIncluded, setIsIncluded] = useState(true);+ return (+ <div className="relative mx-auto mt-40 w-72">+ {new URLSearchParams(location.search).has("covered") ? (+ <div+ data-testid="overlay"+ className="pointer-events-none absolute -inset-8 z-10 bg-gray-100"+ />+ ) : null}+ <RecommendedExpertCard+ expert={{+ template_id: "maria",+ name: "Maria",+ role: "marketing",+ reason: "Plans and runs your campaigns.",+ }}+ isHired={false}+ isHiringThis={false}+ isIncluded={isIncluded}+ disabled={false}+ onHire={() => {}}+ onToggleIncluded={() => setIsIncluded(!isIncluded)}+ />+ </div>+ );+}++createRoot(document.getElementById("root")!).render(<Fixture />);