DEV: uses vanilla js for fixture qunit helper (#14703)

DEV: uses vanilla js for fixture qunit helper (#14703)

diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index e5e71d4..d2c64d0 100644
--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -385,9 +385,9 @@ export function controllerFor(controller, model) {
 
 export function fixture(selector) {
   if (selector) {
-    return $("#qunit-fixture").find(selector);
+    return document.querySelector(`#qunit-fixture ${selector}`);
   }
-  return $("#qunit-fixture");
+  return document.querySelector("#qunit-fixture");
 }
 
 QUnit.assert.not = function (actual, message) {
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
index f6e875e..c5eea3a 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
@@ -9,7 +9,7 @@ import sinon from "sinon";
 const track = ClickTrack.trackClick;
 
 function generateClickEventOn(selector) {
-  return $.Event("click", { currentTarget: fixture(selector).first() });
+  return $.Event("click", { currentTarget: fixture(selector) });
 }
 
 module("Unit | Utility | click-track-edit-history", function (hooks) {
@@ -25,8 +25,7 @@ module("Unit | Utility | click-track-edit-history", function (hooks) {
 
     sessionStorage.clear();
 
-    fixture().html(
-      `<div id="topic" data-topic-id="1337">
+    fixture().innerHTML = `<div id="topic" data-topic-id="1337">
        </div>
        <div id="revisions" data-post-id="42" class="">
          <div class="row">
@@ -55,8 +54,7 @@ module("Unit | Utility | click-track-edit-history", function (hooks) {
              <a class="hashtag" href="http://discuss.domain.com">#hashtag</a>
            </div>
          </div>
-       </div>`
-    );
+       </div>`;
   });
 
   skip("tracks internal URLs", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
index 1de09ca..9d74ee8 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
@@ -8,7 +8,7 @@ import sinon from "sinon";
 const track = ClickTrack.trackClick;
 
 function generateClickEventOn(selector) {
-  return $.Event("click", { currentTarget: fixture(selector).first() });
+  return $.Event("click", { currentTarget: fixture(selector) });
 }
 
 module("Unit | Utility | click-track-profile-page", function (hooks) {
@@ -24,8 +24,7 @@ module("Unit | Utility | click-track-profile-page", function (hooks) {
 
     sessionStorage.clear();
 
-    fixture().html(
-      `<p class="excerpt first" data-post-id="42" data-topic-id="1337" data-user-id="3141">
+    fixture().innerHTML = `<p class="excerpt first" data-post-id="42" data-topic-id="1337" data-user-id="3141">
         <a href="http://www.google.com">google.com</a>
         <a class="lightbox back" href="http://www.google.com">google.com</a>
         <div class="onebox-result">
@@ -48,8 +47,7 @@ module("Unit | Utility | click-track-profile-page", function (hooks) {
         <a id="same-site" href="http://discuss.domain.com">forum</a>
         <a class="attachment" href="http://discuss.domain.com/uploads/default/1234/1532357280.txt">log.txt</a>
         <a class="hashtag" href="http://discuss.domain.com">#hashtag</a>
-      </p>`
-    );
+      </p>`;
   });
 
   skip("tracks internal URLs", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
index 43cf438..d7bed4a 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
@@ -11,7 +11,7 @@ import { setPrefix } from "discourse-common/lib/get-url";
 const track = ClickTrack.trackClick;
 
 function generateClickEventOn(selector) {
-  return $.Event("click", { currentTarget: fixture(selector).first() });
+  return $.Event("click", { currentTarget: fixture(selector) });
 }
 
 module("Unit | Utility | click-track", function (hooks) {
@@ -27,8 +27,7 @@ module("Unit | Utility | click-track", function (hooks) {
 
     sessionStorage.clear();
 
-    fixture().html(
-      `<div id="topic" data-topic-id="1337">
+    fixture().innerHTML = `<div id="topic" data-topic-id="1337">
         <article data-post-id="42" data-user-id="3141">
           <a href="http://www.google.com">google.com</a>
           <a class="lightbox back" href="http://www.google.fr">google.fr</a>
@@ -52,8 +51,7 @@ module("Unit | Utility | click-track", function (hooks) {
           <a class="abs-prefix-url" href="${window.location.origin}/forum/thing">prefix link</a>
           <a class="diff-prefix-url" href="/thing">diff prefix link</a>
         </article>
-      </div>`
-    );
+      </div>`;
   });
 
   skip("tracks internal URLs", async function (assert) {
@@ -189,11 +187,11 @@ module("Unit | Utility | click-track", function (hooks) {
 
     assert.notOk(track(generateClickEventOn("a")));
 
-    let $link = fixture("a").first();
-    assert.ok($link.hasClass("no-href"));
-    assert.equal($link.data("href"), "http://www.google.com/");
-    assert.blank($link.attr("href"));
-    assert.ok($link.data("auto-route"));
+    let link = fixture("a");
+    assert.ok(link.classList.contains("no-href"));
+    assert.equal(link.dataset.href, "http://www.google.com/");
+    assert.blank(link.getAttribute("href"));
+    assert.ok(link.dataset.autoRoute);
     assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
   });
 
@@ -206,15 +204,15 @@ module("Unit | Utility | click-track", function (hooks) {
 
     const done = assert.async();
     later(() => {
-      assert.equal(fixture("a").attr("href"), "http://www.google.com");
+      assert.equal(fixture("a").getAttribute("href"), "http://www.google.com");
       done();
     });
   });
 
   function badgeClickCount(assert, id, expected) {
-    track(generateClickEventOn("#" + id));
-    let $badge = $("span.badge", fixture("#" + id).first());
-    assert.equal(parseInt($badge.html(), 10), expected);
+    track(generateClickEventOn(`#${id}`));
+    const badge = fixture(`#${id}`).querySelector("span.badge");
+    assert.equal(parseInt(badge.innerHTML, 10), expected);
   }
 
   test("does not update badge clicks on my own link", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js b/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js
index 165c53b..e069ec8 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js
@@ -4,19 +4,13 @@ import { fixture } from "discourse/tests/helpers/qunit-helpers";
 
 module("Unit | Utility | highlight-search", function () {
   test("highlighting text", function (assert) {
-    fixture().html(
-      `
+    fixture().innerHTML = `
       <p>This is some text to highlight</p>
-      `
-    );
-
-    highlightSearch(fixture()[0], "some text");
+      `;
 
-    const terms = [];
+    highlightSearch(fixture(), "some text");
 
-    fixture(`.${CLASS_NAME}`).each((_, elem) => {
-      terms.push(elem.textContent);
-    });
+    const terms = [fixture(`.${CLASS_NAME}`).textContent];
 
     assert.equal(
       terms.join(" "),
@@ -26,19 +20,13 @@ module("Unit | Utility | highlight-search", function () {
   });
 
   test("highlighting unicode text", function (assert) {
-    fixture().html(
-      `
+    fixture().innerHTML = `

[... diff too long, it was truncated ...]

GitHub sha: c7099342ff6c9fce1f11df81b50605c414df4eb3

This commit appears in #14703 which was approved by ZogStriP. It was merged by jjaffeux.