From 54442c317ae309d872270712e5ab831336c9572d Mon Sep 17 00:00:00 2001 From: Patrick Seidensal Date: Mon, 26 Aug 2019 17:14:34 +0200 Subject: [PATCH] mgr/dashboard: refactoring E2E mirroring test Signed-off-by: Patrick Seidensal --- .../frontend/e2e/block/mirroring.e2e-spec.ts | 14 ++++++-------- .../dashboard/frontend/e2e/block/mirroring.po.ts | 11 ++++++++--- .../mgr/dashboard/frontend/e2e/page-helper.po.ts | 5 ++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.e2e-spec.ts index 205779a6d2e..8cbc45061fb 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.e2e-spec.ts @@ -36,30 +36,28 @@ describe('Mirroring page', () => { }); describe('checks that edit mode functionality shows in the pools table', async () => { - const poolName = 'mirrorpoolrq'; + const poolName = 'mirroring_test'; beforeAll(async () => { await pools.navigateTo('create'); // Need pool for mirroring testing await pools.create(poolName, 8, 'rbd'); - // console.log(`before second navigateTo()`); await pools.navigateTo(); - // console.log(`before pools.exist(${poolName})`); await pools.exist(poolName, true); - // console.log(`beforeAll done`); }); it('tests editing mode for pools', async () => { await mirroring.navigateTo(); - expect(await mirroring.editMirror(poolName, 'Pool')); + + await mirroring.editMirror(poolName, 'Pool'); expect(await mirroring.getFirstTableCellWithText('pool').isPresent()).toBe(true); - expect(await mirroring.editMirror(poolName, 'Image')); + await mirroring.editMirror(poolName, 'Image'); expect(await mirroring.getFirstTableCellWithText('image').isPresent()).toBe(true); - expect(await mirroring.editMirror(poolName, 'Disabled')); + await mirroring.editMirror(poolName, 'Disabled'); expect(await mirroring.getFirstTableCellWithText('disabled').isPresent()).toBe(true); }); afterAll(async () => { - await pools.navigateTo(); // Deletes mirroring test pool + await pools.navigateTo(); await pools.delete(poolName); await pools.navigateTo(); await pools.exist(poolName, false); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts index a95fa422586..d428288a3f8 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts @@ -2,11 +2,16 @@ import { $, browser, by, element } from 'protractor'; import { Helper } from '../helper.po'; import { PageHelper } from '../page-helper.po'; +const pages = { index: '/#/block/mirroring' }; + export class MirroringPageHelper extends PageHelper { - pages = { index: '/#/block/mirroring' }; + pages = pages; - // Goes to the mirroring page and edits a pool in the Pool table. Clicks on the - // pool and chooses a option (either pool, image, or disabled) + /** + * Goes to the mirroring page and edits a pool in the Pool table. Clicks on the + * pool and chooses an option (either pool, image, or disabled) + */ + @PageHelper.restrictTo(pages.index) async editMirror(name, option) { // Clicks the pool in the table await browser.wait( diff --git a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts index 64e7db0555d..0b89f49ae31 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts @@ -113,7 +113,10 @@ export abstract class PageHelper { return $$('.nav.nav-tabs li').count(); } - getFirstTableCellWithText(content): ElementFinder { + /** + * Searches multiple tables and returns the first cell of any table that matches the criteria. + */ + getFirstTableCellWithText(content: string): ElementFinder { return element.all(by.cssContainingText('.datatable-body-cell-label', content)).first(); } -- 2.39.5