diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-27 00:00:53 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-27 12:13:14 +0200 |
commit | 362c6238fcadb74c54c2a8c7b2c12c5a1011c0b5 (patch) | |
tree | 788796ae091291c2753905616f6a6db3aaa02464 /cypress/pages | |
parent | dd3dcf37039ed969b1a2f6b89941a65ccf73b696 (diff) | |
download | nextcloud-server-362c6238fcadb74c54c2a8c7b2c12c5a1011c0b5.tar.gz nextcloud-server-362c6238fcadb74c54c2a8c7b2c12c5a1011c0b5.zip |
fix: Allow to reset unified search using the `nextcloud:unified-search:reset` event
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'cypress/pages')
-rw-r--r-- | cypress/pages/UnifiedSearch.ts | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/cypress/pages/UnifiedSearch.ts b/cypress/pages/UnifiedSearch.ts new file mode 100644 index 00000000000..f6e0dd2e7a7 --- /dev/null +++ b/cypress/pages/UnifiedSearch.ts @@ -0,0 +1,75 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** + * Page object model for the UnifiedSearch + */ +export class UnifiedSearchPage { + + toggleButton() { + return cy.findByRole('button', { name: 'Unified search' }) + } + + globalSearchButton() { + return cy.findByRole('button', { name: 'Search everywhere' }) + } + + localSearchInput() { + return cy.findByRole('textbox', { name: 'Search in current app' }) + } + + globalSearchInput() { + return cy.findByRole('textbox', { name: /Search apps, files/ }) + } + + globalSearchModal() { + // TODO: Broken in library + // return cy.findByRole('dialog', { name: 'Unified search' }) + return cy.get('#unified-search') + } + + // functions + + openLocalSearch() { + this.toggleButton() + .if('visible') + .click() + + this.localSearchInput().should('exist').and('not.have.css', 'display', 'none') + } + + /** + * Type in the local search (must be open before) + * Helper because the input field is overlayed by the global-search button -> cypress thinks the input is not visible + * + * @param text The text to type + * @param options Options as for `cy.type()` + */ + typeLocalSearch(text: string, options?: Partial<Omit<Cypress.TypeOptions, 'force'>>) { + return this.localSearchInput() + .type(text, { ...options, force: true }) + } + + openGlobalSearch() { + this.toggleButton() + .if('visible').click() + + this.globalSearchButton() + .if('visible').click() + } + + closeGlobalSearch() { + this.globalSearchModal() + .findByRole('button', { name: 'Close' }) + .click() + } + + getResults(category: string | RegExp) { + return this.globalSearchModal() + .findByRole('list', { name: category }) + .findAllByRole('listitem') + } + +} |