From b59e3b0b7ce915b322e3400ef6aa80bca6fd7e58 Mon Sep 17 00:00:00 2001 From: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com> Date: Tue, 21 Jun 2022 13:37:29 -0500 Subject: [PATCH] DEV: Remove `isLegacyEmber()` from tests (#17184) --- .../acceptance/composer-uploads-uppy-test.js | 76 +++++++------------ .../integration/components/d-editor-test.js | 27 +++---- .../components/watched-word-uploader-test.js | 68 ++++++++--------- 3 files changed, 72 insertions(+), 99 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js index 0b24b2fd186..b976eb69c47 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js @@ -12,7 +12,6 @@ import { click, fillIn, settled, visit } from "@ember/test-helpers"; import I18n from "I18n"; import { skip, test } from "qunit"; import { Promise } from "rsvp"; -import { isLegacyEmber } from "discourse-common/config/environment"; function pretender(server, helper) { server.post("/uploads/lookup-urls", () => { @@ -74,12 +73,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { }); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n" - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n" + ); }); const image = createFile("avatar.png"); @@ -152,13 +149,11 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { uploadStarted++; if (uploadStarted === 2) { - if (!isLegacyEmber()) { - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n[Uploading: avatar2.png...]()\n", - "it should show the upload placeholders when the upload starts" - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n[Uploading: avatar2.png...]()\n", + "it should show the upload placeholders when the upload starts" + ); } }); appEvents.on("composer:uploads-cancelled", () => { @@ -186,13 +181,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { const done = assert.async(); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - // Event handling is different in legacy - the text hasn't been inserted when this event fires - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n" - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n" + ); }); appEvents.on("composer:all-uploads-complete", () => { @@ -219,13 +211,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { const done = assert.async(); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - // Event handling is different in legacy - the text hasn't been inserted when this event fires - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n Text after the image." - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n Text after the image." + ); }); appEvents.on("composer:all-uploads-complete", () => { @@ -255,13 +244,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { const done = assert.async(); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - // Event handling is different in legacy - the text hasn't been inserted when this event fires - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n Text after the image." - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n Text after the image." + ); }); appEvents.on("composer:all-uploads-complete", () => { @@ -283,12 +269,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { const done = assert.async(); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - assert.strictEqual( - query(".d-editor-input").value, - "[Uploading: avatar.png...]()\n" - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "[Uploading: avatar.png...]()\n" + ); }); appEvents.on("composer:all-uploads-complete", () => { @@ -311,12 +295,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) { const done = assert.async(); appEvents.on("composer:upload-started", () => { - if (!isLegacyEmber()) { - assert.strictEqual( - query(".d-editor-input").value, - "The image:\n[Uploading: avatar.png...]()\n" - ); - } + assert.strictEqual( + query(".d-editor-input").value, + "The image:\n[Uploading: avatar.png...]()\n" + ); }); appEvents.on("composer:all-uploads-complete", () => { diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js index 0b1a4f98c52..02a5af80fcd 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js @@ -19,7 +19,6 @@ import formatTextWithSelection from "discourse/tests/helpers/d-editor-helper"; import hbs from "htmlbars-inline-precompile"; import { next } from "@ember/runloop"; import { withPluginApi } from "discourse/lib/plugin-api"; -import { isLegacyEmber } from "discourse-common/config/environment"; discourseModule("Integration | Component | d-editor", function (hooks) { setupRenderingTest(hooks); @@ -734,21 +733,19 @@ third line` "it works when there is no partial emoji" ); - if (!isLegacyEmber()) { - await click("textarea.d-editor-input"); - await fillIn(".d-editor-input", "starting to type an emoji like :gri"); - jumpEnd(query("textarea.d-editor-input")); - await click("button.emoji"); + await click("textarea.d-editor-input"); + await fillIn(".d-editor-input", "starting to type an emoji like :gri"); + jumpEnd(query("textarea.d-editor-input")); + await click("button.emoji"); - await click( - '.emoji-picker .section[data-section="smileys_&_emotion"] img.emoji[title="grinning"]' - ); - assert.strictEqual( - this.value, - "starting to type an emoji like :grinning:", - "it works when there is a partial emoji" - ); - } + await click( + '.emoji-picker .section[data-section="smileys_&_emotion"] img.emoji[title="grinning"]' + ); + assert.strictEqual( + this.value, + "starting to type an emoji like :grinning:", + "it works when there is a partial emoji" + ); }, }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js b/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js index 04f65e36ccc..49272b6556b 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js @@ -8,50 +8,44 @@ import { import hbs from "htmlbars-inline-precompile"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; import { click, waitFor } from "@ember/test-helpers"; -import { isLegacyEmber } from "discourse-common/config/environment"; -if (!isLegacyEmber()) { - discourseModule( - "Integration | Component | watched-word-uploader", - function (hooks) { - setupRenderingTest(hooks); +discourseModule( + "Integration | Component | watched-word-uploader", + function (hooks) { + setupRenderingTest(hooks); - hooks.beforeEach(function () { - pretender.post( - "/admin/customize/watched_words/upload.json", - function () { - return response(200, {}); - } - ); + hooks.beforeEach(function () { + pretender.post("/admin/customize/watched_words/upload.json", function () { + return response(200, {}); }); + }); - componentTest("sets the proper action key on uploads", { - template: hbs`{{watched-word-uploader + componentTest("sets the proper action key on uploads", { + template: hbs`{{watched-word-uploader id="watched-word-uploader" actionKey=actionNameKey done=doneUpload }}`, - async test(assert) { - const done = assert.async(); - this.set("actionNameKey", "flag"); - this.set("doneUpload", function () { - assert.equal( - Object.entries(this._uppyInstance.getState().files)[0][1].meta - .action_key, - "flag" - ); - done(); - }); + async test(assert) { + const done = assert.async(); + this.set("actionNameKey", "flag"); + this.set("doneUpload", function () { + assert.equal( + Object.entries(this._uppyInstance.getState().files)[0][1].meta + .action_key, + "flag" + ); + done(); + }); - const words = createFile("watched-words.txt"); - await this.container - .lookup("service:app-events") - .trigger("upload-mixin:watched-word-uploader:add-files", words); - await waitFor(".bootbox span.d-button-label"); - await click(".bootbox span.d-button-label"); - }, - }); - } - ); -} + const words = createFile("watched-words.txt"); + await this.container + .lookup("service:app-events") + .trigger("upload-mixin:watched-word-uploader:add-files", words); + await waitFor(".bootbox span.d-button-label"); + await click(".bootbox span.d-button-label"); + }, + }); + } +);