files-xml-regression.cy.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 { getRowForFile, triggerActionForFile } from './FilesUtils.ts'
  23. /**
  24. * This is a regression test for https://github.com/nextcloud/server/issues/43331
  25. * Where files with XML entities in their names were wrongly displayed and could no longer be renamed / deleted etc.
  26. */
  27. describe('Files: Can handle XML entities in file names', { testIsolation: false }, () => {
  28. before(() => {
  29. cy.createRandomUser().then((user) => {
  30. cy.uploadContent(user, new Blob(), 'text/plain', '/and.txt')
  31. cy.login(user)
  32. cy.visit('/apps/files/')
  33. })
  34. })
  35. it('Can reanme to a file name containing XML entities', () => {
  36. cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('renameFile')
  37. triggerActionForFile('and.txt', 'rename')
  38. getRowForFile('and.txt')
  39. .find('form[aria-label="Rename file"] input')
  40. .type('{selectAll}&amp;.txt{enter}')
  41. cy.wait('@renameFile')
  42. getRowForFile('&amp;.txt').should('be.visible')
  43. })
  44. it('After a reload the filename is preserved', () => {
  45. cy.reload()
  46. getRowForFile('&amp;.txt').should('be.visible')
  47. getRowForFile('&.txt').should('not.exist')
  48. })
  49. it('Can delete the file', () => {
  50. cy.intercept('DELETE', /\/remote.php\/dav\/files\//).as('deleteFile')
  51. triggerActionForFile('&amp;.txt', 'delete')
  52. cy.wait('@deleteFile')
  53. cy.contains('.toast-success', /Delete .* successfull/)
  54. .should('be.visible')
  55. getRowForFile('&amp;.txt').should('not.exist')
  56. cy.reload()
  57. getRowForFile('&amp;.txt').should('not.exist')
  58. getRowForFile('&.txt').should('not.exist')
  59. })
  60. })