-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathResultsSection.ts
More file actions
47 lines (41 loc) · 1.54 KB
/
ResultsSection.ts
File metadata and controls
47 lines (41 loc) · 1.54 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
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { Locator, Page } from '@playwright/test'
export class ResultsSection {
public readonly summaryTab: Locator
public readonly responsesTab: Locator
public readonly noResponsesMessage: Locator
public readonly responseCount: Locator
constructor(public readonly page: Page) {
const main = this.page.getByRole('main')
this.summaryTab = main.getByRole('radio', { name: 'Summary' })
// "Responses" exists in both the TopBar (value="results") and the Results PillMenu
// (value="responses"). Use .and() with the value attribute to disambiguate.
this.responsesTab = main
.getByRole('radio', { name: 'Responses' })
.and(this.page.locator('[value="responses"]'))
this.noResponsesMessage = this.page.getByText('No responses yet')
this.responseCount = this.page.getByText(/\d+ responses?/)
}
public async switchToSummary(): Promise<void> {
// NcCheckboxRadioSwitch renders a hidden <input type="radio"> with
// v-on="{ change: onToggle }". Dispatch the change event directly.
await this.summaryTab.dispatchEvent('change')
}
public async switchToResponses(): Promise<void> {
await this.responsesTab.dispatchEvent('change')
}
/**
* Get the summary section for a specific question by its title.
*
* @param name the title of the question
*/
public getSummaryForQuestion(name: string | RegExp): Locator {
return this.page
.getByRole('main')
.getByRole('heading', { name })
.locator('..')
}
}