function HtmxDynamicFormTest::testMissingSwapTarget

Verify that a bad swap target selector does not cause an error.

File

core/tests/Drupal/FunctionalJavascriptTests/Core/Htmx/HtmxDynamicFormTest.php, line 108

Class

HtmxDynamicFormTest
Tests that dynamic forms powered by HTMX work as expected.

Namespace

Drupal\FunctionalJavascriptTests\Core\Htmx

Code

public function testMissingSwapTarget() : void {
  $this->drupalLogin($this->drupalCreateUser([
    'access content',
  ]));
  $this->drupalGet('htmx-test-attachments/form-builder-test/');
  $checkbox = $this->assertSession()
    ->elementExists('css', '[name="bad_swap_target"]');
  // Selector used in the htmx target attribute.
  $this->assertSession()
    ->elementNotExists('css', 'div.bad-target');
  $checkbox->click();
  $this->assertSession()
    ->assertWaitOnAjaxRequest();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.