mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Split up group form into smaller sections.
This commit is contained in:
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
119
test/javascripts/acceptance/group-manage-membership-test.js.es6
Normal file
119
test/javascripts/acceptance/group-manage-membership-test.js.es6
Normal file
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export default {
|
||||
"/session/current.json": {"current_user":{"id":19,"username":"eviltrout","uploaded_avatar_id":5275,"avatar_template":"/user_avatar/localhost/eviltrout/{size}/5275.png","name":"Robin Ward","total_unread_notifications":205,"unread_notifications":0,"unread_private_messages":0,"admin":true,"notification_channel_position":null,"site_flagged_posts_count":1,"moderator":true,"staff":true,"title":"co-founder","reply_count":859,"topic_count":36,"enable_quoting":true,"external_links_in_new_tab":false,"dynamic_favicon":true,"trust_level":4,"can_edit":true,"can_invite_to_forum":true,"should_be_redirected_to_top":false,"disable_jump_reply":false,"custom_fields":{},"muted_category_ids":[],"dismissed_banner_key":null,"akismet_review_count":0}}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ export function currentUser() {
|
||||
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
||||
}
|
||||
|
||||
export function replaceCurrentUser(properties) {
|
||||
const user = Discourse.User.current();
|
||||
user.setProperties(properties);
|
||||
Discourse.User.resetCurrent(user);
|
||||
}
|
||||
|
||||
export function logIn() {
|
||||
Discourse.User.resetCurrent(currentUser());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user