3 namespace Drupal\Tests\inline_form_errors\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
6 use Drupal\node\Entity\NodeType;
9 * Tests Inline Form Errors compatibility with Quick Edit.
11 * @group inline_form_errors
13 class FormErrorHandlerQuickEditTest extends WebDriverTestBase {
20 public static $modules = [
27 * An editor user with permissions to access the in-place editor.
29 * @var \Drupal\user\UserInterface
31 protected $editorUser;
36 protected function setUp() {
39 // Create a page node type for testing.
40 NodeType::create(['type' => 'page', 'name' => 'page'])->save();
42 // Create a user with the permission to use in-place editing.
45 'create page content',
46 'edit any page content',
47 'access contextual links',
48 'access in-place editing',
50 $this->editorUser = $this->drupalCreateUser($permissions);
51 $this->drupalLogin($this->editorUser);
55 * Tests that the inline form errors are not visible for Quick Edit forms.
57 public function testDisabledInlineFormErrors() {
58 $session = $this->getSession();
59 $web_assert = $this->assertSession();
61 // Create a page node.
62 $node = $this->drupalCreateNode();
64 // Visit the node page.
65 $this->drupalGet('node/' . $node->id());
67 // Wait until the quick edit link is available.
68 $web_assert->waitForElement('css', '.quickedit > a');
70 // Activate the quick editing mode.
71 $session->executeScript("jQuery('article.node').find('.quickedit > a').click()");
73 $web_assert->waitForElement('css', '.quickedit-toolbar');
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')");
78 // Try to save the changes.
79 $save_button = $web_assert->waitForElement('css', '.action-save.quickedit-button');
80 $save_button->click();
82 // Wait until the form submission is complete.
83 $web_assert->assertWaitOnAjaxRequest();
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');
88 // Assert that the required title error is shown.
89 $web_assert->elementTextContains('css', '.quickedit-validation-errors', 'Title field is required.');