From afded137307e88ad1673b83f2a4d33cc98819da0 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Wed, 12 Feb 2025 19:44:15 +0530 Subject: [PATCH] mgr/dashboard: add basic e2e to verify wizard and topology viewer Fixes: https://tracker.ceph.com/issues/69925 Signed-off-by: Nizamudeen A --- .../cypress/e2e/rgw/multisite.e2e-spec.ts | 27 ++++++++ .../frontend/cypress/e2e/rgw/multisite.po.ts | 63 ++++++++++++++++++- .../dashboard/frontend/cypress/support/e2e.ts | 7 +++ .../rgw-multisite-details.component.html | 4 +- .../rgw-multisite-wizard.component.html | 10 ++- 5 files changed, 105 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.e2e-spec.ts index 8d8ed22da0b7f..5ec787f2e33a5 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.e2e-spec.ts @@ -102,4 +102,31 @@ describe('Multisite page', () => { multisite.deletePipe('new-pipe'); }); }); + + describe('Multi-site topology viewer', () => { + it('should show topology viewer', () => { + multisite.navigateTo('topology'); + multisite.topologyViewerExist(); + }); + + describe('Multisite replication wizard', () => { + beforeEach(() => { + multisite.navigateTo('wizard'); + }); + + it('should show replication wizard', () => { + multisite.replicationWizardExist(); + }); + + it('should verify the wizard is properly loaded', () => { + multisite.replicationWizardExist(); + // // Verify first step + multisite.verifyWizardContents('CreateRealmZonegroup'); + // Verify second step + multisite.verifyWizardContents('CreateZone'); + // Verify the review + multisite.verifyWizardContents('Review'); + }); + }); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.po.ts index 0f2078f20bba4..5240c8364244a 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.po.ts @@ -7,8 +7,22 @@ const pages = { url: '#/rgw/multisite/sync-policy/(modal:create)', id: 'cd-rgw-multisite-sync-policy-form' }, - edit: { url: '#/rgw/multisite/sync-policy/(modal:edit', id: 'cd-rgw-multisite-sync-policy-form' } + edit: { url: '#/rgw/multisite/sync-policy/(modal:edit', id: 'cd-rgw-multisite-sync-policy-form' }, + topology: { url: '#/rgw/multisite/configuration', id: 'cd-rgw-multisite-details' }, + wizard: { + url: '#/rgw/multisite/configuration/(modal:setup-multisite-replication)', + id: 'cd-rgw-multisite-wizard' + } }; + +enum WizardSteps { + CreateRealmZonegroup = 'Create Realm & Zonegroup', + CreateZone = 'Create Zone', + Review = 'Review' +} + +type Step = keyof typeof WizardSteps; + export class MultisitePageHelper extends PageHelper { pages = pages; @@ -289,4 +303,51 @@ export class MultisitePageHelper extends PageHelper { // Waits for item to be removed from table getRow(pipe_id).should('not.exist'); } + + @PageHelper.restrictTo(pages.topology.url) + topologyViewerExist() { + cy.get(pages.topology.id).should('be.visible'); + cy.get('[data-testid=rgw-multisite-details-header]').should('have.text', 'Topology Viewer'); + } + + @PageHelper.restrictTo(pages.wizard.url) + replicationWizardExist() { + cy.get('cds-modal').then(() => { + cy.get('[data-testid=rgw-multisite-wizard-header]').should( + 'have.text', + 'Set up Multi-site Replication' + ); + }); + } + + @PageHelper.restrictTo(pages.index.url) + verifyWizardContents(step: Step) { + cy.get('cds-modal').then(() => { + this.gotoStep(step); + if (step === 'CreateRealmZonegroup') { + this.typeValueToField('realmName', 'test-realm'); + this.typeValueToField('zonegroupName', 'test-zg'); + } else if (step === 'CreateZone') { + this.typeValueToField('zoneName', 'test-zone'); + } else { + this.gotoStep('Review'); + cy.get('.form-group.row').then(() => { + cy.get('#realmName').invoke('text').should('eq', 'test-realm'); + cy.get('#zonegroupName').invoke('text').should('eq', 'test-zg'); + cy.get('#zoneName').invoke('text').should('eq', 'test-zone'); + }); + } + }); + } + + typeValueToField(fieldID: string, value: string) { + cy.get(`#${fieldID}`).clear().type(value).should('have.value', value); + } + + gotoStep(step: Step) { + cy.get('cd-wizard').then(() => { + cy.get('form').should('be.visible'); + cy.get('button').contains(WizardSteps[step]).click(); + }); + } } diff --git a/src/pybind/mgr/dashboard/frontend/cypress/support/e2e.ts b/src/pybind/mgr/dashboard/frontend/cypress/support/e2e.ts index 4db2c6a4926a9..8b55b576589d0 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/support/e2e.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/support/e2e.ts @@ -17,3 +17,10 @@ Cypress.on('uncaught:exception', (err: Error) => { } return true; }); + +Cypress.on('fail', (err: Error) => { + if (err.message.includes('xhr') && err.message.includes('canceled')) { + return false; // Ignore canceled XHR requests + } + return true; +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html index c3b740ec7c682..48fc0eeb5f2f7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html @@ -51,8 +51,8 @@
Topology Viewer -
+ data-testid="rgw-multisite-details-header" + i18n>Topology Viewer

Set up Multi-site Replication

@@ -323,14 +324,16 @@
-
+
{{ multisiteSetupForm.get('realmName').value }}
-
+
{{ multisiteSetupForm.get('zonegroupName').value }}
@@ -344,7 +347,8 @@
-
+
{{ multisiteSetupForm.get('zoneName').value }}
-- 2.47.3