discourse/test/javascripts/acceptance/group-manage-membership-test.js.es6
Robin Ward a8793d0d9a REFACTOR: Test Memory Usage Fixes (#7769)
* Calling `Discourse.reset()` creates a new container
We should run our de-initializers only after acceptance tests,
since initializers are not run outside of acceptance tests anyway,
and the container at this point can be passed properly to the
`teardown()` method.

* Remove `Discourse.reset` from tests
This would cause a new container to be created which leaks many objects.

* `updateCurrentUser` is more accurate than `replaceCurrentUser`
2019-06-14 14:54:20 +02:00

115 lines
3.0 KiB
JavaScript

import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
acceptance("Managing Group Membership", {
loggedIn: true
});
QUnit.test("As an admin", async assert => {
await visit("/g/discourse/manage/membership");
assert.ok(
find('label[for="automatic_membership"]').length === 1,
"it should display automatic membership label"
);
assert.ok(
find(".groups-form-automatic-membership-retroactive").length === 1,
"it should display automatic membership retroactive checkbox"
);
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"
);
});
QUnit.test("As a group owner", async assert => {
updateCurrentUser({ staff: 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"
);
});