mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
DEV: Support Node 15 with Ember CLI (#12679)
* DEV: Support Node 15 with Ember CLI * FIX: Broken tests that needed to be updated in newer Ember CLI
This commit is contained in:
parent
528cfea079
commit
0afcf9e12e
|
@ -639,7 +639,7 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_selectText(from, length) {
|
||||
schedule("afterRender", () => {
|
||||
next(() => {
|
||||
const textarea = this.element.querySelector("textarea.d-editor-input");
|
||||
const $textarea = $(textarea);
|
||||
const oldScrollPos = $textarea.scrollTop();
|
||||
|
@ -648,7 +648,7 @@ export default Component.extend({
|
|||
}
|
||||
textarea.selectionStart = from;
|
||||
textarea.selectionEnd = from + length;
|
||||
next(() => $textarea.trigger("change"));
|
||||
$textarea.trigger("change");
|
||||
$textarea.scrollTop(oldScrollPos);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
"@ember/test-helpers": "^2.2.0",
|
||||
"@glimmer/component": "^1.0.0",
|
||||
"@popperjs/core": "^2.4.4",
|
||||
"admin": "^1.0.0",
|
||||
|
@ -25,20 +26,20 @@
|
|||
"discourse-common": "^1.0.0",
|
||||
"discourse-hbr": "^1.0.0",
|
||||
"discourse-widget-hbs": "^1.0.0",
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^1.10.1",
|
||||
"ember-buffered-proxy": "^2.0.0-beta.0",
|
||||
"ember-cli": "~3.15.2",
|
||||
"ember-cli-app-version": "^3.2.0",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli": "~3.25.3",
|
||||
"ember-cli-app-version": "^4.0.0",
|
||||
"ember-cli-babel": "^7.23.1",
|
||||
"ember-cli-dependency-checker": "^3.2.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"ember-cli-inject-live-reload": "^2.0.1",
|
||||
"ember-cli-sri": "^2.1.1",
|
||||
"ember-cli-uglify": "^3.0.0",
|
||||
"ember-cli-terser": "^4.0.1",
|
||||
"ember-export-application-global": "^2.0.1",
|
||||
"ember-load-initializers": "^2.1.1",
|
||||
"ember-maybe-import-regenerator": "^0.1.6",
|
||||
"ember-qunit": "^4.6.0",
|
||||
"ember-qunit": "^5.1.2",
|
||||
"ember-source": "~3.15.0",
|
||||
"html-entities": "^2.1.0",
|
||||
"js-yaml": "^4.0.0",
|
||||
|
@ -48,7 +49,8 @@
|
|||
"mousetrap-global-bind": "^1.1.0",
|
||||
"pretender": "^3.4.3",
|
||||
"pretty-text": "^1.0.0",
|
||||
"qunit-dom": "^0.9.2",
|
||||
"qunit": "^2.14.0",
|
||||
"qunit-dom": "^1.6.0",
|
||||
"sass": "^1.32.8",
|
||||
"select-kit": "^1.0.0",
|
||||
"sinon": "^9.2.0",
|
||||
|
@ -64,8 +66,5 @@
|
|||
"paths": [
|
||||
"lib/bootstrap-json"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"sass": "^1.32.8"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ acceptance("Category Banners", function (needs) {
|
|||
id: 5,
|
||||
name: "test read only without banner",
|
||||
slug: "test-read-only-without-banner",
|
||||
permission: null,
|
||||
permission: 1,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
|
|
|
@ -27,7 +27,7 @@ acceptance("Category Edit", function (needs) {
|
|||
await fillIn("input.category-name", "testing");
|
||||
assert.equal(queryAll(".badge-category").text(), "testing");
|
||||
|
||||
await fillIn(".edit-text-color input", "#ff0000");
|
||||
await fillIn(".edit-text-color input", "ff0000");
|
||||
|
||||
await click(".edit-category-topic-template");
|
||||
await fillIn(".d-editor-input", "this is the new topic template");
|
||||
|
|
|
@ -126,7 +126,7 @@ acceptance("User Preferences", function (needs) {
|
|||
|
||||
await click(".preferences-nav .nav-interface a");
|
||||
await click(".control-group.other input[type=checkbox]:nth-of-type(1)");
|
||||
savePreferences();
|
||||
await savePreferences();
|
||||
|
||||
assert.ok(
|
||||
!exists(".preferences-nav .nav-apps a"),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { click, fillIn } from "@ember/test-helpers";
|
||||
import { click, fillIn, settled } from "@ember/test-helpers";
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
|
@ -57,7 +57,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
|
|||
"<p>evil trout</p>"
|
||||
);
|
||||
|
||||
await this.set("value", "zogstrip");
|
||||
this.set("value", "zogstrip");
|
||||
await settled();
|
||||
|
||||
assert.equal(
|
||||
queryAll(".d-editor-preview").html().trim(),
|
||||
"<p>zogstrip</p>"
|
||||
|
@ -704,10 +706,11 @@ third line`
|
|||
assert.equal(this.value, "red yellow blue");
|
||||
});
|
||||
|
||||
function paste(element, text) {
|
||||
async function paste(element, text) {
|
||||
let e = new Event("paste");
|
||||
e.clipboardData = { getData: () => text };
|
||||
element.dispatchEvent(e);
|
||||
await settled();
|
||||
}
|
||||
|
||||
componentTest("paste table", {
|
||||
|
@ -721,9 +724,18 @@ third line`
|
|||
let element = queryAll(".d-editor")[0];
|
||||
await paste(element, "\ta\tb\n1\t2\t3");
|
||||
assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2|3|\n");
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("paste a different table", {
|
||||
template: hbs`{{d-editor value=value composerEvents=true}}`,
|
||||
beforeEach() {
|
||||
this.set("value", "");
|
||||
this.siteSettings.enable_rich_text_paste = true;
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
let element = queryAll(".d-editor")[0];
|
||||
await paste(element, '\ta\tb\n1\t"2\n2.5"\t3');
|
||||
assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2<br>2.5|3|\n");
|
||||
},
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
import {
|
||||
discourseModule,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
|
||||
discourseModule(
|
||||
"Integration | Component | group-membership-button",
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("canJoinGroup", {
|
||||
template: hbs`{{group-membership-button model=model}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("model", { public_admission: false, is_group_user: true });
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(
|
||||
queryAll(".group-index-join").length === 0,
|
||||
"can't join group if public_admission is false"
|
||||
);
|
||||
|
||||
this.set("model.public_admission", true);
|
||||
assert.ok(
|
||||
queryAll(".group-index-join").length === 0,
|
||||
"can't join group if user is already in the group"
|
||||
);
|
||||
|
||||
this.set("model.is_group_user", false);
|
||||
assert.ok(
|
||||
queryAll(".group-index-join").length,
|
||||
"allowed to join group"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("canLeaveGroup", {
|
||||
template: hbs`{{group-membership-button model=model}}`,
|
||||
beforeEach() {
|
||||
this.set("model", { public_exit: false, is_group_user: false });
|
||||
},
|
||||
async test(assert) {
|
||||
assert.ok(
|
||||
queryAll(".group-index-leave").length === 0,
|
||||
"can't leave group if public_exit is false"
|
||||
);
|
||||
|
||||
this.set("model.public_exit", true);
|
||||
assert.ok(
|
||||
queryAll(".group-index-leave").length === 0,
|
||||
"can't leave group if user is not in the group"
|
||||
);
|
||||
|
||||
this.set("model.is_group_user", true);
|
||||
assert.ok(
|
||||
queryAll(".group-index-leave").length === 1,
|
||||
"allowed to leave group"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("canRequestMembership", {
|
||||
template: hbs`{{group-membership-button model=model}}`,
|
||||
beforeEach() {
|
||||
this.set("model", {
|
||||
allow_membership_requests: true,
|
||||
is_group_user: true,
|
||||
});
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(
|
||||
queryAll(".group-index-request").length === 0,
|
||||
"can't request for membership if user is already in the group"
|
||||
);
|
||||
this.set("model.is_group_user", false);
|
||||
assert.ok(
|
||||
queryAll(".group-index-request").length,
|
||||
"allowed to request for group membership"
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
|
@ -8,6 +8,7 @@ import {
|
|||
import EmberObject from "@ember/object";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
|
||||
discourseModule(
|
||||
"Integration | Component | Widget | default-notification-item",
|
||||
|
@ -60,13 +61,14 @@ discourseModule(
|
|||
|
||||
assert.equal(queryAll("li.read").length, 0);
|
||||
|
||||
await $(document).trigger(
|
||||
$(document).trigger(
|
||||
$.Event("mouseup", {
|
||||
target: queryAll("li")[0],
|
||||
button: 1,
|
||||
which: 2,
|
||||
})
|
||||
);
|
||||
await settled();
|
||||
|
||||
assert.equal(queryAll("li.read").length, 1);
|
||||
assert.equal(requests, 1);
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
import { moduleFor } from "ember-qunit";
|
||||
import { test } from "qunit";
|
||||
|
||||
// TODO: Convert to a modern *integration* test
|
||||
moduleFor("component:group-membership-button");
|
||||
|
||||
test("canJoinGroup", function (assert) {
|
||||
this.subject().setProperties({
|
||||
model: { public_admission: false, is_group_user: true },
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canJoinGroup"),
|
||||
false,
|
||||
"can't join group if public_admission is false"
|
||||
);
|
||||
|
||||
this.subject().set("model.public_admission", true);
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canJoinGroup"),
|
||||
false,
|
||||
"can't join group if user is already in the group"
|
||||
);
|
||||
|
||||
this.subject().set("model.is_group_user", false);
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canJoinGroup"),
|
||||
true,
|
||||
"allowed to join group"
|
||||
);
|
||||
});
|
||||
|
||||
test("canLeaveGroup", function (assert) {
|
||||
this.subject().setProperties({
|
||||
model: { public_exit: false, is_group_user: false },
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canLeaveGroup"),
|
||||
false,
|
||||
"can't leave group if public_exit is false"
|
||||
);
|
||||
|
||||
this.subject().set("model.public_exit", true);
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canLeaveGroup"),
|
||||
false,
|
||||
"can't leave group if user is not in the group"
|
||||
);
|
||||
|
||||
this.subject().set("model.is_group_user", true);
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canLeaveGroup"),
|
||||
true,
|
||||
"allowed to leave group"
|
||||
);
|
||||
});
|
||||
|
||||
test("canRequestMembership", function (assert) {
|
||||
this.subject().setProperties({
|
||||
model: { allow_membership_requests: true, is_group_user: true },
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canRequestMembership"),
|
||||
false,
|
||||
"can't request for membership if user is already in the group"
|
||||
);
|
||||
|
||||
this.subject().set("model.is_group_user", false);
|
||||
|
||||
assert.equal(
|
||||
this.subject().get("canRequestMembership"),
|
||||
true,
|
||||
"allowed to request for group membership"
|
||||
);
|
||||
});
|
||||
|
||||
test("userIsGroupUser", function (assert) {
|
||||
this.subject().setProperties({
|
||||
model: { is_group_user: true },
|
||||
});
|
||||
|
||||
assert.equal(this.subject().get("userIsGroupUser"), true);
|
||||
|
||||
this.subject().set("model.is_group_user", false);
|
||||
|
||||
assert.equal(this.subject().get("userIsGroupUser"), false);
|
||||
|
||||
this.subject().set("model.is_group_user", null);
|
||||
|
||||
assert.equal(this.subject().get("userIsGroupUser"), false);
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user