From: Patrick Seidensal Date: Mon, 19 Aug 2019 12:07:27 +0000 (+0200) Subject: mgr/dashboard: migrate E2E images to async/await X-Git-Tag: v15.1.0~1745^2~16 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=090c3222a5b842006130e5811df5e12158ede1c6;p=ceph-ci.git mgr/dashboard: migrate E2E images to async/await Fixes: https://tracker.ceph.com/issues/40693 Signed-off-by: Patrick Seidensal --- diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts index 290d78eaae3..44c86e660bb 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts @@ -9,65 +9,63 @@ describe('Images page', () => { pools = new Helper().pools; }); - afterEach(() => { - Helper.checkConsole(); + afterEach(async () => { + await Helper.checkConsole(); }); describe('breadcrumb and tab tests', () => { - beforeAll(() => { - images.navigateTo(); + beforeAll(async () => { + await images.navigateTo(); }); - it('should open and show breadcrumb', () => { - expect(images.getBreadcrumbText()).toEqual('Images'); + it('should open and show breadcrumb', async () => { + expect(await images.getBreadcrumbText()).toEqual('Images'); }); - it('should show three tabs', () => { - expect(images.getTabsCount()).toEqual(3); + it('should show three tabs', async () => { + expect(await images.getTabsCount()).toEqual(3); }); - it('should show text for all tabs', () => { - expect(images.getTabText(0)).toEqual('Images'); - expect(images.getTabText(1)).toEqual('Trash'); - expect(images.getTabText(2)).toEqual('Overall Performance'); + it('should show text for all tabs', async () => { + expect(await images.getTabText(0)).toEqual('Images'); + expect(await images.getTabText(1)).toEqual('Trash'); + expect(await images.getTabText(2)).toEqual('Overall Performance'); }); }); - describe('create, edit & delete image test', () => { + describe('create, edit & delete image test', async () => { const poolName = 'e2e_images_pool'; const imageName = 'e2e_images_image'; const newImageName = 'e2e_images_image_new'; - beforeAll(() => { - pools.navigateTo('create'); // Need pool for image testing - pools.create(poolName, 8, 'rbd').then(() => { - pools.navigateTo(); - pools.exist(poolName, true); - }); - images.navigateTo(); + beforeAll(async () => { + await pools.navigateTo('create'); // Need pool for image testing + await pools.create(poolName, 8, 'rbd'); + await pools.navigateTo(); + await pools.exist(poolName, true); + await images.navigateTo(); }); - it('should create image', () => { - images.createImage(imageName, poolName, '1'); - expect(images.getTableCell(imageName).isPresent()).toBe(true); + it('should create image', async () => { + await images.createImage(imageName, poolName, '1'); + expect(await images.getTableCell(imageName).isPresent()).toBe(true); }); - it('should edit image', () => { - images.editImage(imageName, poolName, newImageName, '2'); - expect(images.getTableCell(newImageName).isPresent()).toBe(true); + it('should edit image', async () => { + await images.editImage(imageName, poolName, newImageName, '2'); + expect(await images.getTableCell(newImageName).isPresent()).toBe(true); }); - it('should delete image', () => { - images.deleteImage(newImageName); - expect(images.getTableCell(newImageName).isPresent()).toBe(false); + it('should delete image', async () => { + await images.deleteImage(newImageName); + expect(await images.getTableCell(newImageName).isPresent()).toBe(false); }); - afterAll(() => { - pools.navigateTo(); // Deletes images test pool - pools.delete(poolName).then(() => { - pools.navigateTo(); - pools.exist(poolName, false); - }); + afterAll(async () => { + await pools.navigateTo(); // Deletes images test pool + await pools.delete(poolName); + await pools.navigateTo(); + await pools.exist(poolName, false); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts index eec5642f48b..f867f46462b 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts @@ -10,83 +10,71 @@ export class ImagesPageHelper extends PageHelper { // Creates a block image and fills in the name, pool, and size fields. Then checks // if the image is present in the Images table. - createImage(name, pool, size) { - this.navigateTo('create'); + async createImage(name, pool, size) { + await this.navigateTo('create'); // Need the string '[value=""]' to find the pool in the dropdown menu const getPoolName = `[value="${pool}"]`; - element(by.id('name')).sendKeys(name); // Enter in image name + await element(by.id('name')).sendKeys(name); // Enter in image name // Select image pool - element(by.id('pool')).click(); - element(by.cssContainingText('select[name=pool] option', pool)).click(); - $(getPoolName).click(); - expect(element(by.id('pool')).getAttribute('class')).toContain('ng-valid'); // check if selected + await element(by.id('pool')).click(); + await element(by.cssContainingText('select[name=pool] option', pool)).click(); + await $(getPoolName).click(); + expect(await element(by.id('pool')).getAttribute('class')).toContain('ng-valid'); // check if selected // Enter in the size of the image - element(by.id('size')).click(); - element(by.id('size')).sendKeys(size); + await element(by.id('size')).click(); + await element(by.id('size')).sendKeys(size); // Click the create button and wait for image to be made - element(by.cssContainingText('button', 'Create RBD')) - .click() - .then(() => { - browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT); - }); + await element(by.cssContainingText('button', 'Create RBD')).click(); + await browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT); } - editImage(name, pool, newName, newSize) { + async editImage(name, pool, newName, newSize) { const base_url = '/#/block/rbd/edit/'; const editURL = base_url .concat(pool) .concat('/') .concat(name); - browser.get(editURL); + await browser.get(editURL); - element(by.id('name')).click(); // click name box and send new name - element(by.id('name')).clear(); - element(by.id('name')).sendKeys(newName); - element(by.id('size')).click(); - element(by.id('size')).clear(); - element(by.id('size')).sendKeys(newSize); // click the size box and send new size + await element(by.id('name')).click(); // click name box and send new name + await element(by.id('name')).clear(); + await element(by.id('name')).sendKeys(newName); + await element(by.id('size')).click(); + await element(by.id('size')).clear(); + await element(by.id('size')).sendKeys(newSize); // click the size box and send new size - element(by.cssContainingText('button', 'Edit RBD')) - .click() - .then(() => { - this.navigateTo(); - browser - .wait(Helper.EC.elementToBeClickable(this.getTableCell(newName)), Helper.TIMEOUT) - .then(() => { - this.getTableCell(newName).click(); - expect( - element - .all(by.css('.table.table-striped.table-bordered')) - .first() - .getText() - ).toMatch(newSize); - }); // click edit button and wait to make sure new owner is present in table - }); + await element(by.cssContainingText('button', 'Edit RBD')).click(); + await this.navigateTo(); + await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(newName)), Helper.TIMEOUT); + // click edit button and wait to make sure new owner is present in table + await this.getTableCell(newName).click(); + expect( + await element + .all(by.css('.table.table-striped.table-bordered')) + .first() + .getText() + ).toMatch(newSize); } - deleteImage(name) { - this.navigateTo(); + async deleteImage(name) { + await this.navigateTo(); // wait for table to load - browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); - this.getTableCell(name).click(); // click on the image you want to delete in the table - $$('.table-actions button.dropdown-toggle') + await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); + await this.getTableCell(name).click(); // click on the image you want to delete in the table + await $$('.table-actions button.dropdown-toggle') .first() .click(); // click toggle menu - $('li.delete.ng-star-inserted').click(); // click delete + await $('li.delete.ng-star-inserted').click(); // click delete // wait for pop-up to be visible (checks for title of pop-up) - browser.wait(Helper.EC.visibilityOf($('.modal-body')), Helper.TIMEOUT).then(() => { - $('.custom-control-label').click(); // click confirmation checkbox - element(by.cssContainingText('button', 'Delete RBD')) - .click() - .then(() => { - browser.wait(Helper.EC.stalenessOf(this.getTableCell(name)), Helper.TIMEOUT); - }); - }); + await browser.wait(Helper.EC.visibilityOf($('.modal-body')), Helper.TIMEOUT); + await $('.custom-control-label').click(); // click confirmation checkbox + await element(by.cssContainingText('button', 'Delete RBD')).click(); + await browser.wait(Helper.EC.stalenessOf(this.getTableCell(name)), Helper.TIMEOUT); } }