files-settings.cy.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
  3. *
  4. * @author Ferdinand Thiessen <opensource@fthiessen.de>
  5. *
  6. * @license AGPL-3.0-or-later
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. import type { User } from '@nextcloud/cypress'
  23. import { getRowForFile } from './FilesUtils'
  24. const showHiddenFiles = () => {
  25. // Open the files settings
  26. cy.get('[data-cy-files-navigation-settings-button] a').click({ force: true })
  27. // Toggle the hidden files setting
  28. cy.get('[data-cy-files-settings-setting="show_hidden"]').within(() => {
  29. cy.get('input').should('not.be.checked')
  30. cy.get('input').check({ force: true })
  31. })
  32. // Close the dialog
  33. cy.get('[data-cy-files-navigation-settings] button[aria-label="Close"]').click()
  34. }
  35. describe('files: Hide or show hidden files', { testIsolation: true }, () => {
  36. let user: User
  37. const setupFiles = () => cy.createRandomUser().then(($user) => {
  38. user = $user
  39. cy.uploadContent(user, new Blob([]), 'text/plain', '/.file')
  40. cy.uploadContent(user, new Blob([]), 'text/plain', '/visible-file')
  41. cy.mkdir(user, '/.folder')
  42. cy.login(user)
  43. })
  44. context('view: All files', { testIsolation: false }, () => {
  45. before(setupFiles)
  46. it('hides dot-files by default', () => {
  47. cy.visit('/apps/files')
  48. getRowForFile('visible-file').should('be.visible')
  49. getRowForFile('.file').should('not.exist')
  50. getRowForFile('.folder').should('not.exist')
  51. })
  52. it('can show hidden files', () => {
  53. showHiddenFiles()
  54. // Now the files should be visible
  55. getRowForFile('.file').should('be.visible')
  56. getRowForFile('.folder').should('be.visible')
  57. })
  58. })
  59. context('view: Personal files', { testIsolation: false }, () => {
  60. before(setupFiles)
  61. it('hides dot-files by default', () => {
  62. cy.visit('/apps/files/personal')
  63. getRowForFile('visible-file').should('be.visible')
  64. getRowForFile('.file').should('not.exist')
  65. getRowForFile('.folder').should('not.exist')
  66. })
  67. it('can show hidden files', () => {
  68. showHiddenFiles()
  69. // Now the files should be visible
  70. getRowForFile('.file').should('be.visible')
  71. getRowForFile('.folder').should('be.visible')
  72. })
  73. })
  74. context('view: Recent files', { testIsolation: false }, () => {
  75. before(() => {
  76. setupFiles().then(() => {
  77. // also add hidden file in hidden folder
  78. cy.uploadContent(user, new Blob([]), 'text/plain', '/.folder/other-file')
  79. cy.login(user)
  80. })
  81. })
  82. it('hides dot-files by default', () => {
  83. cy.visit('/apps/files/recent')
  84. getRowForFile('visible-file').should('be.visible')
  85. getRowForFile('.file').should('not.exist')
  86. getRowForFile('.folder').should('not.exist')
  87. getRowForFile('other-file').should('not.exist')
  88. })
  89. it('can show hidden files', () => {
  90. showHiddenFiles()
  91. getRowForFile('visible-file').should('be.visible')
  92. // Now the files should be visible
  93. getRowForFile('.file').should('be.visible')
  94. getRowForFile('.folder').should('be.visible')
  95. getRowForFile('other-file').should('be.visible')
  96. })
  97. })
  98. })