2019-06-14 08:54:20 -04:00
|
|
|
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
2020-02-21 16:14:24 -05:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2018-04-05 23:36:57 -04:00
|
|
|
|
|
|
|
acceptance("Managing Group Membership", {
|
|
|
|
loggedIn: true
|
|
|
|
});
|
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
QUnit.test("As an admin", async assert => {
|
2019-02-21 00:44:25 -05:00
|
|
|
await visit("/g/discourse/manage/membership");
|
2018-07-19 06:11:18 -04:00
|
|
|
|
|
|
|
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"
|
|
|
|
);
|
2020-02-21 16:14:24 -05:00
|
|
|
|
|
|
|
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");
|
2018-04-05 23:36:57 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
QUnit.test("As a group owner", async assert => {
|
2019-07-24 16:01:08 -04:00
|
|
|
updateCurrentUser({ moderator: false, admin: false });
|
2018-04-05 23:36:57 -04:00
|
|
|
|
2019-02-21 00:44:25 -05:00
|
|
|
await visit("/g/discourse/manage/membership");
|
2018-07-19 06:11:18 -04:00
|
|
|
|
|
|
|
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"
|
|
|
|
);
|
2018-04-05 23:36:57 -04:00
|
|
|
});
|