protected function JavascriptStatesTest::doMultipleTriggerTests in Drupal 9
Tests states of elements triggered by multiple elements.
1 call to JavascriptStatesTest::doMultipleTriggerTests()
- JavascriptStatesTest::testJavascriptStates in core/
tests/ Drupal/ FunctionalJavascriptTests/ Core/ Form/ JavascriptStatesTest.php - Tests the JavaScript #states functionality of form elements.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ Core/ Form/ JavascriptStatesTest.php, line 304
Class
- JavascriptStatesTest
- Tests the state of elements based on another elements.
Namespace
Drupal\FunctionalJavascriptTests\Core\FormCode
protected function doMultipleTriggerTests() {
$this
->drupalGet('form-test/javascript-states-form');
$page = $this
->getSession()
->getPage();
// Find trigger and target elements.
$select_trigger = $page
->findField('select_trigger');
$this
->assertNotEmpty($select_trigger);
$textfield_trigger = $page
->findField('textfield_trigger');
$this
->assertNotEmpty($textfield_trigger);
$item_visible_value2_and_textfield = $this
->assertSession()
->elementExists('css', '#edit-item-visible-when-select-trigger-has-value2-and-textfield-trigger-filled');
// Verify initial state.
$this
->assertFalse($item_visible_value2_and_textfield
->isVisible());
// Change state: select the 'Value 2' option.
$select_trigger
->setValue('value2');
$this
->assertFalse($item_visible_value2_and_textfield
->isVisible());
// Change state: fill the textfield.
$textfield_trigger
->setValue('filled');
$this
->assertTrue($item_visible_value2_and_textfield
->isVisible());
}