You are here

public function WebformCardsDraftJavaScriptTest::testDraft in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_cards/tests/src/FunctionalJavaScript/WebformCardsDraftJavaScriptTest.php \Drupal\Tests\webform_cards\FunctionalJavaScript\WebformCardsDraftJavaScriptTest::testDraft()

Test webform cards draft.

File

modules/webform_cards/tests/src/FunctionalJavaScript/WebformCardsDraftJavaScriptTest.php, line 24

Class

WebformCardsDraftJavaScriptTest
Tests for webform cards draft.

Namespace

Drupal\Tests\webform_cards\FunctionalJavaScript

Code

public function testDraft() {
  $session = $this
    ->getSession();
  $page = $session
    ->getPage();
  $assert_session = $this
    ->assertSession();

  /**************************************************************************/

  // Get the webform and load card 1.
  $this
    ->drupalGet('/webform/test_cards_draft');
  $assert_session
    ->waitForElement('css', '.webform-card--active[data-webform-key="card_1"]');
  $this
    ->assertElementVisible('[data-webform-key="card_1"]');
  $this
    ->assertElementNotVisible('[data-webform-key="card_2"]');

  // Move to card 2.
  $page
    ->pressButton('edit-cards-next');
  $assert_session
    ->waitForElement('css', '.webform-card--active[data-webform-key="card_2"]');
  $this
    ->assertElementNotVisible('[data-webform-key="card_1"]');
  $this
    ->assertElementVisible('[data-webform-key="card_2"]');

  // Save a draft.
  $page
    ->pressButton('edit-draft');
  $assert_session
    ->responseContains('Submission saved. You may return to this form later and it will restore the current values.');
  $this
    ->assertElementNotVisible('[data-webform-key="card_1"]');
  $this
    ->assertElementVisible('[data-webform-key="card_2"]');

  // Reload the webform.
  $this
    ->drupalGet('/webform/test_cards_draft');
  $assert_session
    ->waitForElement('css', '.webform-card--active[data-webform-key="card_2"]');
  $this
    ->assertElementNotVisible('[data-webform-key="card_1"]');
  $this
    ->assertElementVisible('[data-webform-key="card_2"]');
}