WebformCardsAutoForwardJavaScriptTest.php in Webform 8.5
File
modules/webform_cards/tests/src/FunctionalJavaScript/WebformCardsAutoForwardJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform_cards\FunctionalJavaScript;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
class WebformCardsAutoForwardJavaScriptTest extends WebformWebDriverTestBase {
public static $modules = [
'webform',
'webform_cards',
'webform_cards_test',
'webform_image_select',
];
public function testAutoForward() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/webform/test_cards_auto_forward');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="textfield"]');
$this
->executeJqueryEvent('#edit-textfield', 'keydown', [
'which' => 13,
]);
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="radios_example"]');
$session
->executeScript('jQuery("#edit-radios-one").mouseup();');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="radios_other_example"]');
$session
->executeScript('jQuery("#edit-radios-other-radios-other-").mouseup();');
$assert_session
->waitForElement('css', '#edit-radios-other-other');
$this
->assertCssSelect('.webform-card--active[data-webform-key="radios_other_example"]');
$session
->executeScript('jQuery("#edit-radios-other-radios-one").mouseup();');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="scale"]');
$session
->executeScript('jQuery("#edit-scale-1").change();');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="rating"]');
$session
->executeScript("jQuery('#edit-rating').val('1').change()");
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="image_select"]');
$session
->executeScript("jQuery('#edit-image-select').val('kitten_1').change()");
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="radios_multiple"]');
$session
->executeScript('jQuery("#edit-radios-multiple-1-one, #edit-radios-multiple-1-two").mouseup();');
$page
->pressButton('edit-submit');
$assert_session
->pageTextContains('New submission added to Test: Webform: Cards auto-forward.');
$this
->drupalGet('/webform/test_cards_auto_forward_hide');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="radios_example"]');
$this
->assertElementNotVisible('#edit-cards-prev');
$this
->assertElementNotVisible('#edit-cards-next');
$this
->click('label[for="edit-radios-one"]');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="radios_other_example"]');
$this
->assertElementVisible('#edit-cards-prev');
$this
->assertElementNotVisible('#edit-cards-next');
$page
->pressButton('edit-cards-prev');
$assert_session
->waitForElementVisible('css', '#edit-cards-next');
$this
->assertElementVisible('#edit-cards-next');
}
}