files-inline-action.cy.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 { closeSidebar, getRowForFile } from '../files/FilesUtils.ts'
  8. describe('files_sharing: Files inline status action', { testIsolation: true }, () => {
  9. /**
  10. * Regression test of https://github.com/nextcloud/server/issues/45723
  11. */
  12. it('No "shared" tag when user ID is purely numerical', () => {
  13. const user = {
  14. language: 'en',
  15. password: 'test1234',
  16. userId: String(Math.floor(Math.random() * 1000)),
  17. } as User
  18. cy.createUser(user)
  19. cy.mkdir(user, '/folder')
  20. cy.login(user)
  21. cy.visit('/apps/files')
  22. getRowForFile('folder')
  23. .should('be.visible')
  24. .find('[data-cy-files-list-row-actions]')
  25. .findByRole('button', { name: 'Shared' })
  26. .should('not.exist')
  27. })
  28. describe('', () => {
  29. let user: User
  30. let sharee: User
  31. beforeEach(() => {
  32. cy.createRandomUser().then(($user) => {
  33. user = $user
  34. })
  35. cy.createRandomUser().then(($user) => {
  36. sharee = $user
  37. })
  38. })
  39. it('Render quick option for sharing', () => {
  40. cy.mkdir(user, '/folder')
  41. cy.login(user)
  42. cy.visit('/apps/files')
  43. getRowForFile('folder')
  44. .should('be.visible')
  45. getRowForFile('folder')
  46. .should('be.visible')
  47. .find('[data-cy-files-list-row-actions]')
  48. .findByRole('button', { name: /Show sharing options/ })
  49. .should('be.visible')
  50. .click()
  51. // check the click opened the sidebar
  52. cy.get('[data-cy-sidebar]')
  53. .should('be.visible')
  54. // and ensure the sharing tab is selected
  55. .findByRole('tab', { name: 'Sharing', selected: true })
  56. .should('exist')
  57. })
  58. it('Render inline status action for sharer', () => {
  59. cy.mkdir(user, '/folder')
  60. cy.login(user)
  61. cy.visit('/apps/files')
  62. getRowForFile('folder')
  63. .should('be.visible')
  64. createShare('folder', sharee.userId)
  65. closeSidebar()
  66. getRowForFile('folder')
  67. .should('be.visible')
  68. .find('[data-cy-files-list-row-actions]')
  69. .findByRole('button', { name: /^Shared with/i })
  70. .should('be.visible')
  71. })
  72. it('Render inline status action for sharee', () => {
  73. cy.mkdir(user, '/folder')
  74. cy.login(user)
  75. cy.visit('/apps/files')
  76. getRowForFile('folder')
  77. .should('be.visible')
  78. createShare('folder', sharee.userId)
  79. closeSidebar()
  80. cy.login(sharee)
  81. cy.visit('/apps/files')
  82. getRowForFile('folder')
  83. .should('be.visible')
  84. .find('[data-cy-files-list-row-actions]')
  85. .findByRole('button', { name: `Shared by ${user.userId}` })
  86. .should('be.visible')
  87. })
  88. })
  89. })