Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / inline_form_errors / tests / src / FunctionalJavascript / FormErrorHandlerQuickEditTest.php
1 <?php
2
3 namespace Drupal\Tests\inline_form_errors\FunctionalJavascript;
4
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
6 use Drupal\node\Entity\NodeType;
7
8 /**
9  * Tests Inline Form Errors compatibility with Quick Edit.
10  *
11  * @group inline_form_errors
12  */
13 class FormErrorHandlerQuickEditTest extends WebDriverTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = [
21     'quickedit',
22     'node',
23     'inline_form_errors',
24   ];
25
26   /**
27    * An editor user with permissions to access the in-place editor.
28    *
29    * @var \Drupal\user\UserInterface
30    */
31   protected $editorUser;
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function setUp() {
37     parent::setUp();
38
39     // Create a page node type for testing.
40     NodeType::create(['type' => 'page', 'name' => 'page'])->save();
41
42     // Create a user with the permission to use in-place editing.
43     $permissions = [
44       'access content',
45       'create page content',
46       'edit any page content',
47       'access contextual links',
48       'access in-place editing',
49     ];
50     $this->editorUser = $this->drupalCreateUser($permissions);
51     $this->drupalLogin($this->editorUser);
52   }
53
54   /**
55    * Tests that the inline form errors are not visible for Quick Edit forms.
56    */
57   public function testDisabledInlineFormErrors() {
58     $session = $this->getSession();
59     $web_assert = $this->assertSession();
60
61     // Create a page node.
62     $node = $this->drupalCreateNode();
63
64     // Visit the node page.
65     $this->drupalGet('node/' . $node->id());
66
67     // Wait until the quick edit link is available.
68     $web_assert->waitForElement('css', '.quickedit > a');
69
70     // Activate the quick editing mode.
71     $session->executeScript("jQuery('article.node').find('.quickedit > a').click()");
72
73     $web_assert->waitForElement('css', '.quickedit-toolbar');
74
75     // Clear the title field. Trigger a 'keyup' to be able to save the changes.
76     $session->executeScript("jQuery('.field--name-title').text('').trigger('keyup')");
77
78     // Try to save the changes.
79     $save_button = $web_assert->waitForElement('css', '.action-save.quickedit-button');
80     $save_button->click();
81
82     // Wait until the form submission is complete.
83     $web_assert->assertWaitOnAjaxRequest();
84
85     // Assert that no error summary from Inline Form Errors is shown.
86     $web_assert->elementTextNotContains('css', '.quickedit-validation-errors', '1 error has been found');
87
88     // Assert that the required title error is shown.
89     $web_assert->elementTextContains('css', '.quickedit-validation-errors', 'Title field is required.');
90   }
91
92 }