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