-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathresults-view.spec.ts
More file actions
99 lines (83 loc) · 3.65 KB
/
results-view.spec.ts
File metadata and controls
99 lines (83 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { expect, mergeTests } from '@playwright/test'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
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 { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'
const test = mergeTests(
randomUserTest,
appNavigationTest,
formTest,
topBarTest,
submitTest,
resultsTest,
)
test.describe('Results view', () => {
// Setup: create form, add questions, submit a response, go to results
test.beforeEach(async ({ page, appNavigation, form, topBar, submitView }) => {
await page.goto('apps/forms')
await page.waitForURL(/apps\/forms\/?$/)
await appNavigation.clickNewForm()
await form.fillTitle('Results test form')
// Add a short answer question
await form.addQuestion(QuestionType.ShortAnswer)
const questions1 = await form.getQuestions()
await questions1[0].fillTitle('Your name')
// Add a checkboxes question
await form.addQuestion(QuestionType.Checkboxes)
const questions2 = await form.getQuestions()
await questions2[1].fillTitle('Pick colors')
await questions2[1].addAnswer('Red')
await questions2[1].addAnswer('Green')
await questions2[1].addAnswer('Blue')
// Switch to View mode and submit a response
await topBar.toggleView(FormsView.View)
await submitView.fillText('Your name', 'Alice')
await submitView.checkOption('Pick colors', 'Red')
await submitView.checkOption('Pick colors', 'Blue')
await submitView.submit()
await expect(submitView.successMessage).toBeVisible()
// Navigate to Results view via URL — the SPA route transition
// from submit → results after submission causes a brief redirect loop,
// so we use direct navigation instead of clicking the TopBar.
await page.goto(page.url().replace(/\/submit.*$/, '/results'))
await page.waitForURL(/\/results$/)
})
test('Summary tab shows submitted data', async ({ resultsView }) => {
// Summary is the default active tab
await expect(resultsView.summaryTab).toBeChecked()
// Verify the response count shows 1
await expect(resultsView.responseCount).toBeVisible()
// The summary for each question should be visible
const nameSummary = resultsView.getSummaryForQuestion('Your name')
await expect(nameSummary).toBeVisible()
await expect(nameSummary).toContainText('Alice')
const colorSummary = resultsView.getSummaryForQuestion('Pick colors')
await expect(colorSummary).toBeVisible()
})
test('Responses tab shows individual submission', async ({ resultsView }) => {
await resultsView.switchToResponses()
// Should show the individual submission with the answers
await expect(resultsView.responsesTab).toBeChecked()
await expect(resultsView.responseCount).toBeVisible()
})
test('Tab switching between Summary and Responses', async ({ resultsView }) => {
// Start on Summary
await expect(resultsView.summaryTab).toBeChecked()
// Switch to Responses
await resultsView.switchToResponses()
await expect(resultsView.responsesTab).toBeChecked()
await expect(resultsView.summaryTab).not.toBeChecked()
// Switch back to Summary
await resultsView.switchToSummary()
await expect(resultsView.summaryTab).toBeChecked()
await expect(resultsView.responsesTab).not.toBeChecked()
})
})