mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +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 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,13 +149,11 @@ 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", () => {
|
||||||
@ -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()) {
|
assert.strictEqual(
|
||||||
// Event handling is different in legacy - the text hasn't been inserted when this event fires
|
query(".d-editor-input").value,
|
||||||
assert.strictEqual(
|
"The image:\n[Uploading: avatar.png...]()\n"
|
||||||
query(".d-editor-input").value,
|
);
|
||||||
"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()) {
|
assert.strictEqual(
|
||||||
// Event handling is different in legacy - the text hasn't been inserted when this event fires
|
query(".d-editor-input").value,
|
||||||
assert.strictEqual(
|
"The image:\n[Uploading: avatar.png...]()\n Text after the image."
|
||||||
query(".d-editor-input").value,
|
);
|
||||||
"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()) {
|
assert.strictEqual(
|
||||||
// Event handling is different in legacy - the text hasn't been inserted when this event fires
|
query(".d-editor-input").value,
|
||||||
assert.strictEqual(
|
"The image:\n[Uploading: avatar.png...]()\n Text after the image."
|
||||||
query(".d-editor-input").value,
|
);
|
||||||
"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", () => {
|
||||||
|
@ -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,21 +733,19 @@ 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"));
|
await click("button.emoji");
|
||||||
await click("button.emoji");
|
|
||||||
|
|
||||||
await click(
|
await click(
|
||||||
'.emoji-picker .section[data-section="smileys_&_emotion"] img.emoji[title="grinning"]'
|
'.emoji-picker .section[data-section="smileys_&_emotion"] img.emoji[title="grinning"]'
|
||||||
);
|
);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
this.value,
|
this.value,
|
||||||
"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"
|
||||||
);
|
);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,50 +8,44 @@ 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",
|
return response(200, {});
|
||||||
function () {
|
|
||||||
return response(200, {});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
componentTest("sets the proper action key on uploads", {
|
componentTest("sets the proper action key on uploads", {
|
||||||
template: hbs`{{watched-word-uploader
|
template: hbs`{{watched-word-uploader
|
||||||
id="watched-word-uploader"
|
id="watched-word-uploader"
|
||||||
actionKey=actionNameKey
|
actionKey=actionNameKey
|
||||||
done=doneUpload
|
done=doneUpload
|
||||||
}}`,
|
}}`,
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
const done = assert.async();
|
const done = assert.async();
|
||||||
this.set("actionNameKey", "flag");
|
this.set("actionNameKey", "flag");
|
||||||
this.set("doneUpload", function () {
|
this.set("doneUpload", function () {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Object.entries(this._uppyInstance.getState().files)[0][1].meta
|
Object.entries(this._uppyInstance.getState().files)[0][1].meta
|
||||||
.action_key,
|
.action_key,
|
||||||
"flag"
|
"flag"
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
const words = createFile("watched-words.txt");
|
const words = createFile("watched-words.txt");
|
||||||
await this.container
|
await this.container
|
||||||
.lookup("service:app-events")
|
.lookup("service:app-events")
|
||||||
.trigger("upload-mixin:watched-word-uploader:add-files", words);
|
.trigger("upload-mixin:watched-word-uploader:add-files", words);
|
||||||
await waitFor(".bootbox span.d-button-label");
|
await waitFor(".bootbox span.d-button-label");
|
||||||
await click(".bootbox span.d-button-label");
|
await click(".bootbox span.d-button-label");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user