2017-11-28 02:50:04 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("Category Edit - security", {
|
|
|
|
loggedIn: true
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("default", assert => {
|
|
|
|
visit("/c/bug");
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".edit-category");
|
|
|
|
click("li.edit-category-security a");
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
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");
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("removing a permission", assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
|
2017-11-28 02:50:04 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".edit-category");
|
|
|
|
click("li.edit-category-security a");
|
|
|
|
click(".edit-category-tab-security .edit-permission");
|
2017-12-22 20:08:12 +08:00
|
|
|
availableGroups.expand();
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.notOk(
|
|
|
|
availableGroups.rowByValue("everyone").exists(),
|
|
|
|
"everyone is already used and is not in the available groups"
|
|
|
|
);
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(
|
|
|
|
".edit-category-tab-security .permission-list li:first-of-type .remove-permission"
|
|
|
|
);
|
2017-12-22 20:08:12 +08:00
|
|
|
availableGroups.expand();
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.ok(
|
|
|
|
availableGroups.rowByValue("everyone").exists(),
|
|
|
|
"everyone has been removed and appears in the available groups"
|
|
|
|
);
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("adding a permission", assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
const permissionSelector = selectKit(".permission-selector");
|
|
|
|
|
2017-11-28 02:50:04 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".edit-category");
|
|
|
|
click("li.edit-category-security a");
|
|
|
|
click(".edit-category-tab-security .edit-permission");
|
|
|
|
availableGroups.expand().selectRowByValue("staff");
|
|
|
|
permissionSelector.expand().selectRowByValue("2");
|
|
|
|
click(".edit-category-tab-security .add-permission");
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const $addedPermissionItem = find(
|
|
|
|
".edit-category-tab-security .permission-list li:nth-child(2)"
|
|
|
|
);
|
2017-11-28 02:50:04 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
const badgeName = $addedPermissionItem.find(".badge-group").text();
|
|
|
|
assert.equal(badgeName, "staff");
|
2017-11-28 02:50:04 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
const permission = $addedPermissionItem.find(".permission").text();
|
|
|
|
assert.equal(permission, "Reply / See");
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("adding a previously removed permission", assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const availableGroups = selectKit(".available-groups");
|
|
|
|
|
2017-11-28 02:50:04 +08:00
|
|
|
visit("/c/bug");
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
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"
|
|
|
|
);
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".edit-category-tab-security .permission-list li").length,
|
|
|
|
0,
|
|
|
|
"it removes the permission from the list"
|
|
|
|
);
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
availableGroups.expand().selectRowByValue("everyone");
|
|
|
|
click(".edit-category-tab-security .add-permission");
|
2017-11-28 02:50:04 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
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");
|
2017-11-28 02:50:04 +08:00
|
|
|
});
|
|
|
|
});
|