WebformElementComputedJavaScriptTest.php in Webform 8.5
File
tests/src/FunctionalJavascript/Element/WebformElementComputedJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript\Element;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
use Drupal\webform\Entity\Webform;
class WebformElementComputedJavaScriptTest extends WebformWebDriverTestBase {
protected static $testWebforms = [
'test_element_computed_ajax',
];
public function testComputedElementAjax() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$webform = Webform::load('test_element_computed_ajax');
$this
->drupalGet($webform
->toUrl());
$assert_session
->fieldExists('a[select]');
$assert_session
->fieldExists('b');
$assert_session
->buttonExists('webform-computed-webform_computed_twig-button');
$assert_session
->hiddenFieldValueEquals('webform_computed_twig', 'Please enter a value for a and b.');
$page
->fillField('a[select]', '1');
$page
->fillField('b', '1');
$session
->executeScript("jQuery('input[name=\"webform_computed_twig\"]').click()");
$assert_session
->waitForText('1 + 1 = 2');
$assert_session
->hiddenFieldValueNotEquals('webform_computed_twig', 'Please enter a value for a and b.');
$assert_session
->hiddenFieldValueEquals('webform_computed_twig', '1 + 1 = 2');
}
}