function NodePreviewLinkTest::testPreviewLinks
Same name in other branches
- 8.9.x core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php \Drupal\Tests\node\FunctionalJavascript\NodePreviewLinkTest::testPreviewLinks()
- 10 core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php \Drupal\Tests\node\FunctionalJavascript\NodePreviewLinkTest::testPreviewLinks()
- 11.x core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php \Drupal\Tests\node\FunctionalJavascript\NodePreviewLinkTest::testPreviewLinks()
Tests the behavior of clicking preview links.
File
-
core/
modules/ node/ tests/ src/ FunctionalJavascript/ NodePreviewLinkTest.php, line 51
Class
- NodePreviewLinkTest
- Tests the JavaScript prevention of navigation away from node previews.
Namespace
Drupal\Tests\node\FunctionalJavascriptCode
public function testPreviewLinks() {
$assertSession = $this->assertSession();
$this->drupalGet('node/add/test');
$this->submitForm([
'title[0][value]' => 'Test node',
'body[0][value]' => '<a href="#foo">Anchor link</a><a href="/foo">Normal link</a>',
], 'Preview');
$this->clickLink('Anchor link');
$assertSession->pageTextNotContains('Leave preview?');
$this->clickLink('Normal link');
$assertSession->pageTextContains('Leave preview?');
$this->click('button:contains("Leave preview")');
$this->assertStringEndsWith('/foo', $this->getUrl());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.