github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/upgrade-operator.spec.ts (about)

     1  /*
     2  Copyright © 2022 - 2024 SUSE LLC
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6      http://www.apache.org/licenses/LICENSE-2.0
     7  Unless required by applicable law or agreed to in writing, software
     8  distributed under the License is distributed on an "AS IS" BASIS,
     9  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10  See the License for the specific language governing permissions and
    11  limitations under the License.
    12  */
    13  
    14  import { Elemental } from '~/support/elemental';
    15  import '~/support/commands';
    16  import 'cypress-file-upload';
    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 * as utils from "~/support/utils";
    21  import { slowCypressDown } from 'cypress-slow-down'
    22  
    23  // slow down each command by 500ms
    24  slowCypressDown(500)
    25  
    26  Cypress.config();
    27  describe('Elemental operator upgrade tests', () => {
    28    const elemental = new Elemental();
    29  
    30    beforeEach(() => {
    31      // Elemental-user can not be used here because it does not have access to the local cluster
    32      cy.login();
    33      cy.visit('/');
    34  
    35      // Open the navigation menu 
    36      cypressLib.burgerMenuToggle();
    37    });
    38  
    39    filterTests(['upgrade'], () => {
    40      // Enable only with K3S because still too much flaky with RKE2
    41      if (utils.isK8sVersion('k3s') && !utils.isRancherManagerVersion('2.7')) {
    42        if (!utils.isOperatorVersion('marketplace')) {
    43          it('Add elemental-operator dev repo', () => {
    44            cypressLib.addRepository('elemental-operator', Cypress.env('chartmuseum_repo')+':8080', 'helm', 'none');
    45          });
    46        } else {
    47          qase(55,
    48            it('Upgrade Elemental operator', () => {
    49              cy.contains('local')
    50                .click();
    51              cy.get('.nav').contains('Apps')
    52                .click();
    53              if (!utils.isOperatorVersion('marketplace')) {
    54                cy.contains('.item.has-description.color1', 'Elemental', {timeout:30000})
    55                  .click();
    56              } else {
    57                cy.contains('Elemental', {timeout:30000})
    58                  .click();
    59              }
    60              cy.contains('Charts: Elemental', {timeout:30000});
    61              cy.clickButton('Upgrade');
    62              cy.contains('.header > .title', 'elemental-operator');
    63              cy.clickButton('Next');
    64              cy.clickButton('Upgrade');
    65              cy.contains('SUCCESS: helm', {timeout:120000});
    66              cy.contains('Installed App: elemental-operator Pending-Upgrade', {timeout:120000});
    67              cy.contains('Installed App: elemental-operator Deployed', {timeout:120000});
    68            })
    69          );
    70  
    71          qase(58,
    72            it('Check Elemental UI after upgrade', () => {
    73              cy.viewport(1920, 1080);
    74              // Elemental's icon should appear in the side menu
    75              cypressLib.checkNavIcon('elemental')
    76                .should('exist');
    77  
    78              // Click on the Elemental's icon
    79              cypressLib.accesMenu('OS Management');
    80  
    81              // Check Elemental's side menu
    82              elemental.checkElementalNav();
    83  
    84              // Check Elemental's main page
    85              // TODO: Could be improve to check everything
    86              cy.get('[data-testid="card-registration-endpoints"]')
    87                .contains('1');
    88              cy.get('[data-testid="card-inventory-of-machines"]')
    89                .contains('1');
    90              cy.get('[data-testid="card-clusters"]')
    91                .contains('1');
    92              cy.get('[data-testid="machine-reg-block"]')
    93                .contains('machine-registration');
    94              // Check OS Versions Channel
    95              cy.clickNavMenu(["Advanced", "OS Version Channels"]);
    96              cy.get('.main-row')
    97                .contains('Active elemental-channel', {timeout: 60000});
    98            })
    99          );
   100        };
   101      };
   102    });
   103  });