You are here

public function ClaroViewsUiTest::testViewsUiDropButtonCssClasses in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php \Drupal\FunctionalJavascriptTests\Theme\ClaroViewsUiTest::testViewsUiDropButtonCssClasses()

Tests Views UI dropbutton CSS classes.

Ensures that the CSS classes added to the Views UI extra actions dropbutton in .views-display-top are preserved when Views UI is refreshed with AJAX.

File

core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php, line 70

Class

ClaroViewsUiTest
Runs tests on Views UI using Claro.

Namespace

Drupal\FunctionalJavascriptTests\Theme

Code

public function testViewsUiDropButtonCssClasses() {
  $this
    ->drupalGet('admin/structure/views/view/who_s_online');
  $assert_session = $this
    ->assertSession();
  $extra_actions_dropbutton_list = $assert_session
    ->elementExists('css', '#views-display-extra-actions.dropbutton--small');
  $list_item_selectors = [
    'li:first-child',
    'li:last-child',
  ];

  // Test list item CSS classes.
  foreach ($list_item_selectors as $list_item_selector) {
    $this
      ->assertNotNull($extra_actions_dropbutton_list
      ->find('css', "{$list_item_selector}.dropbutton__item.dropbutton__item--small"));
  }

  // Click on the Display name and wait for the Views UI dialog.
  $assert_session
    ->elementExists('css', '#edit-display-settings-top .views-display-setting a')
    ->click();
  $this
    ->assertNotNull($this
    ->assertSession()
    ->waitForElement('css', '.js-views-ui-dialog'));

  // Click the Apply button of the dialog.
  $assert_session
    ->elementExists('css', '.js-views-ui-dialog .ui-dialog-buttonpane')
    ->findButton('Apply')
    ->press();

  // Wait for AJAX to finish.
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();

  // Check that the drop button list still has the expected CSS classes.
  $this
    ->assertTrue($extra_actions_dropbutton_list
    ->hasClass('dropbutton--small'));

  // Check list item CSS classes.
  foreach ($list_item_selectors as $list_item_selector) {
    $this
      ->assertNotNull($extra_actions_dropbutton_list
      ->find('css', "{$list_item_selector}.dropbutton__item.dropbutton__item--small"));
  }
}