files-settings.cy.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 } from './FilesUtils'
  7. const showHiddenFiles = () => {
  8. // Open the files settings
  9. cy.get('[data-cy-files-navigation-settings-button] a').click({ force: true })
  10. // Toggle the hidden files setting
  11. cy.get('[data-cy-files-settings-setting="show_hidden"]').within(() => {
  12. cy.get('input').should('not.be.checked')
  13. cy.get('input').check({ force: true })
  14. })
  15. // Close the dialog
  16. cy.get('[data-cy-files-navigation-settings] button[aria-label="Close"]').click()
  17. }
  18. describe('files: Hide or show hidden files', { testIsolation: true }, () => {
  19. let user: User
  20. const setupFiles = () => cy.createRandomUser().then(($user) => {
  21. user = $user
  22. cy.uploadContent(user, new Blob([]), 'text/plain', '/.file')
  23. cy.uploadContent(user, new Blob([]), 'text/plain', '/visible-file')
  24. cy.mkdir(user, '/.folder')
  25. cy.login(user)
  26. })
  27. context('view: All files', { testIsolation: false }, () => {
  28. before(setupFiles)
  29. it('hides dot-files by default', () => {
  30. cy.visit('/apps/files')
  31. getRowForFile('visible-file').should('be.visible')
  32. getRowForFile('.file').should('not.exist')
  33. getRowForFile('.folder').should('not.exist')
  34. })
  35. it('can show hidden files', () => {
  36. showHiddenFiles()
  37. // Now the files should be visible
  38. getRowForFile('.file').should('be.visible')
  39. getRowForFile('.folder').should('be.visible')
  40. })
  41. })
  42. context('view: Personal files', { testIsolation: false }, () => {
  43. before(setupFiles)
  44. it('hides dot-files by default', () => {
  45. cy.visit('/apps/files/personal')
  46. getRowForFile('visible-file').should('be.visible')
  47. getRowForFile('.file').should('not.exist')
  48. getRowForFile('.folder').should('not.exist')
  49. })
  50. it('can show hidden files', () => {
  51. showHiddenFiles()
  52. // Now the files should be visible
  53. getRowForFile('.file').should('be.visible')
  54. getRowForFile('.folder').should('be.visible')
  55. })
  56. })
  57. context('view: Recent files', { testIsolation: false }, () => {
  58. before(() => {
  59. setupFiles().then(() => {
  60. // also add hidden file in hidden folder
  61. cy.uploadContent(user, new Blob([]), 'text/plain', '/.folder/other-file')
  62. cy.login(user)
  63. })
  64. })
  65. it('hides dot-files by default', () => {
  66. cy.visit('/apps/files/recent')
  67. getRowForFile('visible-file').should('be.visible')
  68. getRowForFile('.file').should('not.exist')
  69. getRowForFile('.folder').should('not.exist')
  70. getRowForFile('other-file').should('not.exist')
  71. })
  72. it('can show hidden files', () => {
  73. showHiddenFiles()
  74. getRowForFile('visible-file').should('be.visible')
  75. // Now the files should be visible
  76. getRowForFile('.file').should('be.visible')
  77. getRowForFile('.folder').should('be.visible')
  78. getRowForFile('other-file').should('be.visible')
  79. })
  80. })
  81. })