function NavigationBlockUiTest::testNavigationBlockAdminUiPageNestedForm
Tests navigation block admin page exists and functions correctly.
File
-
core/
modules/ navigation/ tests/ src/ FunctionalJavascript/ NavigationBlockUiTest.php, line 77
Class
- NavigationBlockUiTest
- Tests that the navigation block UI exists and stores data correctly.
Namespace
Drupal\Tests\navigation\FunctionalJavascriptCode
public function testNavigationBlockAdminUiPageNestedForm() : void {
$layout_url = '/admin/config/user-interface/navigation-block';
$this->drupalLogin($this->adminUser);
// Edit the layout and add a block that contains a form.
$this->drupalGet($layout_url);
$this->getSession()
->getPage()
->pressButton('Enable edit mode');
$this->assertSession()
->assertWaitOnAjaxRequest();
$this->openAddBlockForm('Layout Builder form block test form api form block');
$this->getSession()
->getPage()
->checkField('settings[label_display]');
// Save the new block, and ensure it is displayed on the page.
$this->getSession()
->getPage()
->pressButton('Add block');
$this->assertSession()
->assertWaitOnAjaxRequest();
$this->assertSession()
->assertNoElementAfterWait('css', '#drupal-off-canvas');
$this->assertSession()
->addressEquals($layout_url);
$this->assertSession()
->pageTextContains('Layout Builder form block test form api form block');
$this->getSession()
->getPage()
->pressButton('Save');
$unexpected_save_message = 'You have unsaved changes';
$expected_save_message = 'Saved navigation blocks';
$this->assertSession()
->statusMessageNotContains($unexpected_save_message);
$this->assertSession()
->statusMessageContains($expected_save_message);
// Try to save the layout again and confirm it can save because there are no
// nested form tags.
$this->drupalGet($layout_url);
$this->getSession()
->getPage()
->pressButton('Enable edit mode');
$this->assertSession()
->assertWaitOnAjaxRequest();
$this->getSession()
->getPage()
->checkField('toggle_content_preview');
$this->getSession()
->getPage()
->pressButton('Save');
$this->assertSession()
->statusMessageNotContains($unexpected_save_message);
$this->assertSession()
->statusMessageContains($expected_save_message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.