function LayoutBuilderUiTest::testUnsavedChangesMessage

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testUnsavedChangesMessage()
  2. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testUnsavedChangesMessage()
  3. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testUnsavedChangesMessage()

Tests the message indicating unsaved changes.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php, line 95

Class

LayoutBuilderUiTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

public function testUnsavedChangesMessage() : void {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->assertModifiedLayout(static::FIELD_UI_PREFIX . '/display/default/layout');
    // Discard then cancel.
    $page->pressButton('Discard changes');
    $page->clickLink('Cancel');
    $assert_session->addressEquals(static::FIELD_UI_PREFIX . '/display/default/layout');
    $assert_session->pageTextContainsOnce('You have unsaved changes.');
    // Discard then confirm.
    $page->pressButton('Discard changes');
    $page->pressButton('Confirm');
    $assert_session->addressEquals(static::FIELD_UI_PREFIX . '/display/default');
    $assert_session->pageTextNotContains('You have unsaved changes.');
    // Make and then save changes.
    $this->assertModifiedLayout(static::FIELD_UI_PREFIX . '/display/default/layout');
    $page->pressButton('Save layout');
    $assert_session->pageTextNotContains('You have unsaved changes.');
}

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