DEV: Fix leaky tests (#358)
This commit is contained in:
parent
86141dfe3d
commit
0adea550c0
|
@ -35,7 +35,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
bulkAction(username) {
|
bulkAction(username) {
|
||||||
this.topicBulkActions.performAndRefresh({
|
return this.topicBulkActions.performAndRefresh({
|
||||||
type: "assign",
|
type: "assign",
|
||||||
username,
|
username,
|
||||||
});
|
});
|
||||||
|
@ -44,8 +44,7 @@ export default Controller.extend({
|
||||||
@action
|
@action
|
||||||
assign() {
|
assign() {
|
||||||
if (this.isBulkAction) {
|
if (this.isBulkAction) {
|
||||||
this.bulkAction(this.model.username);
|
return this.bulkAction(this.model.username);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = "/assign/assign";
|
let path = "/assign/assign";
|
||||||
|
@ -86,8 +85,7 @@ export default Controller.extend({
|
||||||
@action
|
@action
|
||||||
assignUser(name) {
|
assignUser(name) {
|
||||||
if (this.isBulkAction) {
|
if (this.isBulkAction) {
|
||||||
this.bulkAction(name);
|
return this.bulkAction(name);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setGroupOrUser(name);
|
this.setGroupOrUser(name);
|
||||||
|
@ -100,8 +98,7 @@ export default Controller.extend({
|
||||||
@action
|
@action
|
||||||
assignUsername(selected) {
|
assignUsername(selected) {
|
||||||
if (this.isBulkAction) {
|
if (this.isBulkAction) {
|
||||||
this.bulkAction(selected.firstObject);
|
return this.bulkAction(selected.firstObject);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setGroupOrUser(selected.firstObject);
|
this.setGroupOrUser(selected.firstObject);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||||
|
import { cloneJSON } from "discourse-common/lib/object";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance(
|
acceptance(
|
||||||
|
@ -37,8 +38,9 @@ acceptance(
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
|
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
const assignments =
|
const assignments = cloneJSON(
|
||||||
AssignedTopics["/topics/messages-assigned/eviltrout.json"];
|
AssignedTopics["/topics/messages-assigned/eviltrout.json"]
|
||||||
|
);
|
||||||
assignments.topic_list.topics = [];
|
assignments.topic_list.topics = [];
|
||||||
server.get("/topics/messages-assigned/eviltrout.json", () =>
|
server.get("/topics/messages-assigned/eviltrout.json", () =>
|
||||||
helper.response(assignments)
|
helper.response(assignments)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
discourseModule("Unit | Controller | assign-user", function () {
|
discourseModule("Unit | Controller | assign-user", function () {
|
||||||
test("assigning a user via suggestions makes API call and closes the modal", function (assert) {
|
test("assigning a user via suggestions makes API call and closes the modal", async function (assert) {
|
||||||
pretender.get("/assign/suggestions", () => {
|
pretender.get("/assign/suggestions", () => {
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
|
@ -16,6 +16,7 @@ discourseModule("Unit | Controller | assign-user", function () {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
pretender.put("/assign/assign", () => {
|
pretender.put("/assign/assign", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, {}];
|
return [200, { "Content-Type": "application/json" }, {}];
|
||||||
});
|
});
|
||||||
|
@ -32,12 +33,12 @@ discourseModule("Unit | Controller | assign-user", function () {
|
||||||
modalClosed = true;
|
modalClosed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.send("assignUser", "nat");
|
await controller.assignUser("nat");
|
||||||
|
|
||||||
assert.strictEqual(modalClosed, true);
|
assert.strictEqual(modalClosed, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("assigning a user by selector does not close the modal", function (assert) {
|
test("assigning a user by selector does not close the modal", async function (assert) {
|
||||||
pretender.get("/assign/suggestions", () => {
|
pretender.get("/assign/suggestions", () => {
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
|
@ -62,7 +63,7 @@ discourseModule("Unit | Controller | assign-user", function () {
|
||||||
modalClosed = true;
|
modalClosed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.send("assignUsername", "nat");
|
await controller.assignUsername("nat");
|
||||||
|
|
||||||
assert.strictEqual(modalClosed, false);
|
assert.strictEqual(modalClosed, false);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue