From 968eabf0268be92c5d62b1d3de7fe81a56751a88 Mon Sep 17 00:00:00 2001 From: Adam King Date: Tue, 6 Aug 2019 15:02:07 -0400 Subject: [PATCH] mgr/dashboard: Hosts Page Service Links Tests Test links in "Services" column on hosts page properly link to Performance Counters pages Fixes: https://tracker.ceph.com/issues/41142 Signed-off-by: Adam King Signed-off-by: Rafael Quintero --- .../frontend/e2e/cluster/hosts.e2e-spec.ts | 10 +++++ .../frontend/e2e/cluster/hosts.po.ts | 44 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts index a04ca3c05dbba1..775eac80ac796c 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts @@ -32,4 +32,14 @@ describe('Hosts page', () => { expect(hosts.getTabText(1)).toEqual('Overall Performance'); }); }); + + describe('services link test', () => { + beforeAll(() => { + hosts.navigateTo(); + }); + + it('should check services link(s) work for first host', () => { + hosts.check_services_links(); + }); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts index 9d9a7671634906..61d8f2aed9043c 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts @@ -1,5 +1,49 @@ +import { by, element } from 'protractor'; import { PageHelper } from '../page-helper.po'; export class HostsPageHelper extends PageHelper { pages = { index: '/#/hosts' }; + + // function that checks all services links work for first + // host in table (if a host is present) + check_services_links() { + this.navigateTo(); + let links_tested = 0; + this.getTableCount() + .getText() + .then((hostcount) => { + // Only check for services links if there's at least 1 host present + if (hostcount.includes('0 total')) { + return; + } + // grab services column for first host + const services = element.all(by.css('.datatable-body-cell')).get(1); + // check is any services links are present + services.getText().then((txt) => { + // check that text (links) is present in services box + if (txt.length === 0) { + return; + } + const links = services.all(by.css('a.ng-star-inserted')); + links.count().then((num_links) => { + for (let i = 0; i < num_links; i++) { + // click link, check it worked by looking for changed breadcrumb, + // navigate back to hosts page, repeat until all links checked + links.get(i).click(); + expect(this.getBreadcrumbText()).toEqual('Performance Counters'); + this.navigateTo(); + expect(this.getBreadcrumbText()).toEqual('Hosts'); + links_tested++; + } + }); + }); + }) + .then(() => { + // check if any links were actually tested + expect(links_tested > 0).toBe( + true, + 'No links were tested. Either no hosts were present or the first host had no services' + ); + }); + } }