mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
DEV: Remove isLegacyEmber()
from tests (#17184)
This commit is contained in:
@ -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", () => {
|
||||
|
@ -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"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -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");
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user