1
0

core-utils.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. /**
  6. * Get the unified search modal (if open)
  7. */
  8. export function getUnifiedSearchModal() {
  9. return cy.get('#unified-search')
  10. }
  11. /**
  12. * Open the unified search modal
  13. */
  14. export function openUnifiedSearch() {
  15. cy.get('button[aria-label="Unified search"]').click({ force: true })
  16. // wait for it to be open
  17. getUnifiedSearchModal().should('be.visible')
  18. }
  19. /**
  20. * Close the unified search modal
  21. */
  22. export function closeUnifiedSearch() {
  23. getUnifiedSearchModal().find('button[aria-label="Close"]').click({ force: true })
  24. getUnifiedSearchModal().should('not.be.visible')
  25. }
  26. /**
  27. * Get the input field of the unified search
  28. */
  29. export function getUnifiedSearchInput() {
  30. return getUnifiedSearchModal().find('[data-cy-unified-search-input]')
  31. }
  32. export enum UnifiedSearchFilter {
  33. FilterCurrentView = 'current-view',
  34. Places = 'places',
  35. People = 'people',
  36. Date = 'date',
  37. }
  38. /**
  39. * Get a filter action from the unified search
  40. * @param filter The filter to get
  41. */
  42. export function getUnifiedSearchFilter(filter: UnifiedSearchFilter) {
  43. return getUnifiedSearchModal().find(`[data-cy-unified-search-filters] [data-cy-unified-search-filter="${CSS.escape(filter)}"]`)
  44. }