From 9be0dc840bc8044ad6110c990fdf72183cc7f34d Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 23 Nov 2026 00:12:34 +0100 Subject: [PATCH] fix(results): show no empty parentheses for a scale without labels With both labels of a linear scale cleared, the results summary named the question "Linear scale ()", as the type label wrapped the labels in parentheses even when there were none. It now shows just "Linear scale" in that case. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/results-view.spec.ts | 27 +++++++++++++++++++++++ src/components/Results/ResultsSummary.vue | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/playwright/e2e/results-view.spec.ts b/playwright/e2e/results-view.spec.ts index 7b8687d36..fc6b41ae4 100644 --- a/playwright/e2e/results-view.spec.ts +++ b/playwright/e2e/results-view.spec.ts @@ -10,6 +10,7 @@ import { test as randomUserTest } from '../support/fixtures/random-user.ts' import { test as resultsTest } from '../support/fixtures/results.ts' import { test as submitTest } from '../support/fixtures/submit.ts' import { test as topBarTest } from '../support/fixtures/topBar.ts' +import { api } from '../support/helpers.ts' import { QuestionType } from '../support/sections/QuestionType.ts' import { FormsView } from '../support/sections/TopBarSection.ts' @@ -113,3 +114,29 @@ test.describe('Results view', () => { }) }) +test('A linear scale without labels is named without parentheses', async ({ + page, + resultsView, +}) => { + const form = await api(page.request, 'POST', '/forms') + const scale = await api(page.request, 'POST', `/forms/${form.id}/questions`, { + type: 'linearscale', + text: 'Rate the event', + }) + await api(page.request, 'PATCH', `/forms/${form.id}/questions/${scale.id}`, { + keyValuePairs: { + extraSettings: { optionsLabelLowest: '', optionsLabelHighest: '' }, + }, + }) + await api(page.request, 'POST', `/forms/${form.id}/submissions`, { + answers: { [scale.id]: ['3'] }, + }) + await page.goto(`apps/forms/${form.hash}/results`) + await page.waitForURL(/\/results\/summary$/) + + await expect( + resultsView + .getSummaryForQuestion('Rate the event') + .getByText('Linear scale', { exact: true }), + ).toBeVisible() +}) diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue index f7de8cf9a..518b474ad 100644 --- a/src/components/Results/ResultsSummary.vue +++ b/src/components/Results/ResultsSummary.vue @@ -272,7 +272,9 @@ export default defineComponent({ descriptionParts.push(`${optionsHighest}: ${labelHighest}`) } - return `${label} (${descriptionParts.join(', ')})` + return descriptionParts.length > 0 + ? `${label} (${descriptionParts.join(', ')})` + : label } return label