function RedirectAjaxTest::testRedirectWithAjax

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/FunctionalJavascript/RedirectAjaxTest.php \Drupal\Tests\views\FunctionalJavascript\RedirectAjaxTest::testRedirectWithAjax()

Ensures that redirects work with ajax.

File

core/modules/views/tests/src/FunctionalJavascript/RedirectAjaxTest.php, line 56

Class

RedirectAjaxTest
Tests that the redirects work with Ajax enabled views.

Namespace

Drupal\Tests\views\FunctionalJavascript

Code

public function testRedirectWithAjax() : void {
  $this->drupalGet('admin/content');
  $original_url = $this->getSession()
    ->getCurrentUrl();
  $this->assertSession()
    ->pageTextContains('Tiny paws and playful mews, kittens bring joy in every hue');
  $this->submitForm([
    'title' => 'Kittens',
  ], 'Filter');
  $this->assertSession()
    ->assertWaitOnAjaxRequest();
  $this->assertSession()
    ->pageTextContains('Tiny paws and playful mews, kittens bring joy in every hue');
  $this->getSession()
    ->getPage()
    ->find('css', '.dropbutton-toggle button')
    ->click();
  $this->clickLink('Delete');
  $this->assertSession()
    ->assertWaitOnAjaxRequest();
  $this->assertEquals('Are you sure you want to delete the content item Tiny paws and playful mews, kittens bring joy in every hue?', $this->assertSession()
    ->waitForElement('css', '.ui-dialog-title')
    ->getText());
  $this->getSession()
    ->getPage()
    ->find('css', '.ui-dialog-buttonset')
    ->pressButton('Delete');
  $this->assertSession()
    ->pageTextContains('The Article Tiny paws and playful mews, kittens bring joy in every hue has been deleted.');
  $this->assertStringStartsWith($original_url, $this->getSession()
    ->getCurrentUrl());
  $this->assertSession()
    ->responseContains('core/modules/views/css/views.module.css');
}

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