WebformSettingsAjaxTest.php in Webform 8.5
File
tests/src/Functional/Settings/WebformSettingsAjaxTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Settings;
use Drupal\Tests\webform_node\Traits\WebformNodeBrowserTestTrait;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformSettingsAjaxTest extends WebformBrowserTestBase {
use WebformNodeBrowserTestTrait;
public static $modules = [
'webform',
'webform_node',
];
public function testAjax() {
$webform = Webform::load('contact');
$this
->drupalGet('/webform/contact');
$this
->assertNoRaw('<div id="webform-submission-contact-form-ajax" class="webform-ajax-form-wrapper" data-effect="fade" data-progress-type="throbber">');
$this
->assertNoCssSelect('#webform-submission-contact-form-ajax');
$webform
->setSetting('ajax', TRUE);
$webform
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('<div id="webform-submission-contact-form-ajax" class="webform-ajax-form-wrapper" data-effect="fade" data-progress-type="throbber">');
$this
->assertCssSelect('#webform-submission-contact-form-ajax');
$this
->assertRaw('"effect":"fade","speed":500');
$webform
->setSetting('ajax', FALSE);
$webform
->save();
$this
->drupalGet('/webform/contact');
$this
->assertNoRaw('<div id="webform-submission-contact-form-ajax" class="webform-ajax-form-wrapper" data-effect="fade" data-progress-type="throbber">');
\Drupal::configFactory()
->getEditable('webform.settings')
->set('settings.default_ajax', TRUE)
->set('settings.default_ajax_progress_type', 'fullscreen')
->set('settings.default_ajax_effect', 'slide')
->set('settings.default_ajax_speed', 1500)
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('<div id="webform-submission-contact-form-ajax" class="webform-ajax-form-wrapper" data-effect="slide" data-progress-type="fullscreen">');
$this
->assertRaw('"effect":"slide","speed":1500');
$node = $this
->createWebformNode('contact');
$this
->drupalGet('/node/' . $node
->id());
$this
->assertNoCssSelect('#webform-submission-contact-form-ajax');
$this
->assertCssSelect('#webform-submission-contact-node-' . $node
->id() . '-form-ajax-content');
}
}