Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / FunctionalJavascriptTests / Ajax / BackwardCompatibilityTest.php
diff --git a/web/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php b/web/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php
new file mode 100644 (file)
index 0000000..077c3aa
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests\Ajax;
+
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+
+/**
+ * Tests the compatibility of the ajax.es6.js file.
+ *
+ * @group Ajax
+ */
+class BackwardCompatibilityTest extends JavascriptTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = [
+    'js_ajax_test',
+  ];
+
+  /**
+   * Ensures Drupal.Ajax.element_settings BC layer.
+   */
+  public function testAjaxBackwardCompatibility() {
+    $this->drupalGet('/js_ajax_test');
+    $this->click('#edit-test-button');
+
+    $this->assertSession()
+      ->waitForElement('css', '#js_ajax_test_form_element');
+    $elements = $this->cssSelect('#js_ajax_test_form_element');
+    $this->assertCount(1, $elements);
+    $json = $elements[0]->getText();
+    $data = json_decode($json, TRUE);
+    $this->assertEquals([
+      'element_settings' => 'catbro',
+      'elementSettings' => 'catbro',
+    ], $data);
+  }
+
+}