function FormGroupingElementsTest::testDetailsContainsRequiredTextfieldAjaxForm

Same name in other branches
  1. 11.x core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php \Drupal\FunctionalJavascriptTests\Core\Form\FormGroupingElementsTest::testDetailsContainsRequiredTextfieldAjaxForm()

Tests required field in closed details element with ajax form.

File

core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php, line 194

Class

FormGroupingElementsTest
Tests for form grouping elements.

Namespace

Drupal\FunctionalJavascriptTests\Core\Form

Code

public function testDetailsContainsRequiredTextfieldAjaxForm() : void {
    $this->drupalGet('form_test/details-contains-required-textfield/true');
    $assert_session = $this->assertSession();
    $textfield = $assert_session->elementExists('css', 'input[name="required_textfield_in_details"]');
    // Submit the ajax form to open the details element at the first time.
    $assert_session->elementExists('css', 'input[value="Submit Ajax"]')
        ->click();
    $assert_session->waitForElementVisible('css', 'input[name="required_textfield_in_details"]');
    // Close the details element.
    $assert_session->elementExists('css', 'form summary')
        ->click();
    // Submit the form with invalid data in the required fields without ajax.
    $assert_session->elementExists('css', 'input[data-drupal-selector="edit-submit"]')
        ->click();
    // Confirm the required field is visible.
    $this->assertTrue($textfield->isVisible(), 'Text field is visible');
}

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