1
0

access-levels.cy.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @copyright Copyright (c) 2023 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 { User } from '@nextcloud/cypress'
  23. import { clearState, getNextcloudUserMenu, getNextcloudUserMenuToggle } from '../../support/commonUtils'
  24. const admin = new User('admin', 'admin')
  25. describe('Settings: Ensure only administrator can see the administration settings section', { testIsolation: true }, () => {
  26. beforeEach(() => {
  27. clearState()
  28. })
  29. it('Regular users cannot see admin-level items on the Settings page', () => {
  30. // Given I am logged in
  31. cy.createRandomUser().then(($user) => {
  32. cy.login($user)
  33. cy.visit('/')
  34. })
  35. // I open the settings menu
  36. getNextcloudUserMenuToggle().click()
  37. // I navigate to the settings panel
  38. getNextcloudUserMenu().find('#settings a').click()
  39. cy.url().should('match', /\/settings\/user$/)
  40. cy.get('#app-navigation').should('be.visible').within(() => {
  41. // I see the personal section is NOT shown
  42. cy.get('#app-navigation-caption-personal').should('not.exist')
  43. // I see the admin section is NOT shown
  44. cy.get('#app-navigation-caption-administration').should('not.exist')
  45. // I see that the "Personal info" entry in the settings panel is shown
  46. cy.get('[data-section-id="personal-info"]').should('exist').and('be.visible')
  47. })
  48. })
  49. it('Admin users can see admin-level items on the Settings page', () => {
  50. // Given I am logged in
  51. cy.login(admin)
  52. cy.visit('/')
  53. // I open the settings menu
  54. getNextcloudUserMenuToggle().click()
  55. // I navigate to the settings panel
  56. getNextcloudUserMenu().find('#settings a').click()
  57. cy.url().should('match', /\/settings\/user$/)
  58. cy.get('#app-navigation').should('be.visible').within(() => {
  59. // I see the personal section is shown
  60. cy.get('#app-navigation-caption-personal').should('be.visible')
  61. // I see the admin section is shown
  62. cy.get('#app-navigation-caption-administration').should('be.visible')
  63. // I see that the "Personal info" entry in the settings panel is shown
  64. cy.get('[data-section-id="personal-info"]').should('exist').and('be.visible')
  65. })
  66. })
  67. })