You are here

public function EmailedExportUiTest::testExportUi in Webform Scheduled Tasks 8.2

Test the export UI.

File

tests/src/FunctionalJavascript/EmailedExportUiTest.php, line 45

Class

EmailedExportUiTest
Test the email export task plugin UI.

Namespace

Drupal\Tests\webform_scheduled_tasks\FunctionalJavascript

Code

public function testExportUi() {
  WebformScheduledTask::create([
    'id' => 'foo',
    'result_set_type' => 'all_submissions',
    'task_type' => 'export_email_results',
    'webform' => 'contact',
  ])
    ->save();
  $this
    ->drupalGet('admin/structure/webform/manage/contact/scheduled-tasks/foo/edit');

  // By default the delimited settings should appear.
  $this
    ->assertSession()
    ->fieldValueEquals('task_settings[exporter]', 'delimited');
  $this
    ->assertSession()
    ->pageTextContains('Delimiter text format');

  // Ensure the AJAX switching between export formats works.
  $this
    ->getSession()
    ->getPage()
    ->fillField('task_settings[exporter]', 'table');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->fieldValueEquals('task_settings[exporter]', 'table');
  $this
    ->assertSession()
    ->pageTextContains('Open HTML table in Excel');

  // Test the #states and warning message work.
  $this
    ->getSession()
    ->getPage()
    ->fillField('task_settings[storage_type]', 'filesystem');
  $this
    ->assertSession()
    ->pageTextNotContains('Sending email file attachments requires webform to have already been configured for attachments');
  $this
    ->getSession()
    ->getPage()
    ->fillField('task_settings[storage_type]', 'email');
  $this
    ->assertSession()
    ->pageTextContains('Sending email file attachments requires webform to have already been configured for attachments');
}