You are here

protected function SettingsTrayTestBase::assertEditModeEnabled 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::assertEditModeEnabled()
  2. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::assertEditModeEnabled()

Assert that edit mode has been properly enabled.

File

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

Class

SettingsTrayTestBase
Base class for Settings Tray tests.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

protected function assertEditModeEnabled() {
  $web_assert = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();

  // Move the mouse over the toolbar button so that isn't over a contextual
  // links area which cause the contextual link to be shown.
  $page
    ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)
    ->mouseOver();
  $this
    ->assertTrue($page
    ->waitFor(10, function ($page) {
    return !$page
      ->find('css', '.contextual .trigger.visually-hidden');
  }));

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

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

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