You are here

public function SettingsTrayBlockFormTest::testEditModeEnableDisable in Drupal 9

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

Tests enabling and disabling Edit Mode.

File

core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php, line 232

Class

SettingsTrayBlockFormTest
Testing opening and saving block forms in the off-canvas dialog.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

public function testEditModeEnableDisable() {
  foreach ($this
    ->getTestThemes() as $theme) {
    $this
      ->enableTheme($theme);
    $block = $this
      ->placeBlock('system_powered_by_block');
    foreach ([
      'contextual_link',
      'toolbar_link',
    ] as $enable_option) {
      $this
        ->drupalGet('user');
      $this
        ->assertEditModeDisabled();
      switch ($enable_option) {

        // Enable Edit mode.
        case 'contextual_link':
          $this
            ->clickContextualLink($this
            ->getBlockSelector($block), "Quick edit");
          $this
            ->waitForOffCanvasToOpen();
          $this
            ->assertEditModeEnabled();
          break;
        case 'toolbar_link':
          $this
            ->enableEditMode();
          break;
      }
      $this
        ->disableEditMode();

      // Make another page request to ensure Edit mode is still disabled.
      $this
        ->drupalGet('user');
      $this
        ->assertEditModeDisabled();

      // Make sure on this page request it also re-enables and disables
      // correctly.
      $this
        ->enableEditMode();
      $this
        ->disableEditMode();
    }
  }
}