diff options
Diffstat (limited to 'cypress/pages')
-rw-r--r-- | cypress/pages/FilesFilters.ts | 34 | ||||
-rw-r--r-- | cypress/pages/FilesNavigation.ts | 46 | ||||
-rw-r--r-- | cypress/pages/NavigationHeader.ts | 58 | ||||
-rw-r--r-- | cypress/pages/UnifiedSearch.ts | 75 |
4 files changed, 213 insertions, 0 deletions
diff --git a/cypress/pages/FilesFilters.ts b/cypress/pages/FilesFilters.ts new file mode 100644 index 00000000000..036530f1e8a --- /dev/null +++ b/cypress/pages/FilesFilters.ts @@ -0,0 +1,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 }) + } + +} diff --git a/cypress/pages/FilesNavigation.ts b/cypress/pages/FilesNavigation.ts new file mode 100644 index 00000000000..1be11231bad --- /dev/null +++ b/cypress/pages/FilesNavigation.ts @@ -0,0 +1,46 @@ +/*! + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** + * Page object model for the files app navigation + */ +export class FilesNavigationPage { + + navigation() { + return cy.findByRole('navigation', { name: 'Files' }) + } + + searchInput() { + return this.navigation().findByRole('searchbox') + } + + searchScopeTrigger() { + return this.navigation().findByRole('button', { name: /search scope options/i }) + } + + /** + * Only available after clicking on the search scope trigger + */ + searchScopeMenu() { + return cy.findByRole('menu', { name: /search scope options/i }) + } + + searchClearButton() { + return this.navigation().findByRole('button', { name: /clear search/i }) + } + + settingsToggle() { + return this.navigation().findByRole('link', { name: 'Files settings' }) + } + + views() { + return this.navigation().findByRole('list', { name: 'Views' }) + } + + quota() { + return this.navigation().find('[data-cy-files-navigation-settings-quota]') + } + +} diff --git a/cypress/pages/NavigationHeader.ts b/cypress/pages/NavigationHeader.ts new file mode 100644 index 00000000000..5441b75de88 --- /dev/null +++ b/cypress/pages/NavigationHeader.ts @@ -0,0 +1,58 @@ +/*! + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** + * Page object model for the Nextcloud navigation header + */ +export class NavigationHeader { + + /** + * Locator of the header bar wrapper + */ + header() { + return cy.get('header#header') + } + + /** + * Locator for the logo navigation entry (entry redirects to default app) + */ + logo() { + return this.header() + .find('#nextcloud') + } + + /** + * Locator of the app navigation bar + */ + navigation() { + return this.header() + .findByRole('navigation', { name: 'Applications menu' }) + } + + /** + * The toggle for the navigation overflow menu + */ + overflowNavigationToggle() { + return this.navigation() + } + + /** + * Get all navigation entries + */ + getNavigationEntries() { + return this.navigation() + .findAllByRole('listitem') + } + + /** + * Get the navigation entry for a given app + * @param name The app name + */ + getNavigationEntry(name: string) { + return this.navigation() + .findByRole('listitem', { name }) + } + +} 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') + } + +} |