Verified Commit 36c79386 authored by Dave Long's avatar Dave Long
Browse files

Issue #3413135 by Spokje: Replace deprecated functions in Nightwatch tests

(cherry picked from commit 95348401)
parent 90632d16
Loading
Loading
Loading
Loading
Loading
+31 −10
Original line number Diff line number Diff line
@@ -33,13 +33,19 @@ module.exports = {
          '[data-drupal-selector="edit-editor-settings-toolbar"]',
        )
        .click('.ckeditor5-toolbar-button-sourceEditing') // Select the Source Editing button.
        .keys(browser.Keys.DOWN) // Hit the down arrow key to move it to the toolbar.
        // Hit the down arrow key to move it to the toolbar.
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ARROW_DOWN);
        })
        // Wait for new source editing vertical tab to be present before continuing.
        .waitForElementVisible(
          '[href*=edit-editor-settings-plugins-ckeditor5-sourceediting]',
        )
        .click('.ckeditor5-toolbar-item-codeBlock') // Select the Code Block button.
        .keys(browser.Keys.DOWN) // Hit the down arrow key to move it to the toolbar.
        // Hit the down arrow key to move it to the toolbar.
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ARROW_DOWN);
        })
        // Wait for new code editing vertical tab to be present before continuing.
        .waitForElementVisible(
          '[href*=edit-editor-settings-plugins-ckeditor5-codeblock]',
@@ -73,11 +79,11 @@ module.exports = {
        .click(
          '.ck-code-block-dropdown .ck-dropdown__button .ck-splitbutton__arrow',
        )
        .assert.containsText(
        .assert.textContains(
          '.ck-code-block-dropdown .ck-dropdown__panel .ck-list__item:nth-child(1) .ck-button__label',
          'Twig',
        )
        .assert.containsText(
        .assert.textContains(
          '.ck-code-block-dropdown .ck-dropdown__panel .ck-list__item:nth-child(2) .ck-button__label',
          'YML',
        )
@@ -87,7 +93,10 @@ module.exports = {
          '.ck-code-block-dropdown .ck-dropdown__panel .ck-list__item:nth-child(1) button',
        )
        .waitForElementVisible('.ck-editor__main pre[data-language="Twig"]')
        .keys('x') // Press 'X' to ensure there's data in CKEditor before switching to source view.
        // Press 'X' to ensure there's data in CKEditor before switching to source view.
        .perform(function () {
          return this.actions().sendKeys('x');
        })
        .pause(50)

        // Go into source editing and verify that correct CSS class is added.
@@ -101,15 +110,24 @@ module.exports = {
        // Go back into WYSIWYG mode and hit enter three times to break out of code block.
        .click('.ck-source-editing-button') // Disable source editing.
        .waitForElementVisible('.ck-editor__editable:not(.ck-hidden)')
        .keys(browser.Keys.RIGHT) // Go to end of line.
        // Go to end of line.
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ARROW_RIGHT);
        })
        .pause(50)

        // Hit Enter three times to break out of CKEditor's code block.
        .keys(browser.Keys.ENTER)
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ENTER);
        })
        .pause(50)
        .keys(browser.Keys.ENTER)
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ENTER);
        })
        .pause(50)
        .keys(browser.Keys.ENTER)
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ENTER);
        })
        .pause(50)

        // Open up the code syntax dropdown, and click the 2nd item (which should be 'YML').
@@ -119,7 +137,10 @@ module.exports = {
        .click(
          '.ck-code-block-dropdown .ck-dropdown__panel .ck-list__item:nth-child(2) button',
        )
        .keys('x') // Press 'X' to ensure there's data in CKEditor before switching to source view.
        // Press 'X' to ensure there's data in CKEditor before switching to source view.
        .perform(function () {
          return this.actions().sendKeys('x');
        })

        // Go into source editing and verify that correct CSS class is added.
        .click('.ck-source-editing-button')
+4 −1
Original line number Diff line number Diff line
@@ -28,7 +28,10 @@ module.exports = {
          '[data-drupal-selector="edit-editor-settings-toolbar"]',
        )
        .click('.ckeditor5-toolbar-button-sourceEditing') // Select the Source Editing button.
        .keys(browser.Keys.DOWN) // Hit the down arrow key to move it to the toolbar.
        // Hit the down arrow key to move it to the toolbar.
        .perform(function () {
          return this.actions().sendKeys(browser.Keys.ARROW_DOWN);
        })
        // Wait for new source editing vertical tab to be present before continuing.
        .waitForElementVisible(
          '[href*=edit-editor-settings-plugins-ckeditor5-sourceediting]',
+13 −13
Original line number Diff line number Diff line
@@ -51,47 +51,47 @@ module.exports = {
      .drupalRelativeURL('/admin/appearance/settings/olivero')
      .waitForElementVisible(selectors.schemePicker)
      .click(`${selectors.schemePicker} option[value="firehouse"]`)
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.text,
        colorSchemes.firehouse.base_primary_color,
      )
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.color,
        colorSchemes.firehouse.base_primary_color,
      )
      .click(`${selectors.schemePicker} option[value="ice"]`)
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.text,
        colorSchemes.ice.base_primary_color,
      )
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.color,
        colorSchemes.ice.base_primary_color,
      )
      .click(`${selectors.schemePicker} option[value="plum"]`)
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.text,
        colorSchemes.plum.base_primary_color,
      )
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.color,
        colorSchemes.plum.base_primary_color,
      )
      .click(`${selectors.schemePicker} option[value="slate"]`)
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.text,
        colorSchemes.slate.base_primary_color,
      )
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.color,
        colorSchemes.slate.base_primary_color,
      )
      .click(`${selectors.schemePicker} option[value="default"]`)
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.text,
        colorSchemes.default.base_primary_color,
      )
      .assert.value(
      .assert.valueEquals(
        selectors.primaryColor.color,
        colorSchemes.default.base_primary_color,
      );
@@ -102,11 +102,11 @@ module.exports = {
      .waitForElementVisible(selectors.primaryColor.text)
      .waitForElementVisible(selectors.primaryColor.color)
      .updateValue(selectors.primaryColor.text, '#ff0000')
      .assert.value(selectors.primaryColor.color, '#ff0000')
      .assert.valueEquals(selectors.primaryColor.color, '#ff0000')
      .updateValue(selectors.primaryColor.text, '#00ff00')
      .assert.value(selectors.primaryColor.color, '#00ff00')
      .assert.valueEquals(selectors.primaryColor.color, '#00ff00')
      .updateValue(selectors.primaryColor.text, '#0000ff')
      .assert.value(selectors.primaryColor.color, '#0000ff');
      .assert.valueEquals(selectors.primaryColor.color, '#0000ff');
  },
  'Olivero Settings - color selections impact olivero theme': (browser) => {
    browser
+24 −8
Original line number Diff line number Diff line
@@ -13,9 +13,15 @@ const buttonSubMenuId = 'primary-menu-item-12';
 * @param {boolean} [tabBackwards] - Hold down the SHIFT key when sending tabs
 */
const focusTrapCheck = (browser, parentSelector, tabCount, tabBackwards) => {
  if (tabBackwards === true) browser.keys(browser.Keys.SHIFT);
  if (tabBackwards === true) {
    browser.perform(function () {
      return this.actions().keyDown(browser.Keys.SHIFT);
    });
  }
  for (let i = 0; i < tabCount; i++) {
    browser.keys(browser.Keys.TAB).pause(50);
    browser.perform(function () {
      return this.actions().sendKeys(browser.Keys.TAB).pause(50);
    });
  }
  browser
    .execute(
@@ -29,8 +35,10 @@ const focusTrapCheck = (browser, parentSelector, tabCount, tabBackwards) => {
        browser.assert.ok(result.value);
      },
    )
    // Release all keys.
    .keys(browser.Keys.NULL);
    // Release SHIFT key.
    .perform(function () {
      return this.actions().keyUp(browser.Keys.SHIFT);
    });
};

module.exports = {
@@ -107,7 +115,9 @@ module.exports = {
      .waitForElementVisible(`[aria-controls="${linkSubMenuId}"]`)
      .click(`[aria-controls="${linkSubMenuId}"]`)
      .waitForElementVisible(`#${linkSubMenuId}`)
      .keys(browser.Keys.TAB)
      .perform(function () {
        return this.actions().sendKeys(browser.Keys.TAB);
      })
      .pause(50)
      .execute(
        // eslint-disable-next-line func-names, prefer-arrow-callback, no-shadow
@@ -119,7 +129,9 @@ module.exports = {
          browser.assert.ok(result.value);
        },
      )
      .keys(browser.Keys.ESCAPE)
      .perform(function () {
        return this.actions().sendKeys(browser.Keys.ESCAPE);
      })
      .pause(50)
      .execute(
        // eslint-disable-next-line func-names, prefer-arrow-callback, no-shadow
@@ -136,7 +148,9 @@ module.exports = {
      // Verify functionality on route:<button> button.
      .click(`[aria-controls="${buttonSubMenuId}"]`)
      .waitForElementVisible(`#${buttonSubMenuId}`)
      .keys(browser.Keys.TAB)
      .perform(function () {
        return this.actions().sendKeys(browser.Keys.TAB);
      })
      .pause(50)
      .execute(
        // eslint-disable-next-line func-names, prefer-arrow-callback, no-shadow
@@ -148,7 +162,9 @@ module.exports = {
          browser.assert.ok(result.value);
        },
      )
      .keys(browser.Keys.ESCAPE)
      .perform(function () {
        return this.actions().sendKeys(browser.Keys.ESCAPE);
      })
      .pause(50)
      .execute(
        // eslint-disable-next-line func-names, prefer-arrow-callback, no-shadow
+12 −5
Original line number Diff line number Diff line
@@ -73,16 +73,23 @@ module.exports = {
        },
      )
      // Assert that search form is still visible when focus is on disclosure button.
      .keys(browser.Keys.SHIFT)
      .keys(browser.Keys.TAB)
      .perform(function () {
        return this.actions()
          .keyDown(browser.Keys.SHIFT)
          .sendKeys(browser.Keys.TAB);
      })
      .pause(50)
      .isVisible(searchWideSelector)
      // Assert that search form is NOT visible when focus moves back to menu item.
      .keys(browser.Keys.TAB)
      .perform(function () {
        return this.actions().sendKeys(browser.Keys.TAB);
      })
      .pause(50)
      .waitForElementNotVisible(searchWideSelector)
      // Release all keys.
      .keys(browser.Keys.NULL);
      // Release SHIFT key.
      .perform(function () {
        return this.actions().keyUp(browser.Keys.SHIFT);
      });
  },
  'search narrow form is accessible': (browser) => {
    browser
Loading