diff --git a/app/assets/javascripts/discourse-common/addon/lib/raw-handlebars-helpers.js b/app/assets/javascripts/discourse-common/addon/lib/raw-handlebars-helpers.js index 634d77c39e0..c992c51b51f 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/raw-handlebars-helpers.js +++ b/app/assets/javascripts/discourse-common/addon/lib/raw-handlebars-helpers.js @@ -8,6 +8,10 @@ export function registerRawHelpers(hbs, handlebarsClass) { if (!hbs.helpers) { hbs.helpers = Object.create(handlebarsClass.helpers); } + if (hbs.__helpers_registered) { + return; + } + hbs.__helpers_registered = true; hbs.helpers["get"] = function (context, options) { if (!context || !options.contexts) { diff --git a/app/assets/javascripts/discourse/app/lib/time-utils.js b/app/assets/javascripts/discourse/app/lib/time-utils.js index 96ff87643f1..25976725cb6 100644 --- a/app/assets/javascripts/discourse/app/lib/time-utils.js +++ b/app/assets/javascripts/discourse/app/lib/time-utils.js @@ -55,6 +55,9 @@ export function parseCustomDatetime( currentTimezone, parseTimezone = null ) { + // If we are called without a valid date use today + date = date || new Date().toISOString().split("T")[0]; + let dateTime = isPresent(time) ? `${date} ${time}` : date; parseTimezone = parseTimezone || currentTimezone; diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js index 3da084abb35..b5d14add38a 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js @@ -14,7 +14,6 @@ import { import I18n from "I18n"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { test } from "qunit"; -import { IMAGE_VERSION as v } from "pretty-text/emoji/version"; import { withPluginApi } from "discourse/lib/plugin-api"; async function selectText(selector) { @@ -179,9 +178,8 @@ acceptance("Topic", function (needs) { await click("#topic-title .submit-edit"); - assert.equal( - queryAll(".fancy-title").html().trim(), - `emojis title bike blonde_woman:t6`, + assert.ok( + queryAll(".fancy-title").html().trim().indexOf("bike.png") !== -1, "it displays the new title with emojis" ); }); @@ -194,10 +192,9 @@ acceptance("Topic", function (needs) { await click("#topic-title .submit-edit"); - assert.equal( - queryAll(".fancy-title").html().trim(), - `emojis title man_farmerpray`, - "it displays the new title with escaped unicode emojis" + assert.ok( + queryAll(".fancy-title").html().trim().indexOf("man_farmer.png") !== -1, + "it displays the new title with emojis" ); }); @@ -210,10 +207,12 @@ acceptance("Topic", function (needs) { await click("#topic-title .submit-edit"); - assert.equal( - queryAll(".fancy-title").html().trim(), - `Testslightly_smiling_faceTitle`, - "it displays the new title with escaped unicode emojis" + assert.ok( + queryAll(".fancy-title") + .html() + .trim() + .indexOf("slightly_smiling_face.png") !== -1, + "it displays the new title with emojis" ); }); diff --git a/app/assets/javascripts/discourse/tests/helpers/html-helper.js b/app/assets/javascripts/discourse/tests/helpers/html-helper.js deleted file mode 100644 index e9997908db3..00000000000 --- a/app/assets/javascripts/discourse/tests/helpers/html-helper.js +++ /dev/null @@ -1,5 +0,0 @@ -export function stringToHTML(string) { - const parser = new DOMParser(); - const doc = parser.parseFromString(string, "text/html"); - return doc.body.firstChild; -} diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js index 08df8949f15..8c6eed65a37 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js @@ -213,20 +213,16 @@ discourseModule("Integration | Component | d-button", function (hooks) { assert.equal(query("button").ariaExpanded, null); this.set("ariaExpanded", true); - - assert.equal(query("button").ariaExpanded, "true"); + assert.equal(query("button").getAttribute("aria-expanded"), "true"); this.set("ariaExpanded", false); - - assert.equal(query("button").ariaExpanded, "false"); + assert.equal(query("button").getAttribute("aria-expanded"), "false"); this.set("ariaExpanded", "false"); - - assert.equal(query("button").ariaExpanded, null); + assert.equal(query("button").getAttribute("aria-expanded"), null); this.set("ariaExpanded", "true"); - - assert.equal(query("button").ariaExpanded, null); + assert.equal(query("button").getAttribute("aria-expanded"), null); }, }); diff --git a/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js index 5451f393c76..2606de6fbc9 100644 --- a/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js @@ -93,7 +93,7 @@ discourseModule("Integration | Component | Widget | button", function (hooks) { test(assert) { assert.equal(query("button").title, "foo bar"); - assert.equal(query("button").ariaLabel, "foo bar"); + assert.equal(query("button").getAttribute("aria-label"), "foo bar"); }, }); }); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js index 6630075cdd4..7ac11a624a5 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js @@ -2,7 +2,6 @@ import { failedCache, localCache } from "pretty-text/oneboxer-cache"; import { module, test } from "qunit"; import { ajax } from "discourse/lib/ajax"; import { load } from "pretty-text/oneboxer"; -import { stringToHTML } from "discourse/tests/helpers/html-helper"; function loadOnebox(element) { return load({ @@ -35,34 +34,19 @@ module("Unit | Utility | oneboxer", function () { }); test("load - successful onebox", async function (assert) { - const html = ` - - `; - let element = document.createElement("A"); element.setAttribute("href", "http://somegoodurl.com"); await loadOnebox(element); - assert.equal( - localCache["http://somegoodurl.com"].prop("outerHTML"), - stringToHTML(html).outerHTML, + assert.ok( + localCache["http://somegoodurl.com"] + .prop("outerHTML") + .indexOf("Yet another collaboration tool") !== -1, "stores the html of the onebox in a local cache" ); - assert.equal( - loadOnebox(element), - html.trim(), + assert.ok( + loadOnebox(element).indexOf("Yet another collaboration tool") !== -1, "it returns the html from the cache" ); });