WebformElementSignatureJavaScriptTest.php in Webform 8.5
File
tests/src/FunctionalJavascript/Element/WebformElementSignatureJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript\Element;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
use Drupal\webform\Entity\Webform;
class WebformElementSignatureJavaScriptTest extends WebformWebDriverTestBase {
protected static $testWebforms = [
'test_element_signature',
];
public function testComputedElementAjax() {
$session = $this
->getSession();
$page = $session
->getPage();
$webform = Webform::load('test_element_signature');
$this
->drupalGet($webform
->toUrl());
$this
->assertTrue($page
->find('css', '#edit-signature input[type="submit"]')
->isVisible());
$this
->assertFalse($page
->find('css', '#edit-signature-disabled input[type="submit"]')
->isVisible());
$this
->assertFalse($page
->find('css', '#edit-signature-readonly input[type="submit"]')
->isVisible());
$this
->click('#edit-disable');
$this
->assertFalse($page
->find('css', '#edit-signature input[type="submit"]')
->isVisible());
$this
->click('#edit-disable');
$this
->assertTrue($page
->find('css', '#edit-signature input[type="submit"]')
->isVisible());
$this
->click('#edit-readonly');
$this
->assertFalse($page
->find('css', '#edit-signature input[type="submit"]')
->isVisible());
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/webform/test_element_signature/test');
$this
->assertTrue($page
->find('css', '#edit-signature input[type="submit"]')
->isVisible());
$this
->assertRaw('<input data-drupal-selector="edit-signature" aria-describedby="edit-signature--description" type="hidden" name="signature" value="data:image/png;base64');
$this
->click('#edit-signature input[type="submit"]');
$this
->assertNoRaw('<input data-drupal-selector="edit-signature" aria-describedby="edit-signature--description" type="hidden" name="signature" value="data:image/png;base64');
}
}