diff --git a/playwright/e2e/sections.spec.ts b/playwright/e2e/sections.spec.ts index 833c27201..7dc7974b6 100644 --- a/playwright/e2e/sections.spec.ts +++ b/playwright/e2e/sections.spec.ts @@ -790,6 +790,48 @@ test.describe('Sections', () => { ).toHaveValue('Part one') }) + test('The results summary shows sections as headings between the questions', async ({ + page, + }) => { + const form = await api(page.request, 'POST', '/forms') + const ids: number[] = [] + for (const [type, text] of [ + ['short', 'Intro'], + ['section', 'Part one'], + ['short', 'First'], + ['section', ''], + ['short', 'Second'], + ]) { + ids.push( + ( + await api(page.request, 'POST', `/forms/${form.id}/questions`, { + type, + text, + }) + ).id, + ) + } + await api(page.request, 'PATCH', `/forms/${form.id}/questions/${ids[1]}`, { + keyValuePairs: { description: 'Questions about the first part' }, + }) + await api(page.request, 'POST', `/forms/${form.id}/submissions`, { + answers: { [ids[0]]: ['hello'], [ids[2]]: ['world'] }, + }) + await page.goto(`apps/forms/${form.hash}/results`) + + const main = page.getByRole('main') + await expect(main.getByRole('heading', { level: 3 })).toHaveText([ + 'Intro', + 'Part one', + 'Second', + ]) + await expect(main.getByRole('heading', { level: 4 })).toHaveText(['First']) + const section = page.locator('.results-section') + await expect(section).toHaveCount(1) + await expect(section).toContainText('Questions about the first part') + await expect(section).not.toContainText('Section') + }) + test('Each page checks its required questions, an empty section is an info page', async ({ page, submitView, diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue index e9a76e98e..872dba402 100644 --- a/src/components/Results/ResultsSummary.vue +++ b/src/components/Results/ResultsSummary.vue @@ -5,9 +5,9 @@