add test for small-action-post

This commit is contained in:
awesomerobot 2022-12-19 17:28:13 -05:00 committed by Alan Guo Xiang Tan
parent 7ef731a5b0
commit 00fdeb422c
No known key found for this signature in database
GPG Key ID: 3F656E28E3AADEF1
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { render } from "@ember/test-helpers";
import { test } from "qunit";
import { withPluginApi } from "discourse/lib/plugin-api";
discourseModule(
"Discourse Assign | Integration | Widget | Small Action Post Class",
function (hooks) {
setupRenderingTest(hooks);
test("When assigns are not public add a private-assign class to the small post", async function (assert) {
this.siteSettings.assigns_public = false;
this.set("args", {
id: 10,
actionCode: "assigned",
});
withPluginApi("1.6.0", (api) => {
api.addPostSmallActionClassesCallback((post) => {
if (
post.actionCode.includes("assigned") &&
!this.siteSettings.assigns_public
) {
return ["private-assign"];
}
});
});
await render(
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
);
assert.ok(exists(".small-action.private-assign"));
this.siteSettings.assigns_public = true;
await render(
hbs`<MountWidget @widget="post-small-action" @args={{this.args}} />`
);
assert.ok(!exists(".small-action.private-assign"));
});
}
);