github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/user.spec.ts (about) 1 /* 2 Copyright © 2022 - 2024 SUSE LLC 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 http://www.apache.org/licenses/LICENSE-2.0 8 Unless required by applicable law or agreed to in writing, software 9 distributed under the License is distributed on an "AS IS" BASIS, 10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 See the License for the specific language governing permissions and 12 limitations under the License. 13 */ 14 15 import { Elemental } from '~/support/elemental'; 16 import '~/support/commands'; 17 import filterTests from '~/support/filterTests.js'; 18 import * as cypressLib from '@rancher-ecp-qa/cypress-library'; 19 import { qase } from 'cypress-qase-reporter/dist/mocha'; 20 21 Cypress.config(); 22 describe('User role testing', () => { 23 const elemental = new Elemental(); 24 const elementalUser = "elemental-user" 25 const stdUser = "std-user" 26 const uiPassword = "rancherpassword" 27 28 beforeEach(() => { 29 cy.visit('/'); 30 }); 31 32 filterTests(['main', 'upgrade'], () => { 33 qase(15, 34 it('Create standard user', () => { 35 // User without the elemental-administrator role 36 cy.login(); 37 cypressLib.burgerMenuToggle(); 38 cypressLib.createUser(stdUser, uiPassword); 39 }) 40 ); 41 42 qase(14, 43 it('Create elemental user', () => { 44 // User with the elemental-administrator role 45 cy.login(); 46 cypressLib.burgerMenuToggle(); 47 cypressLib.createUser(elementalUser, uiPassword, 'Elemental Administrator'); 48 }) 49 ); 50 }); 51 52 filterTests(['main'], () => { 53 qase(47, 54 it('Elemental user should access the OS management menu', () => { 55 cy.login(elementalUser, uiPassword); 56 cy.getBySel('banner-title') 57 .contains('Welcome to Rancher'); 58 cypressLib.burgerMenuToggle(); 59 cypressLib.checkNavIcon('elemental').should('exist'); 60 cypressLib.accesMenu('OS Management'); 61 elemental.checkElementalNav(); 62 }) 63 ); 64 65 qase(48, 66 it('Standard user should not access the OS management menu', () => { 67 cy.login(stdUser, uiPassword); 68 cy.getBySel('banner-title') 69 .contains('Welcome to Rancher'); 70 cypressLib.burgerMenuToggle(); 71 cypressLib.checkNavIcon('elemental').should('exist'); 72 cypressLib.accesMenu('OS Management'); 73 // User without appropriate role will get a specific page 74 cy.getBySel('elemental-icon') 75 .should('exist'); 76 cy.getBySel('elemental-description-text') 77 .contains('Elemental is a software stack') 78 .should('exist'); 79 cy.getBySel('warning-not-install-or-no-schema') 80 .should('exist'); 81 }) 82 ); 83 }); 84 });