1
0

access-levels.cy.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import { User } from '@nextcloud/cypress'
  6. import { clearState, getNextcloudUserMenu, getNextcloudUserMenuToggle } from '../../support/commonUtils'
  7. const admin = new User('admin', 'admin')
  8. describe('Settings: Ensure only administrator can see the administration settings section', { testIsolation: true }, () => {
  9. beforeEach(() => {
  10. clearState()
  11. })
  12. it('Regular users cannot see admin-level items on the Settings page', () => {
  13. // Given I am logged in
  14. cy.createRandomUser().then(($user) => {
  15. cy.login($user)
  16. cy.visit('/')
  17. })
  18. // I open the settings menu
  19. getNextcloudUserMenuToggle().click()
  20. // I navigate to the settings panel
  21. getNextcloudUserMenu().find('#settings a').click()
  22. cy.url().should('match', /\/settings\/user$/)
  23. cy.get('#app-navigation').should('be.visible').within(() => {
  24. // I see the personal section is NOT shown
  25. cy.get('#app-navigation-caption-personal').should('not.exist')
  26. // I see the admin section is NOT shown
  27. cy.get('#app-navigation-caption-administration').should('not.exist')
  28. // I see that the "Personal info" entry in the settings panel is shown
  29. cy.get('[data-section-id="personal-info"]').should('exist').and('be.visible')
  30. })
  31. })
  32. it('Admin users can see admin-level items on the Settings page', () => {
  33. // Given I am logged in
  34. cy.login(admin)
  35. cy.visit('/')
  36. // I open the settings menu
  37. getNextcloudUserMenuToggle().click()
  38. // I navigate to the settings panel
  39. getNextcloudUserMenu().find('#settings a').click()
  40. cy.url().should('match', /\/settings\/user$/)
  41. cy.get('#app-navigation').should('be.visible').within(() => {
  42. // I see the personal section is shown
  43. cy.get('#app-navigation-caption-personal').should('be.visible')
  44. // I see the admin section is shown
  45. cy.get('#app-navigation-caption-administration').should('be.visible')
  46. // I see that the "Personal info" entry in the settings panel is shown
  47. cy.get('[data-section-id="personal-info"]').should('exist').and('be.visible')
  48. })
  49. })
  50. })