2018-04-06 11:36:57 +08:00
|
|
|
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
2017-12-04 21:47:11 +08:00
|
|
|
import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button";
|
2017-12-22 20:08:12 +08:00
|
|
|
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
2017-12-04 21:47:11 +08:00
|
|
|
|
|
|
|
acceptance("Poll Builder - polls are disabled", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
poll_enabled: false,
|
|
|
|
poll_minimum_trust_level_to_create: 2
|
2017-12-22 20:08:12 +08:00
|
|
|
},
|
|
|
|
beforeEach: function() {
|
|
|
|
clearPopupMenuOptionsCallback();
|
2017-12-04 21:47:11 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-12-05 07:03:56 +08:00
|
|
|
test("regular user - sufficient trust level", (assert) => {
|
|
|
|
replaceCurrentUser({ staff: false, trust_level: 3 });
|
2017-12-04 21:47:11 +08:00
|
|
|
|
|
|
|
displayPollBuilderButton();
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-12-13 17:49:32 +08:00
|
|
|
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
2017-12-04 21:47:11 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-05 07:03:56 +08:00
|
|
|
test("regular user - insufficient trust level", (assert) => {
|
|
|
|
replaceCurrentUser({ staff: false, trust_level: 1 });
|
2017-12-04 21:47:11 +08:00
|
|
|
|
|
|
|
displayPollBuilderButton();
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-12-13 17:49:32 +08:00
|
|
|
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
2017-12-04 21:47:11 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-05 07:03:56 +08:00
|
|
|
test("staff", (assert) => {
|
|
|
|
replaceCurrentUser({ staff: true });
|
2017-12-04 21:47:11 +08:00
|
|
|
|
|
|
|
displayPollBuilderButton();
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-12-13 17:49:32 +08:00
|
|
|
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
2017-12-04 21:47:11 +08:00
|
|
|
});
|
|
|
|
});
|