WebformCardsStatesJavaScriptTest.php in Webform 8.5
File
modules/webform_cards/tests/src/FunctionalJavaScript/WebformCardsStatesJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform_cards\FunctionalJavaScript;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
class WebformCardsStatesJavaScriptTest extends WebformWebDriverTestBase {
public static $modules = [
'webform',
'webform_cards',
'webform_cards_test',
];
public function testStates() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/webform/test_cards_states');
$this
->assertElementVisible('[data-webform-card="start"][title="Start"]');
$this
->assertElementVisible('[data-webform-card="card_1"][title="Card 1"]');
$this
->assertElementVisible('[data-webform-card="card_2"][title="Card 2"]');
$this
->assertElementVisible('[data-webform-card="card_3"][title="Card 3"]');
$this
->assertElementVisible('[data-webform-card="card_4"][title="Card 4"]');
$this
->assertElementVisible('[data-webform-card="card_5"][title="Card 5"]');
$this
->assertElementVisible('[data-webform-page="webform_preview"][title="Preview"]');
$this
->assertElementVisible('[data-webform-page="webform_confirmation"][title="Complete"]');
$this
->assertCssSelect('.webform-card--active[data-webform-key="start"]');
$page
->pressButton('edit-cards-next');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="card_1"]');
$this
->assertCssSelect('.webform-card--active[data-webform-key="card_1"]');
$page
->pressButton('edit-cards-prev');
$this
->click('#edit-trigger-cards-card-1');
$this
->click('#edit-trigger-cards-card-3');
$this
->click('#edit-trigger-cards-card-5');
$this
->assertElementNotVisible('[data-webform-card="card_1"][title="Card 1"]');
$this
->assertElementNotVisible('[data-webform-card="card_3"][title="Card 3"]');
$this
->assertElementNotVisible('[data-webform-card="card_5"][title="Card 5"]');
$page
->pressButton('edit-cards-next');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="card_2"]');
$this
->assertCssSelect('.webform-card--active[data-webform-key="card_2"]');
$page
->pressButton('edit-cards-prev');
$this
->click('#edit-trigger-cards-card-1');
$this
->click('#edit-trigger-cards-card-3');
$this
->click('#edit-trigger-cards-card-5');
$this
->assertElementVisible('[data-webform-card="card_1"][title="Card 1"]');
$this
->assertElementVisible('[data-webform-card="card_3"][title="Card 3"]');
$this
->assertElementVisible('[data-webform-card="card_5"][title="Card 5"]');
$page
->pressButton('edit-cards-next');
$assert_session
->waitForElement('css', '.webform-card--active[data-webform-key="card_1"]');
$this
->assertCssSelect('.webform-card--active[data-webform-key="card_1"]');
}
}