files-shares-view.cy.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 { createShare } from './filesSharingUtils.ts'
  7. import { getRowForFile } from '../files/FilesUtils.ts'
  8. describe('files_sharing: Files view', { testIsolation: true }, () => {
  9. let user: User
  10. let sharee: User
  11. beforeEach(() => {
  12. cy.createRandomUser().then(($user) => {
  13. user = $user
  14. })
  15. cy.createRandomUser().then(($user) => {
  16. sharee = $user
  17. })
  18. })
  19. /**
  20. * Regression test of https://github.com/nextcloud/server/issues/46108
  21. */
  22. it('opens a shared folder when clicking on it', () => {
  23. cy.mkdir(user, '/folder')
  24. cy.uploadContent(user, new Blob([]), 'text/plain', '/folder/file')
  25. cy.login(user)
  26. cy.visit('/apps/files')
  27. // share the folder
  28. createShare('folder', sharee.userId, { read: true, download: true })
  29. // visit the own shares
  30. cy.visit('/apps/files/sharingout')
  31. // see the shared folder
  32. getRowForFile('folder').should('be.visible')
  33. // click on the folder should open it in files
  34. getRowForFile('folder').findByRole('button', { name: /open in files/i }).click()
  35. // See the URL has changed
  36. cy.url().should('match', /apps\/files\/files\/.+dir=\/folder/)
  37. // Content of the shared folder
  38. getRowForFile('file').should('be.visible')
  39. cy.logout()
  40. // Now for the sharee
  41. cy.login(sharee)
  42. // visit shared files view
  43. cy.visit('/apps/files/sharingin')
  44. // see the shared folder
  45. getRowForFile('folder').should('be.visible')
  46. // click on the folder should open it in files
  47. getRowForFile('folder').findByRole('button', { name: /open in files/i }).click()
  48. // See the URL has changed
  49. cy.url().should('match', /apps\/files\/files\/.+dir=\/folder/)
  50. // Content of the shared folder
  51. getRowForFile('file').should('be.visible')
  52. })
  53. })