function MediaLibraryTestBase::pressSaveButton

Same name and namespace in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
  2. 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
  3. 10 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.

4 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.
WidgetOverflowTest::testUnlimitedCardinality in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php
Tests that unlimited fields' selection count is not constrained.
WidgetOverflowTest::testWidgetOverflow in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php
Tests that the Media Library constrains the number of selected items.
WidgetUploadTest::testWidgetUpload in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the 'media_library_widget' works as expected.

File

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

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.