You are here

protected function SettingsTrayTestBase::assertEditModeDisabled in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::assertEditModeDisabled()
  2. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::assertEditModeDisabled()

Assert that edit mode has been properly disabled.

File

core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php, line 92

Class

SettingsTrayTestBase
Base class for Settings Tray tests.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

protected function assertEditModeDisabled() {
  $web_assert = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->getSession()
    ->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')");
  $page
    ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)
    ->mouseOver();
  $this
    ->assertTrue($page
    ->waitFor(10, function ($page) {
    return !$page
      ->find('css', '.contextual .trigger:not(.visually-hidden)');
  }));

  // Contextual triggers should be hidden.
  $web_assert
    ->elementExists('css', '.contextual .trigger.visually-hidden');

  // No contextual triggers should be not hidden.
  $web_assert
    ->elementNotExists('css', '.contextual .trigger:not(.visually-hidden)');

  // The toolbar edit button should read "Edit".
  $web_assert
    ->elementContains('css', static::TOOLBAR_EDIT_LINK_SELECTOR, 'Edit');

  // The main canvas element should NOT have the "js-settings-tray-edit-mode"
  // class.
  $web_assert
    ->elementNotExists('css', '.dialog-off-canvas-main-canvas.js-settings-tray-edit-mode');
}