UX: Split up group form into smaller sections.

This commit is contained in:
Guo Xiang Tan
2018-04-06 11:36:57 +08:00
parent ba905b24ca
commit 4319273cf5
44 changed files with 760 additions and 583 deletions
@@ -0,0 +1,71 @@
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
acceptance("Managing Group Interaction Settings", {
loggedIn: true,
settings: {
email_in: true
}
});
QUnit.test("As an admin", assert => {
visit("/groups/discourse/manage/interaction");
andThen(() => {
assert.equal(
find('.groups-form-visibility-level').length, 1,
'it should display visibility level selector'
);
assert.equal(
find('.groups-form-mentionable-level').length, 1,
'it should display mentionable level selector'
);
assert.equal(
find('.groups-form-messageable-level').length, 1,
'it should display messageable level selector'
);
assert.equal(
find('.groups-form-incoming-email').length, 1,
'it should display incoming email input'
);
assert.equal(
find('.groups-form-default-notification-level').length, 1,
'it should display default notification level input'
);
});
});
QUnit.test("As a group owner", assert => {
replaceCurrentUser({ admin: false, staff: false });
visit("/groups/discourse/manage/interaction");
andThen(() => {
assert.equal(
find('.groups-form-visibility-level').length, 0,
'it should display visibility level selector'
);
assert.equal(
find('.groups-form-mentionable-level').length, 1,
'it should display mentionable level selector'
);
assert.equal(
find('.groups-form-messageable-level').length, 1,
'it should display messageable level selector'
);
assert.equal(
find('.groups-form-incoming-email').length, 0,
'it should not display incoming email input'
);
assert.equal(
find('.groups-form-default-notification-level').length, 1,
'it should display default notification level input'
);
});
});
@@ -0,0 +1,119 @@
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
acceptance("Managing Group Membership", {
loggedIn: true
});
QUnit.test("As an admin", assert => {
visit("/groups/discourse/manage/membership");
andThen(() => {
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'
);
});
click('.group-form-public-admission');
click('.group-form-allow-membership-requests');
andThen(() => {
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", assert => {
replaceCurrentUser({ staff: false, admin: false });
visit("/groups/discourse/manage/membership");
andThen(() => {
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'
);
});
});
@@ -1,8 +1,8 @@
import { acceptance, logIn } from "helpers/qunit-helpers";
import { acceptance, logIn, replaceCurrentUser } from "helpers/qunit-helpers";
acceptance("Managing Group Profile");
QUnit.test("Editing group", assert => {
QUnit.test("As an admin", assert => {
logIn();
Discourse.reset();
@@ -13,50 +13,25 @@ QUnit.test("Editing group", assert => {
assert.ok(find('.group-form-bio').length === 1, 'it should display group bio input');
assert.ok(find('.group-form-name').length === 1, 'it should display group name input');
assert.ok(find('.group-form-full-name').length === 1, 'it should display group full name input');
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'
);
});
});
click('.group-form-public-admission');
click('.group-form-allow-membership-requests');
QUnit.test("As a group owner", assert => {
logIn();
Discourse.reset();
replaceCurrentUser({ staff: false, admin: false });
visit("/groups/discourse/manage/profile");
andThen(() => {
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'
find('.group-form-name').length, 0,
'it should not display group name input'
);
});
});
QUnit.test("Editing group as an anonymous user", assert => {
QUnit.test("As an anonymous user", assert => {
visit("/groups/discourse/manage/profile");
andThen(() => {
@@ -167,18 +167,3 @@ QUnit.test("Admin Viewing Group", assert => {
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
});
});
QUnit.test("Admin Viewing Automatic Group", assert => {
logIn();
Discourse.reset();
visit("/groups/moderators");
click(".nav-pills li a[title='Manage']");
andThen(() => {
assert.equal(
count('.groups-form .control-group'), 5,
'it should display the right fields'
);
});
});