You are here

public function PreviewTest::testPreviewContextual in Drupal 9

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

Tests contextual links in the preview form.

File

core/modules/views_ui/tests/src/Functional/PreviewTest.php, line 27

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testPreviewContextual() {
  \Drupal::service('module_installer')
    ->install([
    'contextual',
  ]);
  $this
    ->resetAll();
  $this
    ->drupalGet('admin/structure/views/view/test_preview/edit');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->submitForm($edit = [], 'Update preview');

  // Verify that the contextual link to add a new field is shown.
  $this
    ->assertSession()
    ->elementsCount('xpath', '//div[@id="views-live-preview"]//ul[contains(@class, "contextual-links")]/li[contains(@class, "filter-add")]', 1);
  $this
    ->submitForm($edit = [
    'view_args' => '100',
  ], 'Update preview');

  // Test that area text and exposed filters are present and rendered.
  $this
    ->assertSession()
    ->fieldExists('id');
  $this
    ->assertSession()
    ->pageTextContains('Test header text');
  $this
    ->assertSession()
    ->pageTextContains('Test footer text');
  $this
    ->assertSession()
    ->pageTextContains('Test empty text');
}