2016-11-25 15:26:49 +08:00
|
|
|
import { acceptance, logIn } from "helpers/qunit-helpers";
|
|
|
|
|
2015-04-07 02:14:00 +08:00
|
|
|
acceptance("Groups");
|
2015-01-24 00:13:27 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Browsing Groups", assert => {
|
2016-12-14 17:26:16 +08:00
|
|
|
visit("/groups");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(count('.groups-table-row'), 2, 'it displays visible groups');
|
|
|
|
assert.equal(find('.group-index-join').length, 1, 'it shows button to join group');
|
|
|
|
assert.equal(find('.group-index-request').length, 1, 'it shows button to request for group membership');
|
2017-01-06 11:56:10 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.group-index-join');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
|
2017-01-06 11:56:10 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.login-modal .close');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(invisible('.modal.login-modal'), 'it closes the login modal');
|
2017-01-06 11:56:10 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click('.group-index-request');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
|
2016-12-14 17:26:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
click("a[href='/groups/discourse/members']");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
|
2016-12-14 17:26:16 +08:00
|
|
|
});
|
2017-01-06 11:56:10 +08:00
|
|
|
|
|
|
|
click('.group-index-join');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
|
2017-01-06 11:56:10 +08:00
|
|
|
});
|
2016-12-14 17:26:16 +08:00
|
|
|
});
|
|
|
|
|
2017-07-27 16:51:25 +08:00
|
|
|
QUnit.test("Anonymous Viewing Group", assert => {
|
2015-01-24 00:13:27 +08:00
|
|
|
visit("/groups/discourse");
|
2016-11-29 13:42:47 +08:00
|
|
|
|
2015-03-19 19:22:56 +08:00
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair");
|
|
|
|
assert.ok(count('.group-members tr') > 0, "it lists group members");
|
2017-07-27 16:51:25 +08:00
|
|
|
assert.ok(count('.group-message-button') === 0, 'it does not show group message button');
|
2015-01-24 00:13:27 +08:00
|
|
|
});
|
2015-03-19 19:22:56 +08:00
|
|
|
|
2016-12-22 13:07:30 +08:00
|
|
|
click(".nav-pills li a[title='Activity']");
|
|
|
|
|
2015-03-19 19:22:56 +08:00
|
|
|
andThen(() => {
|
2017-11-03 03:05:41 +08:00
|
|
|
assert.ok(count('.group-post') > 0, "it lists stream items");
|
2015-01-24 00:13:27 +08:00
|
|
|
});
|
2016-04-12 01:16:37 +08:00
|
|
|
|
2016-12-22 13:07:30 +08:00
|
|
|
click(".group-activity-nav li a[href='/groups/discourse/activity/topics']");
|
|
|
|
|
2016-04-12 01:16:37 +08:00
|
|
|
andThen(() => {
|
2017-11-03 03:05:41 +08:00
|
|
|
assert.ok(count('.group-post') > 0, "it lists stream items");
|
2016-04-12 01:16:37 +08:00
|
|
|
});
|
|
|
|
|
2016-12-22 13:07:30 +08:00
|
|
|
click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']");
|
|
|
|
|
2016-04-12 01:16:37 +08:00
|
|
|
andThen(() => {
|
2017-11-03 03:05:41 +08:00
|
|
|
assert.ok(count('.group-post') > 0, "it lists stream items");
|
2016-04-12 01:16:37 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(
|
2016-12-22 13:07:30 +08:00
|
|
|
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
|
|
|
|
0,
|
|
|
|
'it should not show messages tab if user is not a group user or admin'
|
|
|
|
);
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin');
|
|
|
|
assert.ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin');
|
2017-11-03 03:05:41 +08:00
|
|
|
assert.ok(count('.group-post') > 0, "it lists stream items");
|
2016-04-12 01:16:37 +08:00
|
|
|
});
|
2015-01-24 00:13:27 +08:00
|
|
|
});
|
2016-11-25 15:26:49 +08:00
|
|
|
|
2017-07-27 16:51:25 +08:00
|
|
|
QUnit.test("User Viewing Group", assert => {
|
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
|
2017-08-08 17:53:02 +08:00
|
|
|
visit("/groups");
|
|
|
|
click('.group-index-request');
|
|
|
|
|
|
|
|
server.post('/groups/Macdonald/request_membership', () => { // eslint-disable-line no-undef
|
|
|
|
return [
|
|
|
|
200,
|
|
|
|
{ "Content-Type": "application/json" },
|
|
|
|
{ relative_url: '/t/internationalization-localization/280' }
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.modal-header').text().trim(), I18n.t(
|
|
|
|
'groups.membership_request.title', { group_name: 'Macdonald' }
|
|
|
|
));
|
|
|
|
|
|
|
|
assert.equal(find('.request-group-membership-form textarea').val(), 'Please add me');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.modal-footer .btn-primary');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.fancy-title').text().trim(),
|
|
|
|
"Internationalization / localization"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-07-27 16:51:25 +08:00
|
|
|
visit("/groups/discourse");
|
|
|
|
|
|
|
|
click('.group-message-button');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(count('#reply-control') === 1, 'it opens the composer');
|
|
|
|
assert.equal(find('.ac-wrap .item').text(), 'discourse', 'it prefills the group name');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Admin Viewing Group", assert => {
|
2016-11-25 15:26:49 +08:00
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
|
|
|
|
visit("/groups/discourse");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin');
|
|
|
|
assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin');
|
2017-10-02 16:50:27 +08:00
|
|
|
assert.equal(count('.group-message-button'), 1, 'it displays show group message button');
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
|
2016-11-25 15:26:49 +08:00
|
|
|
});
|
2016-12-22 13:07:30 +08:00
|
|
|
|
|
|
|
click(".nav-pills li a[title='Activity']");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(
|
2016-12-22 13:07:30 +08:00
|
|
|
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
|
|
|
|
1,
|
|
|
|
'it should show messages tab if user is admin'
|
|
|
|
);
|
|
|
|
});
|
2017-07-27 16:51:25 +08:00
|
|
|
});
|