public function WebformWizardBasicJavaScriptTest::testBasicWizard in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/FunctionalJavascript/Wizard/WebformWizardBasicJavaScriptTest.php \Drupal\Tests\webform\FunctionalJavascript\Wizard\WebformWizardBasicJavaScriptTest::testBasicWizard()
Test webform basic wizard.
File
- tests/
src/ FunctionalJavascript/ Wizard/ WebformWizardBasicJavaScriptTest.php, line 25
Class
- WebformWizardBasicJavaScriptTest
- Tests for webform basic wizard.
Namespace
Drupal\Tests\webform\FunctionalJavascript\WizardCode
public function testBasicWizard() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$webform = Webform::load('test_form_wizard_basic');
/**************************************************************************/
// Check page 1 URL.
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertQuery();
// Check page 2 URL.
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery();
// Enable tracking by name.
$webform
->setSetting('wizard_track', 'name')
->save();
// Check page 1 URL with ?page=*.
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertQuery();
// Check page 2 URL with ?page=2.
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery('page=page_2');
// Check page 1 URL with ?page=1.
$page
->pressButton('edit-wizard-prev');
$assert_session
->waitForText('Element 1');
$this
->assertQuery('page=page_1');
// Check page 1 URL with custom param.
$this
->drupalGet('/webform/test_form_wizard_basic', [
'query' => [
'custom_param' => '1',
],
]);
$this
->assertRaw('Element 1');
$this
->assertQuery('custom_param=1');
// Check page 2 URL with ?page=2.
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery('custom_param=1&page=page_2');
// Check page 1 URL with ?page=1.
$page
->pressButton('edit-wizard-prev');
$assert_session
->waitForText('Element 1');
$this
->assertQuery('custom_param=1&page=page_1');
/**************************************************************************/
// Set the webform to use ajax.
$webform
->setSetting('ajax', TRUE);
$webform
->save();
// There should be no announcements when first visiting the form.
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertEqual('', $page
->findById('drupal-live-announce')
->getText());
// Check announcements on next and previous pages.
$page
->pressButton('Next >');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 2" loaded. (2 of 4)');
$page
->pressButton('< Previous');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 1" loaded. (1 of 4)');
$page
->pressButton('Next >');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 2" loaded. (2 of 4)');
$page
->pressButton('Preview');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Preview" loaded. (3 of 4)');
}