comparison core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php
2
3 namespace Drupal\Tests\node\FunctionalJavascript;
4
5 use Drupal\filter\Entity\FilterFormat;
6 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
7
8 /**
9 * Tests the JavaScript prevention of navigation away from node previews.
10 *
11 * @group node
12 */
13 class NodePreviewLinkTest extends WebDriverTestBase {
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $modules = ['node', 'filter'];
19
20 /**
21 * {@inheritdoc}
22 */
23 public function setUp() {
24 parent::setUp();
25
26 $filtered_html_format = FilterFormat::create([
27 'format' => 'filtered_html',
28 'name' => 'Filtered HTML',
29 ]);
30 $filtered_html_format->save();
31
32 $this->drupalCreateContentType(['type' => 'test']);
33
34 $user = $this->drupalCreateUser([
35 'access content',
36 'edit own test content',
37 'create test content',
38 $filtered_html_format->getPermissionName(),
39 ]);
40 $this->drupalLogin($user);
41 }
42
43 /**
44 * Test the behavior of clicking preview links.
45 */
46 public function testPreviewLinks() {
47 $assertSession = $this->assertSession();
48 $this->drupalPostForm('node/add/test', [
49 'title[0][value]' => 'Test node',
50 'body[0][value]' => '<a href="#foo">Anchor link</a><a href="/foo">Normal link</a>',
51 ], t('Preview'));
52 $this->clickLink('Anchor link');
53 $assertSession->pageTextNotContains('Leave preview?');
54 $this->clickLink('Normal link');
55 $assertSession->pageTextContains('Leave preview?');
56 $this->click('button:contains("Leave preview")');
57 $this->assertStringEndsWith('/foo', $this->getUrl());
58 }
59
60 }