]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: migrate E2E configuration to async/await
authorPatrick Seidensal <pseidensal@suse.com>
Mon, 19 Aug 2019 12:02:13 +0000 (14:02 +0200)
committerPatrick Seidensal <pseidensal@suse.com>
Wed, 28 Aug 2019 07:38:48 +0000 (09:38 +0200)
Fixes: https://tracker.ceph.com/issues/40693
Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts

index 20dc1404ad793c4339b55a9ca7e857e98e6e4077..6ddbafbca98fc36536d7e65fe963c85ad6fa48dd 100644 (file)
@@ -7,28 +7,28 @@ describe('Configuration page', () => {
     configuration = new Helper().configuration;
   });
 
-  afterEach(() => {
-    Helper.checkConsole();
+  afterEach(async () => {
+    await Helper.checkConsole();
   });
 
   describe('breadcrumb test', () => {
-    beforeAll(() => {
-      configuration.navigateTo();
+    beforeAll(async () => {
+      await configuration.navigateTo();
     });
 
-    it('should open and show breadcrumb', () => {
-      expect(configuration.getBreadcrumbText()).toEqual('Configuration');
+    it('should open and show breadcrumb', async () => {
+      expect(await configuration.getBreadcrumbText()).toEqual('Configuration');
     });
   });
   describe('edit configuration test', () => {
-    beforeAll(() => {
-      configuration.navigateTo();
+    beforeAll(async () => {
+      await configuration.navigateTo();
     });
 
-    it('should click and edit a configuration and results should appear in the table', () => {
+    it('should click and edit a configuration and results should appear in the table', async () => {
       const configName = 'client_cache_size';
 
-      configuration.edit(
+      await configuration.edit(
         configName,
         ['global', '1'],
         ['mon', '2'],
@@ -37,7 +37,7 @@ describe('Configuration page', () => {
         ['mds', '5'],
         ['client', '6']
       );
-      configuration.configClear(configName);
+      await configuration.configClear(configName);
     });
   });
 });
index 374e2ad6ff619ddb6d226c1346907a66a5df4f7a..0091e9be8d89bf68dd5c08755d8691f30784284e 100644 (file)
@@ -7,118 +7,99 @@ export class ConfigurationPageHelper extends PageHelper {
     index: '/#/configuration'
   };
 
-  configClear(name) {
+  async configClear(name) {
     // Clears out all the values in a config to reset before and after testing
     // Does not work for configs with checkbox only, possible future PR
 
-    this.navigateTo();
+    await this.navigateTo();
     const valList = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']; // Editable values
 
     // Enter config setting name into filter box
-    $('input.form-control.ng-valid').clear();
-    $('input.form-control.ng-valid').sendKeys(name);
+    await $('input.form-control.ng-valid').clear();
+    await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to clear
-    browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
-    this.getTableCell(name).click(); // click on the config to edit
-    element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
+    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
+    await this.getTableCell(name).click(); // click on the config to edit
+    await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
     for (const i of valList) {
       // Sends two backspaces to all values, clear() did not work in this instance, could be optimized more
-      element(by.id(i)).sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
-      element(by.id(i)).sendKeys(protractor.Key.BACK_SPACE);
+      await element(by.id(i)).sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
+      await element(by.id(i)).sendKeys(protractor.Key.BACK_SPACE);
     }
     // Clicks save button and checks that values are not present for the selected config
-    element(by.cssContainingText('button', 'Save'))
-      .click()
-      .then(() => {
-        // Enter config setting name into filter box
-        $('input.form-control.ng-valid').clear();
-        $('input.form-control.ng-valid').sendKeys(name);
-
-        browser
-          .wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT)
-          .then(() => {
-            this.getTableCell(name)
-              .click()
-              .then(() => {
-                // Clicks desired config
-                browser.wait(
-                  Helper.EC.visibilityOf($('.table.table-striped.table-bordered')), // Checks for visibility of details tab
-                  Helper.TIMEOUT,
-                  'config details did not appear'
-                );
-                for (const i of valList) {
-                  // Waits until values are not present in the details table
-                  browser.wait(
-                    Helper.EC.not(
-                      Helper.EC.textToBePresentInElement(
-                        $('.table.table-striped.table-bordered'),
-                        i + ':'
-                      )
-                    ),
-                    Helper.TIMEOUT
-                  );
-                }
-              });
-          });
-      });
+    await element(by.cssContainingText('button', 'Save')).click();
+
+    // Enter config setting name into filter box
+    await $('input.form-control.ng-valid').clear();
+    await $('input.form-control.ng-valid').sendKeys(name);
+
+    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.getTableCell(name).click();
+    // Clicks desired config
+    await browser.wait(
+      Helper.EC.visibilityOf($('.table.table-striped.table-bordered')), // Checks for visibility of details tab
+      Helper.TIMEOUT,
+      'config details did not appear'
+    );
+    for (const i of valList) {
+      // Waits until values are not present in the details table
+      await browser.wait(
+        Helper.EC.not(
+          Helper.EC.textToBePresentInElement($('.table.table-striped.table-bordered'), i + ':')
+        ),
+        Helper.TIMEOUT
+      );
+    }
   }
 
-  edit(name, ...values: [string, string][]) {
+  async edit(name, ...values: [string, string][]) {
     // Clicks the designated config, then inputs the values passed into the edit function.
     // Then checks if the edit is reflected in the config table. Takes in name of config and
     // a list of tuples of values the user wants edited, each tuple having the desired value along
     // with the number tehey want for that value. Ex: [global, '2'] is the global value with an input of 2
-
-    this.navigateTo();
+    await this.navigateTo();
 
     // Enter config setting name into filter box
-    $('input.form-control.ng-valid').clear();
-    $('input.form-control.ng-valid').sendKeys(name);
+    await $('input.form-control.ng-valid').clear();
+    await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to edit
-    browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
-    this.getTableCell(name).click(); // click on the config to edit
-    element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
+    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
+    await this.getTableCell(name).click(); // click on the config to edit
+    await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
-    expect(this.getBreadcrumbText()).toEqual('Edit');
+    expect(await this.getBreadcrumbText()).toEqual('Edit');
 
     for (let i = 0, valtuple; (valtuple = values[i]); i++) {
       // Finds desired value based off given list
-      element(by.id(valtuple[0])).sendKeys(valtuple[1]); // of values and inserts the given number for the value
+      await element(by.id(valtuple[0])).sendKeys(valtuple[1]); // of values and inserts the given number for the value
     }
 
     // Clicks save button then waits until the desired config is visible, clicks it, then checks
     // that each desired value appears with the desired number
-    element(by.cssContainingText('button', 'Save'))
-      .click()
-      .then(() => {
-        this.navigateTo();
-
-        // Enter config setting name into filter box
-        $('input.form-control.ng-valid').clear();
-        $('input.form-control.ng-valid').sendKeys(name);
-
-        browser.wait(Helper.EC.visibilityOf(this.getTableCell(name)), Helper.TIMEOUT).then(() => {
-          // Checks for visibility of config in table
-          this.getTableCell(name)
-            .click()
-            .then(() => {
-              // Clicks config
-              for (let i = 0, valtuple; (valtuple = values[i]); i++) {
-                // iterates through list of values and
-                browser.wait(
-                  // checks if the value appears in details with the correct number attatched
-                  Helper.EC.textToBePresentInElement(
-                    $('.table.table-striped.table-bordered'),
-                    valtuple[0] + ': ' + valtuple[1]
-                  ),
-                  Helper.TIMEOUT
-                );
-              }
-            });
-        });
-      });
+    await element(by.cssContainingText('button', 'Save')).click();
+    await this.navigateTo();
+
+    // Enter config setting name into filter box
+    await $('input.form-control.ng-valid').clear();
+    await $('input.form-control.ng-valid').sendKeys(name);
+
+    await browser.wait(Helper.EC.visibilityOf(this.getTableCell(name)), Helper.TIMEOUT);
+    // Checks for visibility of config in table
+    await this.getTableCell(name).click();
+    // Clicks config
+    for (let i = 0, valtuple; (valtuple = values[i]); i++) {
+      // iterates through list of values and
+      await browser.wait(
+        // checks if the value appears in details with the correct number attatched
+        Helper.EC.textToBePresentInElement(
+          $('.table.table-striped.table-bordered'),
+          valtuple[0] + ': ' + valtuple[1]
+        ),
+        Helper.TIMEOUT
+      );
+    }
   }
 }