DEV: Remove `isLegacyEmber()` from tests (#17184)

This commit is contained in:
Isaac Janzen 2022-06-21 13:37:29 -05:00 committed by GitHub
parent 59f0815c9d
commit b59e3b0b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 99 deletions

View File

@ -12,7 +12,6 @@ import { click, fillIn, settled, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
import { skip, test } from "qunit"; import { skip, test } from "qunit";
import { Promise } from "rsvp"; import { Promise } from "rsvp";
import { isLegacyEmber } from "discourse-common/config/environment";
function pretender(server, helper) { function pretender(server, helper) {
server.post("/uploads/lookup-urls", () => { server.post("/uploads/lookup-urls", () => {
@ -74,12 +73,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
}); });
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
if (!isLegacyEmber()) {
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n" "The image:\n[Uploading: avatar.png...]()\n"
); );
}
}); });
const image = createFile("avatar.png"); const image = createFile("avatar.png");
@ -152,14 +149,12 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
uploadStarted++; uploadStarted++;
if (uploadStarted === 2) { if (uploadStarted === 2) {
if (!isLegacyEmber()) {
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n[Uploading: avatar2.png...]()\n", "The image:\n[Uploading: avatar.png...]()\n[Uploading: avatar2.png...]()\n",
"it should show the upload placeholders when the upload starts" "it should show the upload placeholders when the upload starts"
); );
} }
}
}); });
appEvents.on("composer:uploads-cancelled", () => { appEvents.on("composer:uploads-cancelled", () => {
assert.strictEqual( assert.strictEqual(
@ -186,13 +181,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { 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( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n" "The image:\n[Uploading: avatar.png...]()\n"
); );
}
}); });
appEvents.on("composer:all-uploads-complete", () => { appEvents.on("composer:all-uploads-complete", () => {
@ -219,13 +211,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { 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( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n Text after the image." "The image:\n[Uploading: avatar.png...]()\n Text after the image."
); );
}
}); });
appEvents.on("composer:all-uploads-complete", () => { appEvents.on("composer:all-uploads-complete", () => {
@ -255,13 +244,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { 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( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n Text after the image." "The image:\n[Uploading: avatar.png...]()\n Text after the image."
); );
}
}); });
appEvents.on("composer:all-uploads-complete", () => { appEvents.on("composer:all-uploads-complete", () => {
@ -283,12 +269,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
if (!isLegacyEmber()) {
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"[Uploading: avatar.png...]()\n" "[Uploading: avatar.png...]()\n"
); );
}
}); });
appEvents.on("composer:all-uploads-complete", () => { appEvents.on("composer:all-uploads-complete", () => {
@ -311,12 +295,10 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
if (!isLegacyEmber()) {
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value, query(".d-editor-input").value,
"The image:\n[Uploading: avatar.png...]()\n" "The image:\n[Uploading: avatar.png...]()\n"
); );
}
}); });
appEvents.on("composer:all-uploads-complete", () => { appEvents.on("composer:all-uploads-complete", () => {

View File

@ -19,7 +19,6 @@ import formatTextWithSelection from "discourse/tests/helpers/d-editor-helper";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
import { isLegacyEmber } from "discourse-common/config/environment";
discourseModule("Integration | Component | d-editor", function (hooks) { discourseModule("Integration | Component | d-editor", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -734,7 +733,6 @@ third line`
"it works when there is no partial emoji" "it works when there is no partial emoji"
); );
if (!isLegacyEmber()) {
await click("textarea.d-editor-input"); await click("textarea.d-editor-input");
await fillIn(".d-editor-input", "starting to type an emoji like :gri"); await fillIn(".d-editor-input", "starting to type an emoji like :gri");
jumpEnd(query("textarea.d-editor-input")); jumpEnd(query("textarea.d-editor-input"));
@ -748,7 +746,6 @@ third line`
"starting to type an emoji like :grinning:", "starting to type an emoji like :grinning:",
"it works when there is a partial emoji" "it works when there is a partial emoji"
); );
}
}, },
}); });

View File

@ -8,21 +8,16 @@ import {
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { click, waitFor } from "@ember/test-helpers"; import { click, waitFor } from "@ember/test-helpers";
import { isLegacyEmber } from "discourse-common/config/environment";
if (!isLegacyEmber()) {
discourseModule( discourseModule(
"Integration | Component | watched-word-uploader", "Integration | Component | watched-word-uploader",
function (hooks) { function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
hooks.beforeEach(function () { hooks.beforeEach(function () {
pretender.post( pretender.post("/admin/customize/watched_words/upload.json", function () {
"/admin/customize/watched_words/upload.json",
function () {
return response(200, {}); return response(200, {});
} });
);
}); });
componentTest("sets the proper action key on uploads", { componentTest("sets the proper action key on uploads", {
@ -54,4 +49,3 @@ if (!isLegacyEmber()) {
}); });
} }
); );
}