function PreviewTest::testPreviewSortLink

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php \Drupal\Tests\views_ui\FunctionalJavascript\PreviewTest::testPreviewSortLink()
  2. 8.9.x core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php \Drupal\Tests\views_ui\FunctionalJavascript\PreviewTest::testPreviewSortLink()
  3. 11.x 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 232

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\Tests\views_ui\FunctionalJavascript

Code

public function testPreviewSortLink() : void {
    // 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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.