Skip to content

Commit 58f74ea

Browse files
committed
feat(e2e): add results view tests
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent ab027f5 commit 58f74ea

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { expect, mergeTests } from '@playwright/test'
7+
import { test as randomUserTest } from '../support/fixtures/random-user'
8+
import { test as appNavigationTest } from '../support/fixtures/navigation'
9+
import { test as formTest } from '../support/fixtures/form'
10+
import { test as topBarTest } from '../support/fixtures/topBar'
11+
import { test as submitTest } from '../support/fixtures/submit'
12+
import { test as resultsTest } from '../support/fixtures/results'
13+
import { QuestionType } from '../support/sections/QuestionType'
14+
import { FormsView } from '../support/sections/TopBarSection'
15+
16+
const test = mergeTests(
17+
randomUserTest,
18+
appNavigationTest,
19+
formTest,
20+
topBarTest,
21+
submitTest,
22+
resultsTest,
23+
)
24+
25+
test.describe('Results view', () => {
26+
// Setup: create form, add questions, submit a response, go to results
27+
test.beforeEach(async ({ page, appNavigation, form, topBar, submitView }) => {
28+
await page.goto('apps/forms')
29+
await page.waitForURL(/apps\/forms$/)
30+
await appNavigation.clickNewForm()
31+
await form.fillTitle('Results test form')
32+
33+
// Add a short answer question
34+
await form.addQuestion(QuestionType.ShortAnswer)
35+
const questions1 = await form.getQuestions()
36+
await questions1[0].fillTitle('Your name')
37+
38+
// Add a checkboxes question
39+
await form.addQuestion(QuestionType.Checkboxes)
40+
const questions2 = await form.getQuestions()
41+
await questions2[1].fillTitle('Pick colors')
42+
await questions2[1].addAnswer('Red')
43+
await questions2[1].addAnswer('Green')
44+
await questions2[1].addAnswer('Blue')
45+
46+
// Switch to View mode and submit a response
47+
await topBar.toggleView(FormsView.View)
48+
await submitView.fillText('Your name', 'Alice')
49+
await submitView.checkOption('Pick colors', 'Red')
50+
await submitView.checkOption('Pick colors', 'Blue')
51+
await submitView.submit()
52+
await expect(submitView.successMessage).toBeVisible()
53+
54+
// Navigate to Results view
55+
await topBar.toggleView(FormsView.Results)
56+
})
57+
58+
test('Summary tab shows submitted data', async ({ resultsView }) => {
59+
// Summary is the default active tab
60+
await expect(resultsView.summaryTab).toBeChecked()
61+
62+
// Verify the response count shows 1
63+
await expect(resultsView.responseCount).toBeVisible()
64+
65+
// The summary for each question should be visible
66+
const nameSummary = resultsView.getSummaryForQuestion('Your name')
67+
await expect(nameSummary).toBeVisible()
68+
await expect(nameSummary).toContainText('Alice')
69+
70+
const colorSummary = resultsView.getSummaryForQuestion('Pick colors')
71+
await expect(colorSummary).toBeVisible()
72+
})
73+
74+
test('Responses tab shows individual submission', async ({
75+
resultsView,
76+
}) => {
77+
await resultsView.switchToResponses()
78+
79+
// Should show the individual submission with the answers
80+
await expect(resultsView.responsesTab).toBeChecked()
81+
await expect(resultsView.responseCount).toBeVisible()
82+
})
83+
84+
test('Tab switching between Summary and Responses', async ({
85+
resultsView,
86+
}) => {
87+
// Start on Summary
88+
await expect(resultsView.summaryTab).toBeChecked()
89+
90+
// Switch to Responses
91+
await resultsView.switchToResponses()
92+
await expect(resultsView.responsesTab).toBeChecked()
93+
await expect(resultsView.summaryTab).not.toBeChecked()
94+
95+
// Switch back to Summary
96+
await resultsView.switchToSummary()
97+
await expect(resultsView.summaryTab).toBeChecked()
98+
await expect(resultsView.responsesTab).not.toBeChecked()
99+
})
100+
})

0 commit comments

Comments
 (0)