Verified Commit 8d0385f8 authored by Jess's avatar Jess
Browse files

Issue #3399754 by mstrelan, smustgrave, xjm: Fix strict type errors in functional JavaScript tests

(cherry picked from commit 35cfa709)
parent 25942e9c
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public function testOffCanvasStyles() {
    $assert_session->assertWaitOnAjaxRequest();

    $styles = $assert_session->elementExists('css', 'style#ckeditor5-off-canvas-reset');
    $this->stringContains('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getText());
    $this->assertStringContainsString('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getHtml());

    $assert_session->elementExists('css', '.ck');

+2 −2
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ public function testFormatterUI() {
    $field_test_format_type->setValue('field_empty_setting');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->responseNotContains('Default empty setting now has a value.');
    $this->assertTrue($field_test_settings->isVisible(), TRUE);
    $this->assertTrue($field_test_settings->isVisible());

    // Set the empty_setting option to a non-empty value again and validate
    // the formatting summary now display's this correctly.
@@ -237,7 +237,7 @@ public function testFormatterUI() {

    // Ensure the button is still there after the module has been disabled.
    $this->drupalGet($manage_display);
    $this->assertTrue($field_test_settings->isVisible(), TRUE);
    $this->assertTrue($field_test_settings->isVisible());

    // Ensure that third-party form elements are not present anymore.
    $field_test_settings->click();
+1 −2
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\file\FunctionalJavascript;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\file\Entity\File;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
@@ -100,7 +99,7 @@ public function testMultiValuedWidget() {
        // Ensure we have the expected number of Remove buttons, and that they
        // are numbered sequentially.
        $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
        $this->assertCount($num_expected_remove_buttons, $buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
        $this->assertCount($num_expected_remove_buttons, $buttons, 'There are ' . $num_expected_remove_buttons . ' "Remove" buttons displayed.');
        foreach ($buttons as $i => $button) {
          $key = $i >= $remaining ? $i - $remaining : $i;
          $check_field_name = $field_name2;
+2 −2
Original line number Diff line number Diff line
@@ -99,11 +99,11 @@ public function testUploadFileExceedingMaximumFileSize() {
    $session = $this->getSession();

    // Create a test file that exceeds the maximum POST size with 1 kilobyte.
    $post_max_size = Bytes::toNumber(ini_get('post_max_size'));
    $post_max_size = (int) Bytes::toNumber(ini_get('post_max_size'));
    $invalid_file = 'public://exceeding_post_max_size.bin';
    $file = fopen($invalid_file, 'wb');
    fseek($file, $post_max_size + 1024);
    fwrite($file, 0x0);
    fwrite($file, '0');
    fclose($file);

    // Go to the node creation form and try to upload the test file.
+9 −10
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\system\FunctionalJavascript;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;

/**
@@ -43,9 +42,9 @@ public function testLazyLoad() {

    // Verify that the base page doesn't have the settings and files that are to
    // be lazy loaded as part of the next requests.
    $this->assertTrue(!isset($original_settings[$expected['setting_name']]), new FormattableMarkup('Page originally lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
    $this->assertNotContains($expected['library_1'], $original_libraries, new FormattableMarkup('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
    $this->assertNotContains($expected['library_2'], $original_libraries, new FormattableMarkup('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
    $this->assertTrue(!isset($original_settings[$expected['setting_name']]), "Page originally lacks the {$expected['setting_name']}, as expected.");
    $this->assertNotContains($expected['library_1'], $original_libraries, "Page originally lacks the {$expected['library_1']} library, as expected.");
    $this->assertNotContains($expected['library_2'], $original_libraries, "Page originally lacks the {$expected['library_2']} library, as expected.");

    // Submit the AJAX request without triggering files getting added.
    $page->pressButton('Submit');
@@ -54,9 +53,9 @@ public function testLazyLoad() {
    $new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);

    // Verify the setting was not added when not expected.
    $this->assertTrue(!isset($new_settings[$expected['setting_name']]), new FormattableMarkup('Page still lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
    $this->assertNotContains($expected['library_1'], $new_libraries, new FormattableMarkup('Page still lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
    $this->assertNotContains($expected['library_2'], $new_libraries, new FormattableMarkup('Page still lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
    $this->assertTrue(!isset($new_settings[$expected['setting_name']]), "Page still lacks the {$expected['setting_name']}, as expected.");
    $this->assertNotContains($expected['library_1'], $new_libraries, "Page still lacks the {$expected['library_1']} library, as expected.");
    $this->assertNotContains($expected['library_2'], $new_libraries, "Page still lacks the {$expected['library_2']} library, as expected.");

    // Submit the AJAX request and trigger adding files.
    $page->checkField('add_files');
@@ -67,11 +66,11 @@ public function testLazyLoad() {

    // Verify the expected setting was added, both to drupalSettings, and as
    // the first AJAX command.
    $this->assertSame($expected['setting_value'], $new_settings[$expected['setting_name']], new FormattableMarkup('Page now has the %setting.', ['%setting' => $expected['setting_name']]));
    $this->assertSame($expected['setting_value'], $new_settings[$expected['setting_name']], "Page now has the {$expected['setting_name']}.");

    // Verify the expected CSS file was added, both to drupalSettings, and as
    // the second AJAX command for inclusion into the HTML.
    $this->assertContains($expected['library_1'], $new_libraries, new FormattableMarkup('Page state now has the %library library.', ['%library' => $expected['library_1']]));
    $this->assertContains($expected['library_1'], $new_libraries, "Page state now has the {$expected['library_1']} library.");

    // Verify the expected JS file was added, both to drupalSettings, and as
    // the third AJAX command for inclusion into the HTML. By testing for an
@@ -79,7 +78,7 @@ public function testLazyLoad() {
    // unexpected JavaScript code, such as a jQuery.extend() that would
    // potentially clobber rather than properly merge settings, didn't
    // accidentally get added.
    $this->assertContains($expected['library_2'], $new_libraries, new FormattableMarkup('Page state now has the %library library.', ['%library' => $expected['library_2']]));
    $this->assertContains($expected['library_2'], $new_libraries, "Page state now has the {$expected['library_2']} library.");
  }

  /**
Loading