You are here

public function PreviewTest::testPreviewSortLink in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php \Drupal\Tests\views_ui\FunctionalJavascript\PreviewTest::testPreviewSortLink()

Tests the link to sort in the preview form.

File

core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php, line 229

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\Tests\views_ui\FunctionalJavascript

Code

public function testPreviewSortLink() {

  // Get the preview.
  $this
    ->getPreviewAJAX('test_click_sort_ajax', 'page_1', 0);

  // Test that the header label is present.
  $element = $this
    ->assertSession()
    ->elementExists('xpath', '//th[contains(@class, "views-field views-field-name")]/a');

  // Verify link.
  $this
    ->assertSession()
    ->linkByHrefExists('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=desc', 0, 'The output URL is as expected.');

  // Click link to sort.
  $element
    ->click();
  $sort_link = $this
    ->assertSession()
    ->waitForElement('xpath', '//th[contains(@class, \'views-field views-field-name is-active\')]/a');
  $this
    ->assertNotEmpty($sort_link);

  // Verify link.
  $this
    ->assertSession()
    ->linkByHrefExists('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=asc', 0, 'The output URL is as expected.');
}