From 9b1f86a671c59032c1c9f37c1f3eb6141ff33b7f Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Tue, 27 Jan 2026 13:09:11 +0100 Subject: [PATCH] fix: lowercase identifier values in routing form editor (#26616) * fix: lowercase identifier values in routing form editor Co-Authored-By: peer@cal.com * fix: remove unused @ts-expect-error directives Co-Authored-By: peer@cal.com --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../routing-forms/[...pages]/FormEdit.tsx | 27 +++++++---------- .../playwright/tests/basic.e2e.ts | 30 +++++++++---------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/FormEdit.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/FormEdit.tsx index 2fbc28afc6..8c2146a84b 100644 --- a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/FormEdit.tsx +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/FormEdit.tsx @@ -1,11 +1,5 @@ "use client"; -import { useAutoAnimate } from "@formkit/auto-animate/react"; -import type { UseFormReturn } from "react-hook-form"; -import { Controller, useFieldArray, useWatch } from "react-hook-form"; -import { Toaster } from "sonner"; -import { v4 as uuidv4 } from "uuid"; - import { FieldTypes } from "@calcom/app-store/routing-forms/lib/FieldTypes"; import type { RoutingFormWithResponseCount } from "@calcom/app-store/routing-forms/types/types"; import { getFieldIdentifier } from "@calcom/features/form-builder/utils/getFieldIdentifier"; @@ -16,17 +10,20 @@ import { FormCard, FormCardBody } from "@calcom/ui/components/card"; import { BooleanToggleGroupField, Label, + MultiOptionInput, SelectField, TextField, - MultiOptionInput, } from "@calcom/ui/components/form"; import { Icon } from "@calcom/ui/components/icon"; import { Tooltip } from "@calcom/ui/components/tooltip"; import type { getServerSidePropsForSingleFormView as getServerSideProps } from "@calcom/web/lib/apps/routing-forms/[...pages]/getServerSidePropsSingleForm"; - -import type { inferSSRProps } from "@lib/types/inferSSRProps"; - import SingleForm from "@components/apps/routing-forms/SingleForm"; +import { useAutoAnimate } from "@formkit/auto-animate/react"; +import type { inferSSRProps } from "@lib/types/inferSSRProps"; +import type { UseFormReturn } from "react-hook-form"; +import { Controller, useFieldArray, useWatch } from "react-hook-form"; +import { Toaster } from "sonner"; +import { v4 as uuidv4 } from "uuid"; type HookForm = UseFormReturn; @@ -123,14 +120,14 @@ function Field({ // Only auto-update identifier if it was auto-generated from the previous label // This preserves manual identifier changes const isIdentifierGeneratedFromPreviousLabel = - currentIdentifier === getFieldIdentifier(previousLabel); + currentIdentifier === getFieldIdentifier(previousLabel).toLowerCase(); if ( !currentIdentifier || isIdentifierGeneratedFromPreviousLabel ) { hookForm.setValue( `${hookFieldNamespace}.identifier`, - getFieldIdentifier(newLabel), + getFieldIdentifier(newLabel).toLowerCase(), { shouldDirty: true } ); } @@ -155,7 +152,7 @@ function Field({ onChange={(e) => { hookForm.setValue( `${hookFieldNamespace}.identifier`, - e.target.value, + e.target.value.toLowerCase(), { shouldDirty: true } ); }} @@ -282,8 +279,6 @@ const FormEdit = ({ append: appendHookFormField, remove: removeHookFormField, swap: swapHookFormField, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-ignore https://github.com/react-hook-form/react-hook-form/issues/6679 } = useFieldArray({ control: hookForm.control, name: fieldsNamespace, @@ -294,8 +289,6 @@ const FormEdit = ({ const addField = () => { appendHookFormField({ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-ignore id: uuidv4(), // This is same type from react-awesome-query-builder type: "text", diff --git a/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts b/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts index a145190977..fbd6caee27 100644 --- a/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts +++ b/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts @@ -271,21 +271,21 @@ test.describe("Routing Forms", () => { label: "Test Field", }); const queryString = - "firstField=456&Test-Field-Number=456&Test-Field-Single-choice-selection=456&Test-Field-Multiple-choice-selection=456&Test-Field-Multiple-choice-selection=789&Test-Field-Phone=456&Test-Field-Email=456@example.com"; + "firstfield=456&test-field-number=456&test-field-single-choice-selection=456&test-field-multiple-choice-selection=456&test-field-multiple-choice-selection=789&test-field-phone=456&test-field-email=456@example.com"; await gotoRoutingLink({ page, queryString }); - await page.fill('[data-testid="form-field-Test-Field-Long-text"]', "manual-fill"); + await page.fill('[data-testid="form-field-test-field-long-text"]', "manual-fill"); - await expect(page.locator('[data-testid="form-field-firstField"]')).toHaveValue("456"); - await expect(page.locator('[data-testid="form-field-Test-Field-Number"]')).toHaveValue("456"); + await expect(page.locator('[data-testid="form-field-firstfield"]')).toHaveValue("456"); + await expect(page.locator('[data-testid="form-field-test-field-number"]')).toHaveValue("456"); // TODO: Verify select and multiselect has prefilled values. - // expect(await page.locator(`[data-testid="form-field-Test-Field-Select"]`).inputValue()).toBe("456"); - // expect(await page.locator(`[data-testid="form-field-Test-Field-MultiSelect"]`).inputValue()).toBe("456"); + // expect(await page.locator(`[data-testid="form-field-test-field-select"]`).inputValue()).toBe("456"); + // expect(await page.locator(`[data-testid="form-field-test-field-multiselect"]`).inputValue()).toBe("456"); - await expect(page.locator('[data-testid="form-field-Test-Field-Phone"]')).toHaveValue("456"); - await expect(page.locator('[data-testid="form-field-Test-Field-Email"]')).toHaveValue( + await expect(page.locator('[data-testid="form-field-test-field-phone"]')).toHaveValue("456"); + await expect(page.locator('[data-testid="form-field-test-field-email"]')).toHaveValue( "456@example.com" ); @@ -297,15 +297,15 @@ test.describe("Routing Forms", () => { const url = new URL(page.url()); // Coming from the response filled by booker - expect(url.searchParams.get("firstField")).toBe("456"); + expect(url.searchParams.get("firstfield")).toBe("456"); // All other params come from prefill URL - expect(url.searchParams.get("Test-Field-Number")).toBe("456"); - expect(url.searchParams.get("Test-Field-Long-text")).toBe("manual-fill"); - expect(url.searchParams.get("Test-Field-Multiple-choice-selection")).toBe("456"); - expect(url.searchParams.getAll("Test-Field-Multiple-choice-selection")).toMatchObject(["456", "789"]); - expect(url.searchParams.get("Test-Field-Phone")).toBe("456"); - expect(url.searchParams.get("Test-Field-Email")).toBe("456@example.com"); + expect(url.searchParams.get("test-field-number")).toBe("456"); + expect(url.searchParams.get("test-field-long-text")).toBe("manual-fill"); + expect(url.searchParams.get("test-field-multiple-choice-selection")).toBe("456"); + expect(url.searchParams.getAll("test-field-multiple-choice-selection")).toMatchObject(["456", "789"]); + expect(url.searchParams.get("test-field-phone")).toBe("456"); + expect(url.searchParams.get("test-field-email")).toBe("456@example.com"); }); // TODO: How to install the app just once?