github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/upgrade-ui-extension.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  
    27  Cypress.config();
    28  describe('UI extension upgrade tests', () => {
    29    const elemental     = new Elemental();
    30  
    31    beforeEach(() => {
    32      // Elemental-user can not be used here because it does not have access to the local cluster
    33      cy.login();
    34      cy.visit('/');
    35  
    36      // Open the navigation menu 
    37      cypressLib.burgerMenuToggle();
    38    });
    39  
    40    filterTests(['upgrade'], () => {
    41      // Enable only with K3S because still too much flaky with RKE2
    42      if (utils.isK8sVersion('k3s')) {
    43        it('Add elemental-ui dev repo', () => {
    44          cypressLib.addRepository('elemental-ui', 'https://github.com/rancher/elemental-ui.git', 'git', 'gh-pages');
    45        });
    46  
    47        qase(56,
    48          it('Upgrade Elemental UI extension', () => {
    49            cy.contains('Extensions')
    50              .click();
    51            cy.getBySel('btn-available')
    52              .click();
    53            cy.getBySel('extension-card-elemental')
    54              .contains('elemental')
    55            cy.getBySel('extension-card-install-btn-elemental')
    56              .click();
    57            cy.getBySel('install-ext-modal-install-btn')
    58              .click();
    59            // Sometimes the reload button is not displayed and it breaks the test...
    60            // Adding a sleep command waiting a more elegant solution
    61            //cy.contains('Extensions changed - reload required', {timeout: 100000});
    62            //cy.clickButton('Reload');
    63            // eslint-disable-next-line cypress/no-unnecessary-waiting
    64            cy.wait(120000);
    65            cy.reload();
    66            cy.getBySel('extension-card-uninstall-btn-elemental')
    67          })
    68        );
    69        qase(58,
    70          it('Check Elemental UI after upgrade', () => {
    71            cy.viewport(1920, 1080);
    72            // Elemental's icon should appear in the side menu
    73            cypressLib.checkNavIcon('elemental')
    74              .should('exist');
    75  
    76            // Click on the Elemental's icon
    77            cypressLib.accesMenu('OS Management');
    78  
    79            // Check Elemental's side menu
    80            elemental.checkElementalNav();
    81  
    82            // Check Elemental's main page
    83            // TODO: Could be improve to check everything
    84            cy.get('[data-testid="card-registration-endpoints"]')
    85              .contains('1');
    86            cy.get('[data-testid="card-inventory-of-machines"]')
    87              .contains('1');
    88            cy.get('[data-testid="card-clusters"]')
    89              .contains('1');
    90            cy.get('[data-testid="machine-reg-block"]')
    91              .contains('machine-registration');
    92          })
    93        );
    94      };
    95    });
    96  });