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