Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions playwright/e2e/results-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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()
})
4 changes: 3 additions & 1 deletion src/components/Results/ResultsSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading