1
0

files-searching.cy.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import type { User } from '@nextcloud/cypress'
  6. import { getRowForFile, navigateToFolder } from './FilesUtils'
  7. import { UnifiedSearchFilter, getUnifiedSearchFilter, getUnifiedSearchInput, getUnifiedSearchModal, openUnifiedSearch } from '../core-utils.ts'
  8. describe('files: Search and filter in files list', { testIsolation: true }, () => {
  9. let user: User
  10. beforeEach(() => cy.createRandomUser().then(($user) => {
  11. user = $user
  12. cy.mkdir(user, '/a folder')
  13. cy.uploadContent(user, new Blob([]), 'text/plain', '/b file')
  14. cy.uploadContent(user, new Blob([]), 'text/plain', '/a folder/c file')
  15. cy.login(user)
  16. cy.visit('/apps/files')
  17. }))
  18. it('filters current view', () => {
  19. // All are visible by default
  20. getRowForFile('a folder').should('be.visible')
  21. getRowForFile('b file').should('be.visible')
  22. // Set up a search query
  23. openUnifiedSearch()
  24. getUnifiedSearchInput().type('a folder')
  25. getUnifiedSearchFilter(UnifiedSearchFilter.FilterCurrentView).click({ force: true })
  26. // Wait for modal to close
  27. getUnifiedSearchModal().should('not.be.visible')
  28. // See that only the folder is visible
  29. getRowForFile('a folder').should('be.visible')
  30. getRowForFile('b file').should('not.exist')
  31. })
  32. it('resets filter when changeing the directory', () => {
  33. // All are visible by default
  34. getRowForFile('a folder').should('be.visible')
  35. getRowForFile('b file').should('be.visible')
  36. // Set up a search query
  37. openUnifiedSearch()
  38. getUnifiedSearchInput().type('a folder')
  39. getUnifiedSearchFilter(UnifiedSearchFilter.FilterCurrentView).click({ force: true })
  40. // Wait for modal to close
  41. getUnifiedSearchModal().should('not.be.visible')
  42. // See that only the folder is visible
  43. getRowForFile('a folder').should('be.visible')
  44. getRowForFile('b file').should('not.exist')
  45. // go to that folder
  46. navigateToFolder('a folder')
  47. // see that the folder is not filtered
  48. getRowForFile('c file').should('be.visible')
  49. })
  50. it('resets filter when changeing the view', () => {
  51. // All are visible by default
  52. getRowForFile('a folder').should('be.visible')
  53. getRowForFile('b file').should('be.visible')
  54. // Set up a search query
  55. openUnifiedSearch()
  56. getUnifiedSearchInput().type('a folder')
  57. getUnifiedSearchFilter(UnifiedSearchFilter.FilterCurrentView).click({ force: true })
  58. // Wait for modal to close
  59. getUnifiedSearchModal().should('not.be.visible')
  60. // See that only the folder is visible
  61. getRowForFile('a folder').should('be.visible')
  62. getRowForFile('b file').should('not.exist')
  63. // go to other view
  64. cy.get('[data-cy-files-navigation-item="personal"] a').click({ force: true })
  65. // wait for view changed
  66. cy.url().should('match', /apps\/files\/personal/)
  67. // see that the folder is not filtered
  68. getRowForFile('a folder').should('be.visible')
  69. getRowForFile('b file').should('be.visible')
  70. })
  71. })