2017-11-27 13:50:04 -05:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("Category Edit - security", {
|
|
|
|
loggedIn: true
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("default", assert => {
|
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('li.edit-category-security a');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const $permissionListItems = find('.permission-list li');
|
|
|
|
|
|
|
|
const badgeName = $permissionListItems.eq(0).find('.badge-group').text();
|
|
|
|
assert.equal(badgeName, 'everyone');
|
|
|
|
|
|
|
|
const permission = $permissionListItems.eq(0).find('.permission').text();
|
|
|
|
assert.equal(permission, 'Create / Reply / See');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("removing a permission", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
|
2017-11-27 13:50:04 -05:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('li.edit-category-security a');
|
|
|
|
click('.edit-category-tab-security .edit-permission');
|
2017-12-22 07:08:12 -05:00
|
|
|
availableGroups.expand();
|
2017-11-27 13:50:04 -05:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-12-22 07:08:12 -05:00
|
|
|
assert.notOk(availableGroups.rowByValue('everyone').exists(), 'everyone is already used and is not in the available groups');
|
2017-11-27 13:50:04 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.edit-category-tab-security .permission-list li:first-of-type .remove-permission');
|
2017-12-22 07:08:12 -05:00
|
|
|
availableGroups.expand();
|
2017-11-27 13:50:04 -05:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-12-22 07:08:12 -05:00
|
|
|
assert.ok(availableGroups.rowByValue('everyone').exists(), 'everyone has been removed and appears in the available groups');
|
2017-11-27 13:50:04 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("adding a permission", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
const permissionSelector = selectKit(".permission-selector");
|
|
|
|
|
2017-11-27 13:50:04 -05:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('li.edit-category-security a');
|
|
|
|
click('.edit-category-tab-security .edit-permission');
|
2017-12-22 07:08:12 -05:00
|
|
|
availableGroups.expand().selectRowByValue('staff');
|
|
|
|
permissionSelector.expand().selectRowByValue('2');
|
2017-11-27 13:50:04 -05:00
|
|
|
click('.edit-category-tab-security .add-permission');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const $addedPermissionItem = find('.edit-category-tab-security .permission-list li:nth-child(2)');
|
|
|
|
|
|
|
|
const badgeName = $addedPermissionItem.find('.badge-group').text();
|
|
|
|
assert.equal(badgeName, 'staff');
|
|
|
|
|
|
|
|
const permission = $addedPermissionItem.find('.permission').text();
|
|
|
|
assert.equal(permission, 'Reply / See');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("adding a previously removed permission", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
|
2017-11-27 13:50:04 -05:00
|
|
|
visit("/c/bug");
|
|
|
|
|
|
|
|
click('.edit-category');
|
|
|
|
click('li.edit-category-security a');
|
|
|
|
click('.edit-category-tab-security .edit-permission');
|
|
|
|
click('.edit-category-tab-security .permission-list li:first-of-type .remove-permission');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find(".edit-category-tab-security .permission-list li").length, 0, 'it removes the permission from the list');
|
|
|
|
});
|
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
availableGroups.expand().selectRowByValue('everyone');
|
2017-11-27 13:50:04 -05:00
|
|
|
click('.edit-category-tab-security .add-permission');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find(".edit-category-tab-security .permission-list li").length, 1, 'it adds the permission to the list');
|
|
|
|
|
|
|
|
const $permissionListItems = find('.permission-list li');
|
|
|
|
|
|
|
|
const badgeName = $permissionListItems.eq(0).find('.badge-group').text();
|
|
|
|
assert.equal(badgeName, 'everyone');
|
|
|
|
|
|
|
|
const permission = $permissionListItems.eq(0).find('.permission').text();
|
|
|
|
assert.equal(permission, 'Create / Reply / See');
|
|
|
|
});
|
|
|
|
});
|