Skip to content

Commit d1746b0

Browse files
committed
chore(tests): Migrate duplicated menu settings tests (access levels) to Cypress
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent a7c8851 commit d1746b0

File tree

3 files changed

+115
-79
lines changed

3 files changed

+115
-79
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
23+
import { User } from '@nextcloud/cypress'
24+
import { clearState, getNextcloudUserMenu, getNextcloudUserMenuToggle } from '../../support/commonUtils'
25+
26+
const admin = new User('admin', 'admin')
27+
28+
describe('Header: Ensure regular users do not have admin settings in the Settings menu', { testIsolation: true }, () => {
29+
beforeEach(() => {
30+
clearState()
31+
})
32+
33+
it('Regular users can see basic items in the Settings menu', () => {
34+
// Given I am logged in
35+
cy.createRandomUser().then(($user) => {
36+
cy.login($user)
37+
cy.visit('/')
38+
})
39+
// I open the settings menu
40+
getNextcloudUserMenuToggle().click()
41+
42+
getNextcloudUserMenu().find('ul').within(($el) => {
43+
// I see the settings menu is open
44+
cy.wrap($el).should('be.visible')
45+
46+
// I see that the Settings menu has only 5 items
47+
cy.get('li').should('have.length', 5)
48+
// I see that the "Set status" item in the Settings menu is shown
49+
cy.contains('li', 'Set status').should('be.visible')
50+
// I see that the "Appearance and accessibility" item in the Settings menu is shown
51+
cy.contains('li', 'Appearance and accessibility').should('be.visible')
52+
// I see that the "Settings" item in the Settings menu is shown
53+
cy.contains('li', 'Settings').should('be.visible')
54+
// I see that the "Help" item in the Settings menu is shown
55+
cy.contains('li', 'Help').should('be.visible')
56+
// I see that the "Log out" item in the Settings menu is shown
57+
cy.contains('li', 'Log out').should('be.visible')
58+
})
59+
})
60+
61+
it('Regular users cannot see admin-level items in the Settings menu', () => {
62+
// Given I am logged in
63+
cy.createRandomUser().then(($user) => {
64+
cy.login($user)
65+
cy.visit('/')
66+
})
67+
// I open the settings menu
68+
getNextcloudUserMenuToggle().click()
69+
70+
getNextcloudUserMenu().find('ul').within(($el) => {
71+
// I see the settings menu is open
72+
cy.wrap($el).should('be.visible')
73+
74+
// I see that the "Users" item in the Settings menu is NOT shown
75+
cy.contains('li', 'Users').should('not.exist')
76+
// I see that the "Administration settings" item in the Settings menu is NOT shown
77+
cy.contains('li', 'Administration settings').should('not.exist')
78+
cy.get('#admin_settings').should('not.exist')
79+
})
80+
})
81+
82+
it('Admin users can see admin-level items in the Settings menu', () => {
83+
// Given I am logged in
84+
cy.login(admin)
85+
cy.visit('/')
86+
87+
// I open the settings menu
88+
getNextcloudUserMenuToggle().click()
89+
90+
getNextcloudUserMenu().find('ul').within(($el) => {
91+
// I see the settings menu is open
92+
cy.wrap($el).should('be.visible')
93+
94+
// I see that the Settings menu has only 8 items
95+
cy.get('li').should('have.length', 8)
96+
// I see that the "Set status" item in the Settings menu is shown
97+
cy.contains('li', 'Set status').should('be.visible')
98+
// I see that the "Appearance and accessibility" item in the Settings menu is shown
99+
cy.contains('li', 'Appearance and accessibility').should('be.visible')
100+
// I see that the "Personal Settings" item in the Settings menu is shown
101+
cy.contains('li', 'Personal settings').should('be.visible')
102+
// I see that the "Administration settings" item in the Settings menu is shown
103+
cy.contains('li', 'Administration settings').should('be.visible')
104+
// I see that the "Apps" item in the Settings menu is shown
105+
cy.contains('li', 'Apps').should('be.visible')
106+
// I see that the "Users" item in the Settings menu is shown
107+
cy.contains('li', 'Users').should('be.visible')
108+
// I see that the "Help" item in the Settings menu is shown
109+
cy.contains('li', 'Help').should('be.visible')
110+
// I see that the "Log out" item in the Settings menu is shown
111+
cy.contains('li', 'Log out').should('be.visible')
112+
})
113+
})
114+
})

cypress/e2e/settings/access-levels.cy.ts

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,11 @@ import { clearState, getNextcloudUserMenu, getNextcloudUserMenuToggle } from '..
2525

2626
const admin = new User('admin', 'admin')
2727

28-
describe('Settings: Access levels', { testIsolation: true }, () => {
28+
describe('Settings: Ensure only administrator can see the administration settings section', { testIsolation: true }, () => {
2929
beforeEach(() => {
3030
clearState()
3131
})
3232

33-
it('Regular users cannot see admin-level items in the Settings menu', () => {
34-
// Given I am logged in
35-
cy.createRandomUser().then(($user) => {
36-
cy.login($user)
37-
cy.visit('/')
38-
})
39-
// I open the settings menu
40-
getNextcloudUserMenuToggle().click()
41-
42-
getNextcloudUserMenu().find('ul').within(($el) => {
43-
// I see the settings menu is open
44-
cy.wrap($el).should('be.visible')
45-
46-
// I see that the "Settings" item in the Settings menu is shown
47-
cy.contains('li', 'Settings').should('be.visible')
48-
// I see that the "Help" item in the Settings menu is shown
49-
cy.contains('li', 'Help').should('be.visible')
50-
// I see that the "Log out" item in the Settings menu is shown
51-
cy.contains('li', 'Log out').should('be.visible')
52-
53-
// I see that the "Users" item in the Settings menu is NOT shown
54-
cy.contains('li', 'Users').should('not.exist')
55-
// I see that the "Administration settings" item in the Settings menu is NOT shown
56-
cy.contains('li', 'Administration settings').should('not.exist')
57-
cy.get('#admin_settings').should('not.exist')
58-
})
59-
})
60-
6133
it('Regular users cannot see admin-level items on the Settings page', () => {
6234
// Given I am logged in
6335
cy.createRandomUser().then(($user) => {
@@ -82,31 +54,6 @@ describe('Settings: Access levels', { testIsolation: true }, () => {
8254
})
8355
})
8456

85-
it('Admin users can see admin-level items in the Settings menu', () => {
86-
// Given I am logged in
87-
cy.login(admin)
88-
cy.visit('/')
89-
90-
// I open the settings menu
91-
getNextcloudUserMenuToggle().click()
92-
93-
getNextcloudUserMenu().find('ul').within(($el) => {
94-
// I see the settings menu is open
95-
cy.wrap($el).should('be.visible')
96-
97-
// I see that the "Personal Settings" item in the Settings menu is shown
98-
cy.contains('li', 'Personal settings').should('be.visible')
99-
// I see that the "Administration settings" item in the Settings menu is shown
100-
cy.contains('li', 'Administration settings').should('be.visible')
101-
// I see that the "Help" item in the Settings menu is shown
102-
cy.contains('li', 'Help').should('be.visible')
103-
// I see that the "Users" item in the Settings menu is shown
104-
cy.contains('li', 'Users').should('be.visible')
105-
// I see that the "Log out" item in the Settings menu is shown
106-
cy.contains('li', 'Log out').should('be.visible')
107-
})
108-
})
109-
11057
it('Admin users can see admin-level items on the Settings page', () => {
11158
// Given I am logged in
11259
cy.login(admin)

tests/acceptance/features/header.feature

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
@apache
22
Feature: header
33

4-
Scenario: admin users can see admin-level items in the Settings menu
5-
Given I am logged in as the admin
6-
When I open the Settings menu
7-
Then I see that the Settings menu is shown
8-
And I see that the Settings menu has only 9 items
9-
And I see that the "Set status" item in the Settings menu is shown
10-
And I see that the "Appearance and accessibility" item in the Settings menu is shown
11-
And I see that the "Personal settings" item in the Settings menu is shown
12-
And I see that the "Administration settings" item in the Settings menu is shown
13-
And I see that the "Apps" item in the Settings menu is shown
14-
And I see that the "Users" item in the Settings menu is shown
15-
And I see that the "Help" item in the Settings menu is shown
16-
And I see that the "Log out" item in the Settings menu is shown
17-
18-
Scenario: normal users can see basic items in the Settings menu
19-
Given I am logged in
20-
When I open the Settings menu
21-
Then I see that the Settings menu is shown
22-
And I see that the Settings menu has only 6 items
23-
And I see that the "Set status" item in the Settings menu is shown
24-
And I see that the "Appearance and accessibility" item in the Settings menu is shown
25-
And I see that the "Settings" item in the Settings menu is shown
26-
And I see that the "Help" item in the Settings menu is shown
27-
And I see that the "Log out" item in the Settings menu is shown
28-
294
Scenario: other users are seen in the contacts menu
305
Given I am logged in as the admin
316
When I open the Contacts menu

0 commit comments

Comments
 (0)