From: Tiago Melo Date: Tue, 5 May 2020 09:55:49 +0000 (+0000) Subject: mgr/dashboard: Add E2E for navigation X-Git-Tag: wip-pdonnell-testing-20200918.022351~724^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b13dd050f8b16ea036c7acb7d614185678e56166;p=ceph-ci.git mgr/dashboard: Add E2E for navigation Fixes: https://tracker.ceph.com/issues/45376 Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/cypress.json b/src/pybind/mgr/dashboard/frontend/cypress.json index 4f604241edb..cef1e3382d3 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress.json +++ b/src/pybind/mgr/dashboard/frontend/cypress.json @@ -9,6 +9,5 @@ "viewportHeight": 1080, "viewportWidth": 1920, "pluginsFile": false, - "fixturesFolder": false, "projectId": "k7ab29" } diff --git a/src/pybind/mgr/dashboard/frontend/cypress/fixtures/nfs-ganesha-status.json b/src/pybind/mgr/dashboard/frontend/cypress/fixtures/nfs-ganesha-status.json new file mode 100644 index 00000000000..4dbbaaccc0d --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/fixtures/nfs-ganesha-status.json @@ -0,0 +1,4 @@ +{ + "available": false, + "message": "Ganesha config location is not configured. Please set the GANESHA_RADOS_POOL_NAMESPACE setting." +} diff --git a/src/pybind/mgr/dashboard/frontend/cypress/fixtures/rgw-status.json b/src/pybind/mgr/dashboard/frontend/cypress/fixtures/rgw-status.json new file mode 100644 index 00000000000..faa8c041869 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/fixtures/rgw-status.json @@ -0,0 +1 @@ +{ "available": true, "message": null } diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.e2e-spec.ts new file mode 100644 index 00000000000..f9d74a08b39 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.e2e-spec.ts @@ -0,0 +1,23 @@ +import { NavigationPageHelper } from './navigation.po'; + +describe('Shared pages', () => { + const shared = new NavigationPageHelper(); + + beforeEach(() => { + cy.login(); + shared.navigateTo(); + }); + + it('should display the vertical menu by default', () => { + shared.getVerticalMenu().should('be.visible'); + }); + + it('should hide the vertical menu', () => { + shared.getMenuToggler().click(); + shared.getVerticalMenu().should('not.be.visible'); + }); + + it('should navigate to the correct page', () => { + shared.checkNavigations(shared.navigations); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.po.ts new file mode 100644 index 00000000000..31215cddbd9 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/navigation.po.ts @@ -0,0 +1,69 @@ +import { PageHelper } from '../page-helper.po'; + +export class NavigationPageHelper extends PageHelper { + pages = { + index: { url: '#/dashboard', id: 'cd-dashboard' } + }; + + navigations = [ + { menu: 'NFS', component: 'cd-nfs-501' }, + { + menu: 'Object Gateway', + submenus: [ + { menu: 'Daemons', component: 'cd-rgw-daemon-list' }, + { menu: 'Users', component: 'cd-rgw-user-list' }, + { menu: 'Buckets', component: 'cd-rgw-bucket-list' } + ] + }, + { menu: 'Dashboard', component: 'cd-dashboard' }, + { + menu: 'Cluster', + submenus: [ + { menu: 'Hosts', component: 'cd-hosts' }, + { menu: 'Inventory', component: 'cd-inventory' }, + { menu: 'Monitors', component: 'cd-monitor' }, + { menu: 'Services', component: 'cd-services' }, + { menu: 'OSDs', component: 'cd-osd-list' }, + { menu: 'Configuration', component: 'cd-configuration' }, + { menu: 'CRUSH map', component: 'cd-crushmap' }, + { menu: 'Manager modules', component: 'cd-mgr-module-list' }, + { menu: 'Logs', component: 'cd-logs' }, + { menu: 'Monitoring', component: 'cd-prometheus-tabs' } + ] + }, + { menu: 'Pools', component: 'cd-pool-list' }, + { + menu: 'Block', + submenus: [ + { menu: 'Images', component: 'cd-rbd-list' }, + { menu: 'Mirroring', component: 'cd-mirroring' }, + { menu: 'iSCSI', component: 'cd-iscsi' } + ] + }, + { menu: 'Filesystem', component: 'cd-cephfs-list' } + ]; + + getVerticalMenu() { + return cy.get('ul.cd-navbar-primary'); + } + + getMenuToggler() { + return cy.get('cd-navigation > div.cd-navbar-top button.btn.btn-link'); + } + + checkNavigations(navs: any) { + // The nfs-ganesha and RGW status requests are mocked to ensure that this method runs in time + cy.server(); + cy.route('/api/nfs-ganesha/status', 'fixture:nfs-ganesha-status'); + cy.route('/api/rgw/status', 'fixture:rgw-status'); + + navs.forEach((nav: any) => { + cy.contains('.simplebar-content li.nav-item a', nav.menu).click(); + if (nav.submenus) { + this.checkNavigations(nav.submenus); + } else { + cy.get(nav.component).should('exist'); + } + }); + } +}