discourse/test/javascripts/acceptance/group-manage-membership-test.js
jbrw aa1fc01307
FEATURE - Moderators can create and manage groups (#10432)
Enabling the moderators_manage_categories_and_groups site setting will allow moderator users to create/manage groups.

* show New Group form to moderators

* Allow moderators to update groups and read logs, where appropriate

* Rename site setting from create -> manage

* improved tests

* Migration should rename old log entries

* Log group changes, even if those changes mean you can no longer see the group

* Slight reshuffle

* RouteTo /g if they no longer have permissions to view group
2020-08-19 10:41:40 -04:00

120 lines
3.2 KiB
JavaScript

import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
import selectKit from "helpers/select-kit-helper";
acceptance("Managing Group Membership", {
loggedIn: true
});
QUnit.test("As an admin", async assert => {
updateCurrentUser({ can_create_group: true });
await visit("/g/alternative-group/manage/membership");
assert.ok(
find('label[for="automatic_membership"]').length === 1,
"it should display automatic membership label"
);
assert.ok(
find(".groups-form-primary-group").length === 1,
"it should display set as primary group checkbox"
);
assert.ok(
find(".groups-form-grant-trust-level").length === 1,
"it should display grant trust level selector"
);
assert.ok(
find(".group-form-public-admission").length === 1,
"it should display group public admission input"
);
assert.ok(
find(".group-form-public-exit").length === 1,
"it should display group public exit input"
);
assert.ok(
find(".group-form-allow-membership-requests").length === 1,
"it should display group allow_membership_request input"
);
assert.ok(
find(".group-form-allow-membership-requests[disabled]").length === 1,
"it should disable group allow_membership_request input"
);
await click(".group-form-public-admission");
await click(".group-form-allow-membership-requests");
assert.ok(
find(".group-form-public-admission[disabled]").length === 1,
"it should disable group public admission input"
);
assert.ok(
find(".group-form-public-exit[disabled]").length === 0,
"it should not disable group public exit input"
);
assert.equal(
find(".group-form-membership-request-template").length,
1,
"it should display the membership request template field"
);
const emailDomains = selectKit(".group-form-automatic-membership-automatic");
await emailDomains.expand();
await emailDomains.fillInFilter("foo.com");
await emailDomains.keyboard("enter");
assert.equal(emailDomains.header().value(), "foo.com");
});
QUnit.test("As a group owner", async assert => {
updateCurrentUser({ moderator: false, admin: false });
await visit("/g/discourse/manage/membership");
assert.ok(
find('label[for="automatic_membership"]').length === 0,
"it should not display automatic membership label"
);
assert.ok(
find(".groups-form-automatic-membership-retroactive").length === 0,
"it should not display automatic membership retroactive checkbox"
);
assert.ok(
find(".groups-form-primary-group").length === 0,
"it should not display set as primary group checkbox"
);
assert.ok(
find(".groups-form-grant-trust-level").length === 0,
"it should not display grant trust level selector"
);
assert.ok(
find(".group-form-public-admission").length === 1,
"it should display group public admission input"
);
assert.ok(
find(".group-form-public-exit").length === 1,
"it should display group public exit input"
);
assert.ok(
find(".group-form-allow-membership-requests").length === 1,
"it should display group allow_membership_request input"
);
assert.ok(
find(".group-form-allow-membership-requests[disabled]").length === 1,
"it should disable group allow_membership_request input"
);
});