mgr/dashboard: migrate E2E hosts to async/await

Fixes: https://tracker.ceph.com/issues/40693

Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
This commit is contained in:
Patrick Seidensal 2019-08-19 13:07:05 +02:00
parent fa959e1dd8
commit bdaf0a89f2
4 changed files with 46 additions and 51 deletions

View File

@ -7,39 +7,39 @@ describe('Hosts page', () => {
hosts = new Helper().hosts;
});
afterEach(() => {
Helper.checkConsole();
afterEach(async () => {
await Helper.checkConsole();
});
describe('breadcrumb and tab tests', () => {
beforeAll(() => {
hosts.navigateTo();
beforeAll(async () => {
await hosts.navigateTo();
});
it('should open and show breadcrumb', () => {
expect(hosts.getBreadcrumbText()).toEqual('Hosts');
it('should open and show breadcrumb', async () => {
expect(await hosts.getBreadcrumbText()).toEqual('Hosts');
});
it('should show two tabs', () => {
expect(hosts.getTabsCount()).toEqual(2);
it('should show two tabs', async () => {
expect(await hosts.getTabsCount()).toEqual(2);
});
it('should show hosts list tab at first', () => {
expect(hosts.getTabText(0)).toEqual('Hosts List');
it('should show hosts list tab at first', async () => {
expect(await hosts.getTabText(0)).toEqual('Hosts List');
});
it('should show overall performance as a second tab', () => {
expect(hosts.getTabText(1)).toEqual('Overall Performance');
it('should show overall performance as a second tab', async () => {
expect(await hosts.getTabText(1)).toEqual('Overall Performance');
});
});
describe('services link test', () => {
it('should check at least one host is present', () => {
hosts.check_for_host();
it('should check at least one host is present', async () => {
await hosts.check_for_host();
});
it('should check services link(s) work for first host', () => {
hosts.check_services_links();
it('should check services link(s) work for first host', async () => {
await hosts.check_services_links();
});
});
});

View File

@ -4,49 +4,40 @@ import { PageHelper } from '../page-helper.po';
export class HostsPageHelper extends PageHelper {
pages = { index: '/#/hosts' };
check_for_host() {
this.navigateTo();
async check_for_host() {
await this.navigateTo();
this.getTableCount()
.getText()
.then((hostcount) => {
expect(hostcount.includes('0 total')).toBe(false);
});
const hostcount = await this.getTableCount().getText();
expect(await hostcount.includes('0 total')).toBe(false);
}
// function that checks all services links work for first
// host in table
check_services_links() {
this.navigateTo();
async check_services_links() {
await this.navigateTo();
let links_tested = 0;
// 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
expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host');
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. Test failed');
});
const txt = await services.getText();
// check that text (links) is present in services box
expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host');
if (txt.length === 0) {
return;
}
const links = services.all(by.css('a.service-link'));
const num_links = await links.count();
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
await links.get(i).click();
expect(await this.getBreadcrumbText()).toEqual('Performance Counters');
await this.navigateTo();
expect(await this.getBreadcrumbText()).toEqual('Hosts');
links_tested++;
}
// check if any links were actually tested
expect(links_tested > 0).toBe(true, 'No links were tested. Test failed');
}
}

View File

@ -1,6 +1,7 @@
import { browser } from 'protractor';
import { Logs } from 'selenium-webdriver';
import { ImagesPageHelper } from './block/images.po';
import { HostsPageHelper } from './cluster/hosts.po';
import { LogsPageHelper } from './cluster/logs.po';
import { ManagerModulesPageHelper } from './cluster/mgr-modules.po';
import { MonitorsPageHelper } from './cluster/monitors.po';
@ -32,6 +33,7 @@ export class Helper {
monitors: MonitorsPageHelper;
mgrModules: ManagerModulesPageHelper;
logs: LogsPageHelper;
hosts: HostsPageHelper;
constructor() {
this.pools = new PoolPageHelper();
@ -49,6 +51,7 @@ export class Helper {
this.monitors = new MonitorsPageHelper();
this.mgrModules = new ManagerModulesPageHelper();
this.logs = new LogsPageHelper();
this.hosts = new HostsPageHelper();
}
/**

View File

@ -9,7 +9,8 @@
(updateSelection)="updateSelection($event)">
<ng-template #servicesTpl let-value="value">
<span *ngFor="let service of value; last as isLast">
<a [routerLink]="[service.cdLink]"
<a class="service-link"
[routerLink]="[service.cdLink]"
[queryParams]="cdParams"
*ngIf="service.canRead">{{ service.type }}.{{ service.id }}
</a>