files-sidebar.cy.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, triggerActionForFile } from './FilesUtils'
  7. describe('Files: Sidebar', { testIsolation: true }, () => {
  8. let user: User
  9. let fileId: number = 0
  10. beforeEach(() => cy.createRandomUser().then(($user) => {
  11. user = $user
  12. cy.mkdir(user, '/folder')
  13. cy.uploadContent(user, new Blob([]), 'text/plain', '/file').then((response) => {
  14. fileId = Number.parseInt(response.headers['oc-fileid'] ?? '0')
  15. })
  16. cy.login(user)
  17. }))
  18. it('opens the sidebar', () => {
  19. cy.visit('/apps/files')
  20. getRowForFile('file').should('be.visible')
  21. triggerActionForFile('file', 'details')
  22. cy.get('[data-cy-sidebar]').should('be.visible')
  23. })
  24. it('changes the current fileid', () => {
  25. cy.visit('/apps/files')
  26. getRowForFile('file').should('be.visible')
  27. triggerActionForFile('file', 'details')
  28. cy.get('[data-cy-sidebar]').should('be.visible')
  29. cy.url().should('contain', `apps/files/files/${fileId}`)
  30. })
  31. it('closes the sidebar on delete', () => {
  32. cy.visit('/apps/files')
  33. getRowForFile('file').should('be.visible')
  34. // open the sidebar
  35. triggerActionForFile('file', 'details')
  36. // validate it is open
  37. cy.get('[data-cy-sidebar]').should('be.visible')
  38. triggerActionForFile('file', 'delete')
  39. cy.get('[data-cy-sidebar]').should('not.exist')
  40. })
  41. it('changes the fileid on delete', () => {
  42. cy.uploadContent(user, new Blob([]), 'text/plain', '/folder/other').then((response) => {
  43. const otherFileId = Number.parseInt(response.headers['oc-fileid'] ?? '0')
  44. cy.login(user)
  45. cy.visit('/apps/files')
  46. getRowForFile('folder').should('be.visible')
  47. navigateToFolder('folder')
  48. getRowForFile('other').should('be.visible')
  49. // open the sidebar
  50. triggerActionForFile('other', 'details')
  51. // validate it is open
  52. cy.get('[data-cy-sidebar]').should('be.visible')
  53. cy.url().should('contain', `apps/files/files/${otherFileId}`)
  54. triggerActionForFile('other', 'delete')
  55. cy.get('[data-cy-sidebar]').should('not.exist')
  56. // Ensure the URL is changed
  57. cy.url().should('not.contain', `apps/files/files/${otherFileId}`)
  58. })
  59. })
  60. })