github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/machine_selector.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 import { slowCypressDown } from 'cypress-slow-down' 21 22 // slow down each command by 500ms 23 slowCypressDown(500) 24 25 filterTests(['main'], () => { 26 Cypress.config(); 27 describe('Machine selector testing', () => { 28 const elemental = new Elemental(); 29 const elementalUser = "elemental-user" 30 const uiAccount = Cypress.env('ui_account'); 31 const uiPassword = "rancherpassword" 32 const vmNumber = 3; 33 34 beforeEach(() => { 35 (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); 36 cy.visit('/'); 37 38 // Open the navigation menu 39 cypressLib.burgerMenuToggle(); 40 41 // Click on the Elemental's icon 42 cypressLib.accesMenu('OS Management'); 43 44 // Go to the cluster creation page 45 elemental.accessClusterMenu(); 46 }); 47 48 qase(25, 49 it('Testing selector without any rule', () => { 50 cy.contains('.banner', `Matches all ${vmNumber} existing Inventory of Machines`) 51 .should('exist'); 52 }) 53 ); 54 55 qase(26, 56 it('Testing selector with unmatching rule', () => { 57 //cy.clickButton('Add Rule'); 58 // TODO: Cannot use the clickButton here, I do not know why yet 59 cy.get('[cluster="[provisioning.cattle.io.cluster: undefined]"]') 60 .contains('Add Rule') 61 .click(); 62 cy.get('[data-testid="input-match-expression-values-0"] > input').as('match-value') 63 cy.get('@match-value').click() 64 cy.get('@match-value').type('wrong'); 65 cy.contains('.banner', 'Matches no existing Inventory of Machines') 66 .should('exist'); 67 }) 68 ); 69 70 qase(27, 71 it('Testing selector with matching rule', () => { 72 //cy.clickButton('Add Rule'); 73 // TODO: Cannot use the clickButton here, I do not know why yet 74 cy.get('[cluster="[provisioning.cattle.io.cluster: undefined]"]') 75 .contains('Add Rule') 76 .click(); 77 cy.get('[data-testid="input-match-expression-key-0"]') 78 .click() 79 cy.contains('myInvLabel1') 80 .click(); 81 cy.get('[data-testid="input-match-expression-values-0"] > input').as('match-value') 82 cy.get('@match-value').click() 83 cy.get('@match-value').type('myInvLabelValue1'); 84 cy.contains('.banner', `Matches all ${vmNumber} existing Inventory of Machines`) 85 .should('exist'); 86 }) 87 ); 88 }); 89 });