aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/pages/FilesFilters.ts
blob: 036530f1e8a3ad177625a336f9ff2ad35a8149c4 (plain)
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
/*!
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

/**
 * Page object model for the files filters
 */
export class FilesFilterPage {

	filterContainter() {
		return cy.get('[data-cy-files-filters]')
	}

	activeFiltersList() {
		return cy.findByRole('list', { name: 'Active filters' })
	}

	activeFilters() {
		return this.activeFiltersList().findAllByRole('listitem')
	}

	removeFilter(name: string | RegExp) {
		const el = typeof name === 'string'
			? this.activeFilters().should('contain.text', name)
			: this.activeFilters().should('match', name)
		el.should('exist')
		// click the button
		el.findByRole('button', { name: 'Remove filter' })
			.should('exist')
			.click({ force: true })
	}

}