files-settings.cy.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: Recent files', { testIsolation: false }, () => {
  60. before(() => {
  61. setupFiles().then(() => {
  62. // also add hidden file in hidden folder
  63. cy.uploadContent(user, new Blob([]), 'text/plain', '/.folder/other-file')
  64. cy.login(user)
  65. })
  66. })
  67. it('hides dot-files by default', () => {
  68. cy.visit('/apps/files/recent')
  69. getRowForFile('visible-file').should('be.visible')
  70. getRowForFile('.file').should('not.exist')
  71. getRowForFile('.folder').should('not.exist')
  72. getRowForFile('other-file').should('not.exist')
  73. })
  74. it('can show hidden files', () => {
  75. showHiddenFiles()
  76. getRowForFile('visible-file').should('be.visible')
  77. // Now the files should be visible
  78. getRowForFile('.file').should('be.visible')
  79. getRowForFile('.folder').should('be.visible')
  80. getRowForFile('other-file').should('be.visible')
  81. })
  82. })
  83. })