From 942366956ca6eee039af7d23de29c27370f461ed Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Mon, 1 Dec 2025 19:20:49 +0530 Subject: [PATCH] fix: missing finish label on last card (#6915) --- apps/web/modules/survey/editor/components/block-card.tsx | 5 ++++- apps/web/modules/survey/editor/components/elements-view.tsx | 4 ++-- apps/web/playwright/survey.spec.ts | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/web/modules/survey/editor/components/block-card.tsx b/apps/web/modules/survey/editor/components/block-card.tsx index 35df21fc51..a17f4ac9bf 100644 --- a/apps/web/modules/survey/editor/components/block-card.tsx +++ b/apps/web/modules/survey/editor/components/block-card.tsx @@ -133,13 +133,16 @@ export const BlockCard = ({ // A button label is invalid if it exists but doesn't have valid text for all enabled languages const surveyLanguages = localSurvey.languages ?? []; const hasInvalidButtonLabel = - block.buttonLabel !== undefined && !isLabelValidForAllLanguages(block.buttonLabel, surveyLanguages); + block.buttonLabel !== undefined && + block.buttonLabel["default"]?.trim() !== "" && + !isLabelValidForAllLanguages(block.buttonLabel, surveyLanguages); // Check if back button label is invalid // Back button label should exist for all blocks except the first one const hasInvalidBackButtonLabel = blockIdx > 0 && block.backButtonLabel !== undefined && + block.backButtonLabel["default"]?.trim() !== "" && !isLabelValidForAllLanguages(block.backButtonLabel, surveyLanguages); // Block should be highlighted if it has invalid elements OR invalid button labels diff --git a/apps/web/modules/survey/editor/components/elements-view.tsx b/apps/web/modules/survey/editor/components/elements-view.tsx index 522174f071..5f2ae1e0d7 100644 --- a/apps/web/modules/survey/editor/components/elements-view.tsx +++ b/apps/web/modules/survey/editor/components/elements-view.tsx @@ -513,8 +513,8 @@ export const ElementsView = ({ id: newBlockId, name: getBlockName(index ?? prevSurvey.blocks.length), elements: [{ ...updatedElement, isDraft: true }], - buttonLabel: createI18nString(t("templates.next"), []), - backButtonLabel: createI18nString(t("templates.back"), []), + buttonLabel: createI18nString(t(""), []), + backButtonLabel: createI18nString(t(""), []), }; return { diff --git a/apps/web/playwright/survey.spec.ts b/apps/web/playwright/survey.spec.ts index 5e666dbf97..a0c93c875c 100644 --- a/apps/web/playwright/survey.spec.ts +++ b/apps/web/playwright/survey.spec.ts @@ -232,7 +232,7 @@ test.describe("Survey Create & Submit Response without logic", async () => { for (let i = 0; i < surveys.createAndSubmit.ranking.choices.length; i++) { await page.getByText(surveys.createAndSubmit.ranking.choices[i]).click(); } - await page.locator("#questionCard-12").getByRole("button", { name: "Next" }).click(); + await page.locator("#questionCard-12").getByRole("button", { name: "Finish" }).click(); // loading spinner -> wait for it to disappear await page.getByTestId("loading-spinner").waitFor({ state: "hidden" }); }); @@ -979,7 +979,7 @@ test.describe("Testing Survey with advanced logic", async () => { .fill("This is my city"); await expect(page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.zip)).toBeVisible(); await page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.zip).fill("12345"); - await page.locator("#questionCard-13").getByRole("button", { name: "Next" }).click(); + await page.locator("#questionCard-13").getByRole("button", { name: "Finish" }).click(); // loading spinner -> wait for it to disappear await page.getByTestId("loading-spinner").waitFor({ state: "hidden" });