π OpenHands: AI-Driven Development
fix(onboarding): start a setup step's tour from its row and drop the template stop's footer (#18243)
Hiep Le3558417661ed
diff --git a/__tests__/components/features/setup-guide/setup-guide-tour.test.ts b/__tests__/components/features/setup-guide/setup-guide-tour.test.tsindex b0161be497..73e39524e1 100644--- a/__tests__/components/features/setup-guide/setup-guide-tour.test.ts+++ b/__tests__/components/features/setup-guide/setup-guide-tour.test.ts@@ -54,6 +54,18 @@ describe("setup guide tours", () => {},);+ it("hides the footer only on the stop that waits for a template card", async () => {+ await startSetupGuideTour("first-automation", NAV, t);+ await startSetupGuideTour("add-integration", NAV, t);++ const stops = vi+ .mocked(startGuidedTour)+ .mock.calls.flatMap(([tour]) => tour.stops);+ expect(+ stops.filter((stop) => stop.hideFooter).map((stop) => stop.id),+ ).toEqual(["choose-template"]);+ });+it("starts nothing for a step done in the enterprise app", async () => {await startSetupGuideTour("invite-users", NAV, t);diff --git a/__tests__/components/features/setup-guide/super-admin-setup-guide.test.tsx b/__tests__/components/features/setup-guide/super-admin-setup-guide.test.tsxindex 2ae2cf0a0f..e599606257 100644--- a/__tests__/components/features/setup-guide/super-admin-setup-guide.test.tsx+++ b/__tests__/components/features/setup-guide/super-admin-setup-guide.test.tsx@@ -387,6 +387,29 @@ describe("SuperAdminSetupGuide", () => {).toHaveAttribute("aria-expanded", "false");});+ it("starts a Canvas step's tour from its row, even when another step is next", async () => {+ activateBackend(cloudBackend);+ serveSetupGuide({+ setupState: () => HttpResponse.json(guideState({ org_llm: true })),+ });+ const user = userEvent.setup();+ const { navigate } = renderGuide();++ await user.click(+ await screen.findByTestId("super-admin-setup-guide-step-add-integration"),+ );++ expect(startSetupGuideTour).toHaveBeenCalledWith(+ "add-integration",+ expect.objectContaining({ navigate }),+ expect.any(Function),+ );+ expect(navigate).not.toHaveBeenCalled();+ expect(+ screen.getByTestId("super-admin-setup-guide-toggle"),+ ).toHaveAttribute("aria-expanded", "false");+ });+it("starts the tour a page opened from the enterprise guide asks for, once", async () => {window.history.replaceState(null,diff --git a/__tests__/components/features/setup-guide/tour-engine.test.ts b/__tests__/components/features/setup-guide/tour-engine.test.tsindex e247610746..a58dd6f1a1 100644--- a/__tests__/components/features/setup-guide/tour-engine.test.ts+++ b/__tests__/components/features/setup-guide/tour-engine.test.ts@@ -16,6 +16,7 @@ const { drivers } = vi.hoisted(() => ({drivers: [] as {destroy: ReturnType<typeof vi.fn>;moveTo: ReturnType<typeof vi.fn>;+ config: Config;}[],}));@@ -29,6 +30,7 @@ vi.mock("driver.js", () => ({moveNext: vi.fn(),movePrevious: vi.fn(),destroy: vi.fn(() => config.onDestroyed?.(undefined, {}, {} as never)),+ config,};drivers.push(instance);return instance;@@ -134,6 +136,37 @@ describe("startGuidedTour", () => {await waitFor(() => expect(drivers[0].moveTo).toHaveBeenCalledWith(1));});+ it("hides the popover footer only on a stop that asks for it", async () => {+ // Arrange+ const renderPopover = () => {+ const popover = {+ nextButton: document.createElement("button"),+ footer: document.createElement("div"),+ };+ drivers[0].config.onPopoverRender?.(popover as never, {} as never);+ return popover;+ };+ await startGuidedTour(+ tour(+ stop({ id: "pick", advanceOnClick: "#card", hideFooter: true }),+ stop({ id: "form", anchor: "#form" }),+ ),+ NAV,+ LABELS,+ );+ await wait(60);++ // Act+ const first = renderPopover();+ document.getElementById("card")!.click();+ await waitFor(() => expect(drivers[0].moveTo).toHaveBeenCalledWith(1));+ const second = renderPopover();++ // Assert+ expect(first.footer.style.display).toBe("none");+ expect(second.footer.style.display).toBe("");+ });+it("keeps the page usable while an interactive stop is shown", async () => {// Actawait startGuidedTour(diff --git a/src/components/features/setup-guide/super-admin-setup-guide.tsx b/src/components/features/setup-guide/super-admin-setup-guide.tsxindex 5b70dcc606..868bfa1ce4 100644--- a/src/components/features/setup-guide/super-admin-setup-guide.tsx+++ b/src/components/features/setup-guide/super-admin-setup-guide.tsx@@ -216,8 +216,30 @@ export default function SuperAdminSetupGuide() {withOrg: boolean,tourStepId?: SuperAdminSetupStepId,) => cloudPageUrl(cloudHost, path, withOrg ? guideOrgId : null, tourStepId);- // A step row and Start open the same page for a step; Start also asks the- // enterprise guide for the step's tour.+ // A plain click on a Canvas step that has a tour runs the tour, which opens+ // the step's page itself; a modified click still follows the link.+ const startStepTour = (+ step: SuperAdminSetupStep,+ event: MouseEvent<HTMLAnchorElement>,+ ) => {+ const plainClick =+ event.button === 0 &&+ !event.metaKey &&+ !event.ctrlKey &&+ !event.shiftKey &&+ !event.altKey;+ if (+ plainClick &&+ step.destination.kind === "canvas" &&+ hasSetupGuideTour(step.id)+ ) {+ event.preventDefault();+ setOpen(false);+ startTour(step.id);+ }+ };+ // A step row and Start open the same page for a step, with the step's tour+ // for a Canvas step. Start also asks the enterprise guide for its tour.const renderStepLink = (step: SuperAdminSetupStep,testId: string,@@ -346,7 +368,9 @@ export default function SuperAdminSetupGuide() {);return (<li key={step.id}>- {renderStepLink(step, testId, rowClassName, label)}+ {renderStepLink(step, testId, rowClassName, label, (event) =>+ startStepTour(step, event),+ )}</li>);})}@@ -364,8 +388,7 @@ export default function SuperAdminSetupGuide() {</p>{/* Like the enterprise Start, close the panel before openingthe step, so Start does something even when the admin is- already on that step's page. A Canvas step's tour opens- the page itself; a modified click still follows the link. */}+ already on that step's page. */}{renderStepLink(nextStep,START_TEST_ID,@@ -373,20 +396,7 @@ export default function SuperAdminSetupGuide() {t(I18nKey.ONBOARDING$SETUP_GUIDE_START),(event) => {setOpen(false);- const plainClick =- event.button === 0 &&- !event.metaKey &&- !event.ctrlKey &&- !event.shiftKey &&- !event.altKey;- if (- plainClick &&- nextStep.destination.kind === "canvas" &&- hasSetupGuideTour(nextStep.id)- ) {- event.preventDefault();- startTour(nextStep.id);- }+ startStepTour(nextStep, event);},true,)}diff --git a/src/components/features/setup-guide/tour/setup-guide-tour.ts b/src/components/features/setup-guide/tour/setup-guide-tour.tsindex a8a0716f6c..b0197fe511 100644--- a/src/components/features/setup-guide/tour/setup-guide-tour.ts+++ b/src/components/features/setup-guide/tour/setup-guide-tour.ts@@ -23,6 +23,8 @@ const SETUP_GUIDE_TOUR_STOPS: Partial<id: "choose-template",anchor: '[data-testid="recommended-automations-section"]',advanceOnClick: '[data-testid^="recommended-automation-card-"]',+ // Next is hidden while it waits for a card, and Back has nowhere to go.+ hideFooter: true,title: I18nKey.ONBOARDING$SETUP_GUIDE_TOUR_TEMPLATE_TITLE,body: I18nKey.ONBOARDING$SETUP_GUIDE_TOUR_TEMPLATE_BODY,side: "top",diff --git a/src/components/features/setup-guide/tour/tour-engine.ts b/src/components/features/setup-guide/tour/tour-engine.tsindex 0a2901da76..fed92bb40b 100644--- a/src/components/features/setup-guide/tour/tour-engine.ts+++ b/src/components/features/setup-guide/tour/tour-engine.ts@@ -291,6 +291,12 @@ export async function startGuidedTour(// Completion and clicks are event-driven on these stops.// eslint-disable-next-line no-param-reassign -- driver.js owns this nodepopover.nextButton.style.display = isWaiting(stops[index]) ? "none" : "";+ // A per-step `showProgress: false` falls back to the tour-wide value in+ // driver.js, so the footer is hidden here instead.+ if (stops[index]?.hideFooter) {+ // eslint-disable-next-line no-param-reassign -- driver.js owns this node+ popover.footer.style.display = "none";+ }},onNextClick: async (_el, _step, { driver: instanceApi }) => {const current = stops[index];diff --git a/src/components/features/setup-guide/tour/tour-types.ts b/src/components/features/setup-guide/tour/tour-types.tsindex b16869896a..bffdc104de 100644--- a/src/components/features/setup-guide/tour/tour-types.ts+++ b/src/components/features/setup-guide/tour/tour-types.ts@@ -28,6 +28,11 @@ export interface GuidedTourStop {* anchor (such as a dropdown's option list) still take clicks.*/interactive?: boolean;+ /**+ * Hide the popover's footer (Back and the step count), such as on a first+ * stop that only waits for the admin's click.+ */+ hideFooter?: boolean;}export interface GuidedTour {