]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: fixing cephadm dashboard e2e failures
authorNizamudeen A <nia@redhat.com>
Fri, 27 Sep 2024 05:28:41 +0000 (10:58 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 13 Mar 2025 04:47:14 +0000 (10:17 +0530)
the wizard component changes caused issue to the e2e, so fixing it.
It was uncaught before because of the test were unable to run due to
some lab issues.

Fixes: https://tracker.ceph.com/issues/68871
Signed-off-by: Nizamudeen A <nia@redhat.com>
12 files changed:
src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/hosts.po.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/osds.po.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/common/create-cluster/create-cluster.feature.po.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/common/forms-helper.feature.po.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/orchestrator/workflow/02-create-cluster-add-host.feature
src/pybind/mgr/dashboard/frontend/cypress/e2e/orchestrator/workflow/03-create-cluster-create-services.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/orchestrator/workflow/04-create-cluster-create-osds.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/orchestrator/workflow/05-create-cluster-review.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/orchestrator/workflow/06-cluster-check.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dynamic-input-combobox.directive.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/combo-box.service.ts

index 7c2db0efd06db2086b5525449a8893ce9e65593a..43ef2d5cd50e90fb9bdefa7b98bfcebfa3cfdb36 100644 (file)
@@ -21,7 +21,7 @@ export class HostsPageHelper extends PageHelper {
 
   add(hostname: string, exist?: boolean, maintenance?: boolean, labels: string[] = []) {
     cy.get(`${this.pages.add.id}`).within(() => {
-      cy.get('#hostname').type(hostname);
+      cy.get('#hostname').type(hostname, { force: true });
       if (maintenance) {
         cy.get('label[for=maintenance]').click();
       }
@@ -35,6 +35,7 @@ export class HostsPageHelper extends PageHelper {
     }
 
     cy.get('cd-submit-button').click();
+    cy.get('cds-modal').should('not.exist');
     // back to host list
     cy.get(`${this.pages.index.id}`);
   }
index ad7224de1211e22d658551102200da7e3473ee2a..b35a94050a1addda1041a9a8ff9c86632d4805c3 100644 (file)
@@ -50,9 +50,8 @@ export class OSDsPageHelper extends PageHelper {
 
   @PageHelper.restrictTo(pages.index.url)
   checkStatus(id: number, status: string[]) {
-    this.searchTable(`id:${id}`);
+    this.searchTable(id.toString());
     cy.wait(5 * 1000);
-    this.expectTableCount('found', 1);
     cy.get(`[cdstabledata]:nth-child(${this.columnIndex.status}) .badge`).should(($ele) => {
       const allStatus = $ele.toArray().map((v) => v.innerText);
       for (const s of status) {
index d18c348554691aac3c2e854b9a240a305023f9b6..76c3cedf653dd54bfe09900cc89de46d3e4b9d3c 100644 (file)
@@ -2,8 +2,8 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
 
 Given('I am on the {string} section', (page: string) => {
   cy.get('cd-wizard').within(() => {
-    cy.get('.nav-link').should('contain.text', page).first().click();
-    cy.get('.nav-link.active').should('contain.text', page);
+    cy.get('button').should('have.attr', 'title', page).first().click();
+    cy.get('.cds--assistive-text').should('contain.text', 'Current');
   });
 });
 
index a43a304c680d4f2a653d9bba844bd8db0adc3a14..6252fc7e99d89dcdcad65851147b1fb44bc2f649 100644 (file)
@@ -42,16 +42,17 @@ And('select options {string}', (labels: string) => {
 
 And('{string} option {string}', (action: string, labels: string) => {
   if (labels) {
+    cy.get('cds-modal').find('input[id=labels]').click();
     if (action === 'add') {
-      cy.get('cd-modal').find('.select-menu-edit').click();
       for (const label of labels.split(', ')) {
-        cy.get('.popover-body input').type(`${label}{enter}`);
+        cy.get('input[id=labels]').clear().type(`${label}`);
+
+        cy.get('cds-dropdown-list').find('li').should('have.attr', 'title', label).click();
       }
     } else {
       for (const label of labels.split(', ')) {
-        cy.contains('cd-modal .badge', new RegExp(`^${label}$`))
-          .find('.badge-remove')
-          .click();
+        cy.get('input[id=labels]').clear().type(`${label}`);
+        cy.get('cds-dropdown-list').find('li').should('have.attr', 'title', label).click();
       }
     }
   }
@@ -84,7 +85,7 @@ And('I confirm to {string} on carbon modal', (action: string) => {
 });
 
 Then('I should see an error in {string} field', (field: string) => {
-  cy.get('cd-modal').within(() => {
+  cy.get('cds-modal').within(() => {
     cy.get(`input[id=${field}]`).should('have.class', 'ng-invalid');
   });
 });
index b9578f8c03d46b117f9d501785f01e670d78a70c..0c62d576aa569309a200e15038265e05caf53c8b 100644 (file)
@@ -12,10 +12,9 @@ Feature: Cluster expansion host addition
     Scenario Outline: Add hosts
         Given I am on the "Add Hosts" section
         When I click on "Add" button
-        And enter "hostname" "<hostname>" in the modal
-        And select options "<labels>"
+        And enter "hostname" "<hostname>" in the carbon modal
+        And "add" option "<labels>"
         And I click on "Add Host" button
-        Then I should not see the modal
         And I should see a row with "<hostname>"
         And I should see row "<hostname>" have "<labels>"
 
@@ -32,7 +31,6 @@ Feature: Cluster expansion host addition
         Then I should see the carbon modal
         And I check the tick box in carbon modal
         And I click on "Remove Host" button
-        Then I should not see the carbon modal
         And I should not see a row with "<hostname>"
 
         Examples:
@@ -43,9 +41,8 @@ Feature: Cluster expansion host addition
     Scenario: Add hosts using pattern 'ceph-node-[01-02]'
         Given I am on the "Add Hosts" section
         When I click on "Add" button
-        And enter "hostname" "ceph-node-[01-02]" in the modal
+        And enter "hostname" "ceph-node-[01-02]" in the carbon modal
         And I click on "Add Host" button
-        Then I should not see the modal
         And I should see rows with following entries
             | hostname |
             | ceph-node-01 |
@@ -55,7 +52,7 @@ Feature: Cluster expansion host addition
         Given I am on the "Add Hosts" section
         And I should see a row with "ceph-node-00"
         When I click on "Add" button
-        And enter "hostname" "ceph-node-00" in the modal
+        And enter "hostname" "ceph-node-00" in the carbon modal
         Then I should see an error in "hostname" field
 
     Scenario Outline: Add and remove labels on host
index 0118c85c113dd2b8f4527ad856c20567252ec29e..0f55fd9a99feff58d55abb51d1767897d4356e56 100644 (file)
@@ -19,7 +19,10 @@ describe('Create cluster create services page', () => {
     cy.login();
     createCluster.navigateTo();
     createCluster.createCluster();
-    cy.get('.nav-link').contains('Create Services').click();
+
+    cy.get('cd-wizard').within(() => {
+      cy.get('button').contains('Create Services').click();
+    });
   });
 
   it('should check if title contains Create Services', () => {
index 5583d37fd12b6f3869150d1162d8d4a636018ac0..858126774f8103ff53d13611baf65c74cba2c212 100644 (file)
@@ -12,7 +12,9 @@ describe('Create cluster create osds page', () => {
     cy.login();
     createCluster.navigateTo();
     createCluster.createCluster();
-    cy.get('.nav-link').contains('Create OSDs').click();
+    cy.get('cd-wizard').within(() => {
+      cy.get('button').contains('Create OSDs').click();
+    });
   });
 
   it('should check if title contains Create OSDs', () => {
@@ -28,12 +30,16 @@ describe('Create cluster create osds page', () => {
         // Go to the Review section and Expand the cluster
         // because the drive group spec is only stored
         // in frontend and will be lost when refreshed
-        cy.get('.nav-link').contains('Review').click();
+        cy.get('cd-wizard').within(() => {
+          cy.get('button').contains('Review').click();
+        });
         cy.get('button[aria-label="Next"]').click();
         cy.get('cd-dashboard').should('exist');
         createCluster.navigateTo();
         createCluster.createCluster();
-        cy.get('.nav-link').contains('Create OSDs').click();
+        cy.get('cd-wizard').within(() => {
+          cy.get('button').contains('Create OSDs').click();
+        });
       }
     });
   });
index d5b4a368d3900f52140b782b2c4cfdc770a7e219..b0acb6964aa706ba308689c52a1cece9887b09ef 100644 (file)
@@ -14,12 +14,8 @@ describe('Create Cluster Review page', () => {
     createCluster.navigateTo();
     createCluster.createCluster();
 
-    cy.get('.nav-link').contains('Review').click();
-  });
-
-  describe('navigation link test', () => {
-    it('should check if active nav-link is of Review section', () => {
-      cy.get('.nav-link.active').should('contain.text', 'Review');
+    cy.get('cd-wizard').within(() => {
+      cy.get('button').contains('Review').click();
     });
   });
 
index 722741a6cc50cbce6517e1fa36cf2195ace15649..e1c66c0f4af3c33d0147f9576e4e4436cc5c0f7c 100644 (file)
@@ -21,10 +21,14 @@ describe('when cluster creation is completed', () => {
 
     // Explicitly skip OSD Creation Step so that it prevents from
     // deploying OSDs to the hosts automatically.
-    cy.get('.nav-link').contains('Create OSDs').click();
+    cy.get('cd-wizard').within(() => {
+      cy.get('button').contains('Create OSDs').click();
+    });
     cy.get('button[aria-label="Skip this step"]').click();
 
-    cy.get('.nav-link').contains('Review').click();
+    cy.get('cd-wizard').within(() => {
+      cy.get('button').contains('Review').click();
+    });
     cy.get('button[aria-label="Next"]').click();
     cy.get('cd-dashboard').should('exist');
   });
index 7a3bbf079d869f310afe8cfe335424b3bf844775..d652465846afe61cd1b818dc7ffcda2c4fb17743 100644 (file)
@@ -328,7 +328,7 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
       const host = this.selection.first();
       const labels = new Set(resp.concat(this.hostService.predefinedLabels));
       const allLabels = Array.from(labels).map((label) => {
-        return { content: label };
+        return { content: label, selected: host['labels'].includes(label) };
       });
       this.cdsModalService.show(FormModalComponent, {
         titleText: $localize`Edit Host: ${host.hostname}`,
index 0f7d99415772cb5679dc1b7a0c0a1e28efb2e3f9..2645e466ec6e960a2bbf327e601b0ef28968c834 100644 (file)
@@ -1,4 +1,12 @@
-import { Directive, Input, OnDestroy, OnInit, Output, EventEmitter, HostListener } from '@angular/core';
+import {
+  Directive,
+  Input,
+  OnDestroy,
+  OnInit,
+  Output,
+  EventEmitter,
+  HostListener
+} from '@angular/core';
 import { ComboBoxItem } from '../models/combo-box.model';
 import { ComboBoxService } from '../services/combo-box.service';
 import { Subject, Subscription } from 'rxjs';
@@ -15,9 +23,6 @@ export const DEBOUNCE_TIMER = 300;
   selector: '[cdDynamicInputCombobox]'
 })
 export class DynamicInputComboboxDirective implements OnInit, OnDestroy {
-  /**
-   * This input is the same as what we have in the <cds-combobox> element.
-   */
   @Input() items: ComboBoxItem[];
 
   /**
@@ -29,9 +34,7 @@ export class DynamicInputComboboxDirective implements OnInit, OnDestroy {
   private searchSubject: Subject<string> = new Subject();
   private selectedItems: ComboBoxItem[] = [];
 
-  constructor(
-    private combBoxService: ComboBoxService
-  ) { }
+  constructor(private combBoxService: ComboBoxService) {}
 
   ngOnInit() {
     this.searchSubscription = this.searchSubject
@@ -52,12 +55,12 @@ export class DynamicInputComboboxDirective implements OnInit, OnDestroy {
         const exists = this.items.some(
           (item: ComboBoxItem) => item.content === searchString
         );
-      
-        if (!exists) {
-          this.items = this.items.concat({ content: searchString, name: searchString });
-        }
-        this.updatedItems.emit(this.items );
-        this.combBoxService.emit({ searchString });
+
+      if (!exists) {
+        this.items = this.items.concat({ content: searchString, name: searchString });
+      }
+      this.updatedItems.emit(this.items);
+      this.combBoxService.emit({ searchString });
       });
   }
 
index bb193b1859235f8aee9e1b3e1f4e2201c647edc5..6d8208e69a04b6eabbef703a8e7d4f74e3ac07b9 100644 (file)
@@ -7,8 +7,7 @@ import { Subject } from 'rxjs';
 export class ComboBoxService {
   private searchSubject = new Subject<{ searchString: string }>();
 
-  constructor() {
-  }
+  constructor() {}
 
   emit(value: { searchString: string }) {
     this.searchSubject.next(value);