function HtmxDynamicFormTest::testMissingPartialTarget
Verify that response with two partials: one bad, one good.
The first partial is missing a target, the second is good. The missing target should not cause an error, execution should continue, and the good partial should be applied.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ Core/ Htmx/ HtmxDynamicFormTest.php, line 127
Class
- HtmxDynamicFormTest
- Tests that dynamic forms powered by HTMX work as expected.
Namespace
Drupal\FunctionalJavascriptTests\Core\HtmxCode
public function testMissingPartialTarget() : void {
$this->drupalLogin($this->drupalCreateUser([
'access content',
]));
$this->drupalGet('htmx-test-attachments/form-builder-test/');
$checkbox = $this->assertSession()
->elementExists('css', '[name="partial_missing"]');
// Selector used in the htmx target attribute.
$this->assertSession()
->elementNotExists('css', 'div.does-not-exist');
$checkbox->click();
$this->assertSession()
->assertWaitOnAjaxRequest();
$this->assertSession()
->elementNotExists('css', '[data-drupal-wrapper-selector="edit-partial-replace"]');
$this->assertSession()
->pageTextContainsOnce('Inserted by htmx!');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.