mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
DEV: Avoid using globals (#14909)
This commit is contained in:
parent
4ad77f3382
commit
bdd2c888b0
36
.eslintrc
36
.eslintrc
|
@ -5,15 +5,41 @@
|
|||
"eol-last": 2
|
||||
},
|
||||
"globals": {
|
||||
"_": "off",
|
||||
"acceptance": "off",
|
||||
"asyncRender": "off",
|
||||
"bootbox": "off",
|
||||
"click": "off",
|
||||
"count": "off",
|
||||
"currentPath": "off",
|
||||
"currentRouteName": "off",
|
||||
"currentURL": "off",
|
||||
"currentUser": "off",
|
||||
"Discourse": "off",
|
||||
"exists": "off",
|
||||
"fillIn": "off",
|
||||
"find": "off",
|
||||
"getSettledState": "off",
|
||||
"hasModule": "off",
|
||||
"invisible": "off",
|
||||
"jQuery": "off",
|
||||
"keyboardHelper": "off",
|
||||
"keyEvent": "off",
|
||||
"moduleFor": "off",
|
||||
"moduleForComponent": "off",
|
||||
"testStart": "off",
|
||||
"testDone": "off",
|
||||
"pauseTest": "off",
|
||||
"Pretender": "off",
|
||||
"query": "off",
|
||||
"queryAll": "off",
|
||||
"QUnit": "off",
|
||||
"sandbox": "off",
|
||||
"sinon": "off",
|
||||
"currentURL": "off",
|
||||
"invisible": "off",
|
||||
"test": "off",
|
||||
"testDone": "off",
|
||||
"testStart": "off",
|
||||
"triggerEvent": "off",
|
||||
"visible": "off",
|
||||
"count": "off"
|
||||
"visit": "off",
|
||||
"waitUntil": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { COMPONENTS, THEMES } from "admin/models/theme";
|
|||
import I18n from "I18n";
|
||||
import Route from "@ember/routing/route";
|
||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export function showUnassignedComponentWarning(theme, callback) {
|
||||
bootbox.confirm(
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { empty } from "@ember/object/computed";
|
||||
import { bind, default as computed } from "discourse-common/utils/decorators";
|
||||
import computed, { bind } from "discourse-common/utils/decorators";
|
||||
import I18n from "I18n";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["pick-files-button"],
|
||||
|
|
|
@ -5,6 +5,7 @@ import { getWebauthnCredential } from "discourse/lib/webauthn";
|
|||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { SECOND_FACTOR_METHODS } from "discourse/models/user";
|
||||
import I18n from "I18n";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
showSecondFactor: false,
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
validateUploadedFile,
|
||||
} from "discourse/lib/uploads";
|
||||
import { cacheShortUploadUrl } from "pretty-text/upload-short-url";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
// Note: This mixin is used _in addition_ to the ComposerUpload mixin
|
||||
// on the composer-editor component. It overrides some, but not all,
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
validateUploadedFiles,
|
||||
} from "discourse/lib/uploads";
|
||||
import { cacheShortUploadUrl } from "pretty-text/upload-short-url";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export default Mixin.create({
|
||||
_xhr: null,
|
||||
|
|
|
@ -16,6 +16,7 @@ import UppyChecksum from "discourse/lib/uppy-checksum-plugin";
|
|||
import UppyS3Multipart from "discourse/mixins/uppy-s3-multipart";
|
||||
import { on } from "discourse-common/utils/decorators";
|
||||
import { warn } from "@ember/debug";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export const HUGE_FILE_THRESHOLD_BYTES = 104_857_600; // 100MB
|
||||
|
||||
|
|
|
@ -224,6 +224,7 @@ Site.reopenClass(Singleton, {
|
|||
|
||||
if (typeof Discourse !== "undefined") {
|
||||
let warned = false;
|
||||
// eslint-disable-next-line no-undef
|
||||
Object.defineProperty(Discourse, "Site", {
|
||||
get() {
|
||||
if (!warned) {
|
||||
|
|
|
@ -1125,6 +1125,7 @@ User.reopenClass(Singleton, {
|
|||
|
||||
if (typeof Discourse !== "undefined") {
|
||||
let warned = false;
|
||||
// eslint-disable-next-line no-undef
|
||||
Object.defineProperty(Discourse, "User", {
|
||||
get() {
|
||||
if (!warned) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
acceptance,
|
||||
count,
|
||||
exists,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
|
@ -91,16 +92,16 @@ acceptance("Admin - Watched Words", function (needs) {
|
|||
await visit("/admin/customize/watched_words/action/replace");
|
||||
await click(".watched-word-test");
|
||||
await fillIn(".modal-body textarea", "Hi there!");
|
||||
assert.strictEqual(find(".modal-body li .match").text(), "Hi");
|
||||
assert.strictEqual(find(".modal-body li .replacement").text(), "hello");
|
||||
assert.strictEqual(query(".modal-body li .match").innerText, "Hi");
|
||||
assert.strictEqual(query(".modal-body li .replacement").innerText, "hello");
|
||||
});
|
||||
|
||||
test("test modal - tag", async function (assert) {
|
||||
await visit("/admin/customize/watched_words/action/tag");
|
||||
await click(".watched-word-test");
|
||||
await fillIn(".modal-body textarea", "Hello world!");
|
||||
assert.strictEqual(find(".modal-body li .match").text(), "Hello");
|
||||
assert.strictEqual(find(".modal-body li .tag").text(), "greeting");
|
||||
assert.strictEqual(query(".modal-body li .match").innerText, "Hello");
|
||||
assert.strictEqual(query(".modal-body li .tag").innerText, "greeting");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
import { skip, test } from "qunit";
|
||||
|
||||
acceptance("Composer - Edit conflict", function (needs) {
|
||||
needs.user();
|
||||
|
@ -14,26 +14,23 @@ acceptance("Composer - Edit conflict", function (needs) {
|
|||
});
|
||||
});
|
||||
|
||||
QUnit.skip(
|
||||
"Edit a post that causes an edit conflict",
|
||||
async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".topic-post:nth-of-type(1) button.show-more-actions");
|
||||
await click(".topic-post:nth-of-type(1) button.edit");
|
||||
await fillIn(".d-editor-input", "this will 409");
|
||||
await click("#reply-control button.create");
|
||||
assert.strictEqual(
|
||||
queryAll("#reply-control button.create").text().trim(),
|
||||
I18n.t("composer.overwrite_edit"),
|
||||
"it shows the overwrite button"
|
||||
);
|
||||
assert.ok(
|
||||
queryAll("#draft-status .d-icon-user-edit"),
|
||||
"error icon should be there"
|
||||
);
|
||||
await click(".modal .btn-primary");
|
||||
}
|
||||
);
|
||||
skip("Edit a post that causes an edit conflict", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".topic-post:nth-of-type(1) button.show-more-actions");
|
||||
await click(".topic-post:nth-of-type(1) button.edit");
|
||||
await fillIn(".d-editor-input", "this will 409");
|
||||
await click("#reply-control button.create");
|
||||
assert.strictEqual(
|
||||
queryAll("#reply-control button.create").text().trim(),
|
||||
I18n.t("composer.overwrite_edit"),
|
||||
"it shows the overwrite button"
|
||||
);
|
||||
assert.ok(
|
||||
queryAll("#draft-status .d-icon-user-edit"),
|
||||
"error icon should be there"
|
||||
);
|
||||
await click(".modal .btn-primary");
|
||||
});
|
||||
|
||||
test("Should not send originalText when posting a new reply", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
|
|
|
@ -379,11 +379,9 @@ acceptance("Composer", function (needs) {
|
|||
|
||||
// at this point, request is in flight, so post is staged
|
||||
assert.strictEqual(count(".topic-post.staged"), 1);
|
||||
assert.ok(
|
||||
find(".topic-post:nth-of-type(1)")[0].className.includes("staged")
|
||||
);
|
||||
assert.ok(query(".topic-post:nth-of-type(1)").className.includes("staged"));
|
||||
assert.strictEqual(
|
||||
find(".topic-post.staged .cooked").text().trim(),
|
||||
query(".topic-post.staged .cooked").innerText.trim(),
|
||||
"will return empty json"
|
||||
);
|
||||
|
||||
|
@ -394,26 +392,23 @@ acceptance("Composer", function (needs) {
|
|||
assert.strictEqual(count(".topic-post.staged"), 0);
|
||||
});
|
||||
|
||||
QUnit.skip(
|
||||
"Editing a post can rollback to old content",
|
||||
async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".topic-post:nth-of-type(1) button.show-more-actions");
|
||||
await click(".topic-post:nth-of-type(1) button.edit");
|
||||
skip("Editing a post can rollback to old content", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".topic-post:nth-of-type(1) button.show-more-actions");
|
||||
await click(".topic-post:nth-of-type(1) button.edit");
|
||||
|
||||
await fillIn(".d-editor-input", "this will 409");
|
||||
await fillIn("#reply-title", "This is the new text for the title");
|
||||
await click("#reply-control button.create");
|
||||
await fillIn(".d-editor-input", "this will 409");
|
||||
await fillIn("#reply-title", "This is the new text for the title");
|
||||
await click("#reply-control button.create");
|
||||
|
||||
assert.ok(!exists(".topic-post.staged"));
|
||||
assert.strictEqual(
|
||||
find(".topic-post .cooked")[0].innerText,
|
||||
"Any plans to support localization of UI elements, so that I (for example) could set up a completely German speaking forum?"
|
||||
);
|
||||
assert.ok(!exists(".topic-post.staged"));
|
||||
assert.strictEqual(
|
||||
query(".topic-post .cooked").innerText,
|
||||
"Any plans to support localization of UI elements, so that I (for example) could set up a completely German speaking forum?"
|
||||
);
|
||||
|
||||
await click(".bootbox.modal .btn-primary");
|
||||
}
|
||||
);
|
||||
await click(".bootbox.modal .btn-primary");
|
||||
});
|
||||
|
||||
test("Composer can switch between edits", async function (assert) {
|
||||
await visit("/t/this-is-a-test-topic/9");
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
count,
|
||||
exists,
|
||||
fakeTime,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
|
@ -53,7 +54,7 @@ acceptance("Invites - Create & Edit Invite Modal", function (needs) {
|
|||
await visit("/u/eviltrout/invited/pending");
|
||||
await click(".user-invite-buttons .btn:first-child");
|
||||
assert.strictEqual(
|
||||
find("input.invite-link")[0].value,
|
||||
query("input.invite-link").value,
|
||||
"http://example.com/invites/52641ae8878790bc7b79916247cfe6ba",
|
||||
"shows an invite link when modal is opened"
|
||||
);
|
||||
|
@ -102,7 +103,7 @@ acceptance("Invites - Create & Edit Invite Modal", function (needs) {
|
|||
await fillIn("#invite-email", "error");
|
||||
await click(".invite-link .btn");
|
||||
assert.strictEqual(
|
||||
find("#modal-alert").text(),
|
||||
query("#modal-alert").innerText,
|
||||
"error isn't a valid email address."
|
||||
);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
queryAll,
|
||||
selectText,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Fast Edit", function (needs) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { skip, test } from "qunit";
|
||||
import userFixtures from "discourse/tests/fixtures/user-fixtures";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
acceptance,
|
||||
count,
|
||||
exists,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { test } from "qunit";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { currentURL, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import I18n from "I18n";
|
||||
import {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
selectText,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import I18n from "I18n";
|
||||
import { triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
// This tests are flaky on Firefox. Fails with `calling set on destroyed object`
|
||||
|
|
|
@ -9,7 +9,7 @@ import User from "discourse/models/user";
|
|||
import { autoLoadModules } from "discourse/initializers/auto-load-modules";
|
||||
import createStore from "discourse/tests/helpers/create-store";
|
||||
import { currentSettings } from "discourse/tests/helpers/site-settings";
|
||||
import { test } from "qunit";
|
||||
import QUnit, { test } from "qunit";
|
||||
|
||||
const LEGACY_ENV = !EmberSetupRenderingTest;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import I18n from "I18n";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { click } from "@ember/test-helpers";
|
||||
|
||||
discourseModule("Integration | Component | bookmark", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import I18n from "I18n";
|
||||
import { click } from "@ember/test-helpers";
|
||||
|
||||
discourseModule("Integration | Component | hidden-details", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
|
|
@ -5,7 +5,11 @@ import componentTest, {
|
|||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import {
|
||||
discourseModule,
|
||||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
|
||||
|
@ -45,7 +49,7 @@ discourseModule("Integration | Component | invite-panel", function (hooks) {
|
|||
assert.ok(!exists(".send-invite:disabled"));
|
||||
await click(".generate-invite-link");
|
||||
assert.strictEqual(
|
||||
find(".invite-link-input")[0].value,
|
||||
query(".invite-link-input").value,
|
||||
"http://example.com/invites/92c297e886a0ca03089a109ccd6be155"
|
||||
);
|
||||
},
|
||||
|
|
|
@ -5,6 +5,7 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
|||
import hbs from "htmlbars-inline-precompile";
|
||||
import { triggerEvent } from "@ember/test-helpers";
|
||||
import sinon from "sinon";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
function createBlob(mimeType, extension) {
|
||||
const blob = new Blob(["content"], {
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { click } from "@ember/test-helpers";
|
||||
|
||||
discourseModule("Integration | Component | site-header", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
applyCachedInlineOnebox,
|
||||
deleteCachedInlineOnebox,
|
||||
} from "pretty-text/inline-oneboxer";
|
||||
import { module, skip, test } from "qunit";
|
||||
import QUnit, { module, skip, test } from "qunit";
|
||||
import Post from "discourse/models/post";
|
||||
import { buildQuote } from "discourse/lib/quote";
|
||||
import { deepMerge } from "discourse-common/lib/object";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// discourse-skip-module
|
||||
(function () {
|
||||
// eslint-disable-next-line no-undef
|
||||
Discourse.start();
|
||||
})();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { currentRouteName, visit } from "@ember/test-helpers";
|
||||
import { click, currentRouteName, fillIn, visit } from "@ember/test-helpers";
|
||||
import { module, test } from "qunit";
|
||||
import { run } from "@ember/runloop";
|
||||
import startApp from "wizard/test/helpers/start-app";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { componentTest } from "wizard/test/helpers/component-test";
|
||||
import { moduleForComponent } from "ember-qunit";
|
||||
import { click, fillIn } from "@ember/test-helpers";
|
||||
|
||||
moduleForComponent("invite-list", { integration: true });
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user