fix test
This commit is contained in:
parent
90ed1eb96c
commit
aaf05abf16
|
|
@ -4,6 +4,7 @@ import hbs from "htmlbars-inline-precompile";
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import { resetPostSmallActionClassesCallbacks } from "discourse/widgets/post-small-action";
|
||||||
|
|
||||||
discourseModule(
|
discourseModule(
|
||||||
"Discourse Assign | Integration | Widget | Small Action Post Class",
|
"Discourse Assign | Integration | Widget | Small Action Post Class",
|
||||||
|
|
@ -11,55 +12,63 @@ discourseModule(
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("Adds private-assign class when assigns are not public", async function (assert) {
|
test("Adds private-assign class when assigns are not public", async function (assert) {
|
||||||
this.siteSettings.assigns_public = false;
|
try {
|
||||||
|
this.siteSettings.assigns_public = false;
|
||||||
|
|
||||||
this.set("args", {
|
this.set("args", {
|
||||||
id: 10,
|
id: 10,
|
||||||
actionCode: "assigned",
|
actionCode: "assigned",
|
||||||
});
|
|
||||||
|
|
||||||
withPluginApi("1.6.0", (api) => {
|
|
||||||
api.addPostSmallActionClassesCallback((post) => {
|
|
||||||
if (
|
|
||||||
post.actionCode.includes("assigned") &&
|
|
||||||
!this.siteSettings.assigns_public
|
|
||||||
) {
|
|
||||||
return ["private-assign"];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await render(
|
withPluginApi("1.6.0", (api) => {
|
||||||
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
|
api.addPostSmallActionClassesCallback((post) => {
|
||||||
);
|
if (
|
||||||
|
post.actionCode.includes("assigned") &&
|
||||||
|
!this.siteSettings.assigns_public
|
||||||
|
) {
|
||||||
|
return ["private-assign"];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
assert.ok(exists(".small-action.private-assign"));
|
await render(
|
||||||
|
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(exists(".small-action.private-assign"));
|
||||||
|
} finally {
|
||||||
|
resetPostSmallActionClassesCallbacks();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Does not add private-assign class when assigns are public", async function (assert) {
|
test("Does not add private-assign class when assigns are public", async function (assert) {
|
||||||
this.siteSettings.assigns_public = true;
|
try {
|
||||||
|
this.siteSettings.assigns_public = true;
|
||||||
|
|
||||||
this.set("args", {
|
this.set("args", {
|
||||||
id: 10,
|
id: 10,
|
||||||
actionCode: "assigned",
|
actionCode: "assigned",
|
||||||
});
|
|
||||||
|
|
||||||
withPluginApi("1.6.0", (api) => {
|
|
||||||
api.addPostSmallActionClassesCallback((post) => {
|
|
||||||
if (
|
|
||||||
post.actionCode.includes("assigned") &&
|
|
||||||
!this.siteSettings.assigns_public
|
|
||||||
) {
|
|
||||||
return ["private-assign"];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await render(
|
withPluginApi("1.6.0", (api) => {
|
||||||
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
|
api.addPostSmallActionClassesCallback((post) => {
|
||||||
);
|
if (
|
||||||
|
post.actionCode.includes("assigned") &&
|
||||||
|
!this.siteSettings.assigns_public
|
||||||
|
) {
|
||||||
|
return ["private-assign"];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
assert.ok(!exists(".small-action.private-assign"));
|
await render(
|
||||||
|
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(!exists(".small-action.private-assign"));
|
||||||
|
} finally {
|
||||||
|
resetPostSmallActionClassesCallbacks();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue