note-to-recipient.cy.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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, openSharingPanel } from './FilesSharingUtils.ts'
  7. import { getRowForFile, navigateToFolder } from '../files/FilesUtils.ts'
  8. describe('files_sharing: Note to recipient', { 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. it('displays the note to the sharee', () => {
  20. cy.mkdir(user, '/folder')
  21. cy.uploadContent(user, new Blob([]), 'text/plain', '/folder/file')
  22. cy.login(user)
  23. cy.visit('/apps/files')
  24. // share the folder
  25. createShare('folder', sharee.userId, { read: true, download: true, note: 'Hello, this is the note.' })
  26. cy.logout()
  27. // Now for the sharee
  28. cy.login(sharee)
  29. // visit shared files view
  30. cy.visit('/apps/files')
  31. navigateToFolder('folder')
  32. cy.get('.note-to-recipient')
  33. .should('be.visible')
  34. .and('contain.text', 'Hello, this is the note.')
  35. })
  36. /**
  37. * Regression test for https://github.com/nextcloud/server/issues/46188
  38. */
  39. it('shows an existing note when editing a share', () => {
  40. cy.mkdir(user, '/folder')
  41. cy.login(user)
  42. cy.visit('/apps/files')
  43. // share the folder
  44. createShare('folder', sharee.userId, { read: true, download: true, note: 'Hello, this is the note.' })
  45. // reload just to be sure
  46. cy.reload()
  47. // open the sharing tab
  48. openSharingPanel('folder')
  49. cy.get('[data-cy-sidebar]').within(() => {
  50. // Open the share
  51. cy.get('[data-cy-files-sharing-share-actions]').first().click()
  52. // Open the custom settings
  53. cy.get('[data-cy-files-sharing-share-permissions-bundle="custom"]').click()
  54. cy.findByRole('checkbox', { name: /note to recipient/i })
  55. .and('be.checked')
  56. cy.findByRole('textbox', { name: /note to recipient/i })
  57. .should('be.visible')
  58. .and('have.value', 'Hello, this is the note.')
  59. })
  60. })
  61. })