This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/slow-mode-info-test.js
Andrei Prigorshnev a5dd24c445
DEV: fix warnings 'Hbs template must be compiled and not a string' in tests (#13116)
These warnings appeared only when running tests using Ember CLI.
2021-05-21 19:58:18 +04:00

83 lines
2.0 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import {
discourseModule,
exists,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
discourseModule("Integration | Component | slow-mode-info", function (hooks) {
setupRenderingTest(hooks);
componentTest("doesn't render if the topic is closed", {
template: "{{slow-mode-info topic=topic}}",
beforeEach() {
this.set("topic", { slow_mode_seconds: 3600, closed: true });
},
test(assert) {
assert.ok(!exists(".slow-mode-heading"), "it doesn't render the notice");
},
});
componentTest("doesn't render if the slow mode is disabled", {
template: hbs`{{slow-mode-info topic=topic}}`,
beforeEach() {
this.set("topic", { slow_mode_seconds: 0, closed: false });
},
test(assert) {
assert.ok(!exists(".slow-mode-heading"), "it doesn't render the notice");
},
});
componentTest("renders if slow mode is enabled", {
template: hbs`{{slow-mode-info topic=topic}}`,
beforeEach() {
this.set("topic", { slow_mode_seconds: 3600, closed: false });
},
test(assert) {
assert.ok(queryAll(".slow-mode-heading").length === 1);
},
});
componentTest("staff and TL4 users can disable slow mode", {
template: hbs`{{slow-mode-info topic=topic user=user}}`,
beforeEach() {
this.setProperties({
topic: { slow_mode_seconds: 3600, closed: false },
user: { canManageTopic: true },
});
},
test(assert) {
assert.ok(queryAll(".slow-mode-remove").length === 1);
},
});
componentTest("regular users can't disable slow mode", {
template: hbs`{{slow-mode-info topic=topic user=user}}`,
beforeEach() {
this.setProperties({
topic: { slow_mode_seconds: 3600, closed: false },
user: { canManageTopic: false },
});
},
test(assert) {
assert.ok(
!exists(".slow-mode-remove"),
"it doesn't let you disable slow mode"
);
},
});
});