function MediaLibraryTestBase::pressSaveButton

Same name in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
  2. 10 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
  3. 11.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()

Clicks "Save" button and waits for AJAX completion.

Parameters

bool $expect_errors: Whether validation errors are expected after the "Save" button is pressed. Defaults to FALSE.

2 calls to MediaLibraryTestBase::pressSaveButton()
WidgetOEmbedTest::testWidgetOEmbed in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php
Tests that oEmbed media can be added in the Media library's widget.
WidgetUploadTest::testWidgetUpload in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the Media library's widget works as expected.

File

core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php, line 246

Class

MediaLibraryTestBase
Base class for functional tests of Media Library functionality.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function pressSaveButton($expect_errors = FALSE) {
    $buttons = $this->assertElementExistsAfterWait('css', '.ui-dialog-buttonpane');
    $buttons->pressButton('Save');
    // If no validation errors are expected, wait for the "Insert selected"
    // button to return.
    if (!$expect_errors) {
        $result = $buttons->waitFor(10, function ($buttons) {
            
            /** @var \Behat\Mink\Element\NodeElement $buttons */
            return $buttons->findButton('Insert selected');
        });
        $this->assertNotEmpty($result);
    }
    // assertWaitOnAjaxRequest() required for input "id" attributes to
    // consistently match their label's "for" attribute.
    $this->assertSession()
        ->assertWaitOnAjaxRequest();
}

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