Namespace
Drupal\Tests\form_api_example\FunctionalJavascript
File
-
modules/form_api_example/tests/src/FunctionalJavascript/ModalFormTest.php
View source
<?php
namespace Drupal\Tests\form_api_example\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Core\Url;
class ModalFormTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'form_api_example',
];
public function testModalForm() {
$modal_route_nojs = Url::fromRoute('form_api_example.modal_form', [
'nojs' => 'nojs',
]);
$this->drupalGet($modal_route_nojs);
$assert = $this->assertSession();
$session = $this->getSession();
$page = $this->getSession()
->getPage();
$this->clickLink('ajax-example-modal-link');
$this->assertNotEmpty($assert->waitForElementVisible('css', '.ui-dialog'));
$this->assertNotEmpty($input = $page->find('css', 'div.ui-dialog input[name="title"]'));
$input->setValue('test_title');
$this->assertNotEmpty($submit = $page->find('css', 'button.ui-button.form-submit'));
$submit->click();
$assert->assertWaitOnAjaxRequest();
$assert->elementContains('css', 'span.ui-dialog-title', 'test_title');
$this->assertNotEmpty($close = $page->find('css', 'button.ui-dialog-titlebar-close'));
$close->click();
$assert->assertWaitOnAjaxRequest();
$assert->pageTextNotContains('appears in this modal dialog.');
}
}
Classes