github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/machine_inventory.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 '~/support/commands';
    16  import filterTests from '~/support/filterTests.js';
    17  import * as utils from "~/support/utils";
    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  Cypress.config();
    26  describe('Machine inventory testing', () => {
    27    const clusterName          = "mycluster"
    28    const elementalUser        = "elemental-user"
    29    const hwLabels             = ["TotalCPUThread", "TotalMemory", "CPUModel",
    30                                 "CPUVendor", "NumberBlockDevices", "NumberNetInterface",
    31                                 "CPUVendorTotalCPUCores"]
    32    const k8sDownstreamVersion = Cypress.env('k8s_downstream_version');
    33    const proxy                = "http://172.17.0.1:3128"
    34    const uiAccount            = Cypress.env('ui_account');
    35    const uiPassword           = "rancherpassword"
    36    const vmNumber             = 3;
    37    
    38    beforeEach(() => {
    39      (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login();
    40      cy.visit('/');
    41  
    42      // Open the navigation menu
    43      cypressLib.burgerMenuToggle();
    44  
    45      // Click on the Elemental's icon
    46      cypressLib.accesMenu('OS Management');
    47    });
    48  
    49    filterTests(['main'], () => {
    50      qase(28,
    51        it('Check that machine inventory has been created', () => {
    52          cy.clickNavMenu(["Inventory of Machines"]);
    53          cy.contains('Namespace: fleet-default')
    54          for (let i = 0; i < vmNumber; i++) {
    55            cy.getBySel(`sortable-cell-${i}-0`)
    56              .contains('Active')
    57              .should('exist');
    58            cy.getBySel(`sortable-cell-${i}-1`)
    59              .contains(`node-00${i + 1}`)
    60              .should('exist');
    61          }
    62        })
    63      );
    64  
    65      qase(29,
    66        it('Check we can see our embedded hardware labels', () => {
    67          cy.clickNavMenu(["Inventory of Machines"]);
    68          cy.contains('node-001')
    69            .click()
    70          cy.checkMachInvLabel('machine-registration', 'myInvLabel1', 'myInvLabelValue1', true);
    71          for (const key in hwLabels) {
    72            cy.clickNavMenu(["Inventory of Machines"]);
    73            // Because of the double .parent() call we have to keep this ugly chain
    74            // TODO: try to use something more elegant later!
    75            // eslint-disable-next-line cypress/unsafe-to-chain-command
    76            cy.get('.table-options-group > .btn > .icon')
    77              .click()
    78              .parent()
    79              .parent()
    80              .contains(hwLabels[key])
    81              .click({force: true})
    82            cy.contains(hwLabels[key]);
    83          }
    84        })
    85      );
    86    });
    87    
    88    filterTests(['main', 'upgrade'], () => {
    89      qase(30,
    90        it('Create Elemental cluster', () => {
    91          utils.createCluster(clusterName, k8sDownstreamVersion, proxy);
    92        })
    93      );
    94    });
    95    
    96    filterTests(['main', 'upgrade'], () => {
    97      it('Check Elemental cluster status', () => {
    98        cypressLib.burgerMenuToggle();
    99        cypressLib.checkClusterStatus(clusterName, 'Active', 600000);
   100        cypressLib.burgerMenuToggle();
   101        cy.contains(clusterName)
   102          .click();
   103      })
   104    });
   105  });