WebformStatesCustomJavaScriptTest.php in Webform 6.x
File
tests/src/FunctionalJavascript/States/WebformStatesCustomJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript\States;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
class WebformStatesCustomJavaScriptTest extends WebformWebDriverTestBase {
protected static $testWebforms = [
'test_states_server_custom',
];
public function testCustomStates() {
$session = $this
->getSession();
$page = $session
->getPage();
$this
->drupalGet('/webform/test_states_server_custom');
$dependent_pattern = $page
->findField('edit-dependent-pattern');
$this
->assertFalse($dependent_pattern
->isVisible());
$page
->fillField('edit-trigger-pattern', 'a');
$this
->assertTrue($dependent_pattern
->isVisible());
$page
->fillField('edit-trigger-pattern', '1');
$this
->assertFalse($dependent_pattern
->isVisible());
$dependent_not_pattern = $page
->findField('edit-dependent-not-pattern');
$this
->assertFalse($dependent_not_pattern
->isVisible());
$page
->fillField('edit-trigger-not-pattern', 'a');
$this
->assertTrue($dependent_not_pattern
->isVisible());
$page
->fillField('edit-trigger-not-pattern', '');
$this
->assertFalse($dependent_not_pattern
->isVisible());
$dependent_less = $page
->findField('edit-dependent-less');
$this
->assertFalse($dependent_less
->isVisible());
$page
->fillField('edit-trigger-less', '5');
$this
->assertTrue($dependent_less
->isVisible());
$page
->fillField('edit-trigger-less', '11');
$this
->assertFalse($dependent_less
->isVisible());
$dependent_less_equal = $page
->findField('edit-dependent-less-equal');
$this
->assertFalse($dependent_less_equal
->isVisible());
$page
->fillField('edit-trigger-less-equal', '10');
$this
->assertTrue($dependent_less_equal
->isVisible());
$page
->fillField('edit-trigger-less-equal', '11');
$this
->assertFalse($dependent_less_equal
->isVisible());
$dependent_greater = $page
->findField('edit-dependent-greater');
$this
->assertFalse($dependent_greater
->isVisible());
$page
->fillField('edit-trigger-greater', '11');
$this
->assertTrue($dependent_greater
->isVisible());
$page
->fillField('edit-trigger-greater', '5');
$this
->assertFalse($dependent_greater
->isVisible());
$dependent_greater_equal = $page
->findField('edit-dependent-greater-equal');
$this
->assertFalse($dependent_greater_equal
->isVisible());
$page
->fillField('edit-trigger-greater-equal', '10');
$this
->assertTrue($dependent_greater_equal
->isVisible());
$page
->fillField('edit-trigger-greater-equal', '5');
$this
->assertFalse($dependent_greater_equal
->isVisible());
$dependent_between = $page
->findField('edit-dependent-between');
$dependent_not_between = $page
->findField('edit-dependent-not-between');
$this
->assertFalse($dependent_between
->isVisible());
$this
->assertFalse($dependent_not_between
->isVisible());
$page
->fillField('edit-trigger-between', '11');
$this
->assertTrue($dependent_between
->isVisible());
$this
->assertFalse($dependent_not_between
->isVisible());
$page
->fillField('edit-trigger-between', '5');
$this
->assertFalse($dependent_between
->isVisible());
$this
->assertTrue($dependent_not_between
->isVisible());
$page
->fillField('edit-trigger-between', '');
$this
->assertFalse($dependent_between
->isVisible());
$this
->assertFalse($dependent_not_between
->isVisible());
$page
->fillField('edit-trigger-between', '21');
$this
->assertFalse($dependent_between
->isVisible());
$this
->assertTrue($dependent_not_between
->isVisible());
}
}