2016-11-25 02:26:49 -05:00
|
|
|
import { acceptance, logIn } from "helpers/qunit-helpers";
|
|
|
|
|
2015-04-06 14:14:00 -04:00
|
|
|
acceptance("Groups");
|
2015-01-23 11:13:27 -05:00
|
|
|
|
2015-03-19 07:22:56 -04:00
|
|
|
test("Browsing Groups", () => {
|
2016-12-14 04:26:16 -05:00
|
|
|
visit("/groups");
|
|
|
|
|
|
|
|
andThen(() => {
|
2016-12-28 23:51:36 -05:00
|
|
|
equal(count('.groups-table-row'), 2, 'it displays visible groups');
|
2017-01-05 22:56:10 -05:00
|
|
|
equal(find('.group-index-join').length, 1, 'it shows button to join group');
|
|
|
|
equal(find('.group-index-request').length, 1, 'it shows button to request for group membership');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.group-index-join');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
ok(exists('.modal.login-modal'), 'it shows the login modal');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.login-modal .close');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
ok(invisible('.modal.login-modal'), 'it closes the login modal');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.group-index-request');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
ok(exists('.modal.login-modal'), 'it shows the login modal');
|
2016-12-14 04:26:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
click("a[href='/groups/discourse/members']");
|
|
|
|
|
|
|
|
andThen(() => {
|
2016-12-15 00:02:50 -05:00
|
|
|
equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
|
2016-12-14 04:26:16 -05:00
|
|
|
});
|
2017-01-05 22:56:10 -05:00
|
|
|
|
|
|
|
click('.group-index-join');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
ok(exists('.modal.login-modal'), 'it shows the login modal');
|
|
|
|
});
|
2016-12-14 04:26:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("Viewing Group", () => {
|
2015-01-23 11:13:27 -05:00
|
|
|
visit("/groups/discourse");
|
2016-11-29 00:42:47 -05:00
|
|
|
|
2015-03-19 07:22:56 -04:00
|
|
|
andThen(() => {
|
2016-11-29 00:42:47 -05:00
|
|
|
ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair");
|
2016-06-02 09:21:43 -04:00
|
|
|
ok(count('.group-members tr') > 0, "it lists group members");
|
2015-01-23 11:13:27 -05:00
|
|
|
});
|
2015-03-19 07:22:56 -04:00
|
|
|
|
2016-12-22 00:07:30 -05:00
|
|
|
click(".nav-pills li a[title='Activity']");
|
|
|
|
|
2015-03-19 07:22:56 -04:00
|
|
|
andThen(() => {
|
2016-06-02 09:21:43 -04:00
|
|
|
ok(count('.user-stream .item') > 0, "it lists stream items");
|
2015-01-23 11:13:27 -05:00
|
|
|
});
|
2016-04-11 13:16:37 -04:00
|
|
|
|
2016-12-22 00:07:30 -05:00
|
|
|
click(".group-activity-nav li a[href='/groups/discourse/activity/topics']");
|
|
|
|
|
2016-04-11 13:16:37 -04:00
|
|
|
andThen(() => {
|
|
|
|
ok(count('.user-stream .item') > 0, "it lists stream items");
|
|
|
|
});
|
|
|
|
|
2016-12-22 00:07:30 -05:00
|
|
|
click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']");
|
|
|
|
|
2016-04-11 13:16:37 -04:00
|
|
|
andThen(() => {
|
|
|
|
ok(count('.user-stream .item') > 0, "it lists stream items");
|
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2016-12-22 00:07:30 -05:00
|
|
|
equal(
|
|
|
|
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'
|
|
|
|
);
|
2016-12-28 22:52:07 -05:00
|
|
|
ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin');
|
|
|
|
ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin');
|
2016-04-11 13:16:37 -04:00
|
|
|
ok(count('.user-stream .item') > 0, "it lists stream items");
|
|
|
|
});
|
2015-01-23 11:13:27 -05:00
|
|
|
});
|
2016-11-25 02:26:49 -05:00
|
|
|
|
2016-12-14 04:26:16 -05:00
|
|
|
test("Admin Viewing Group", () => {
|
2016-11-25 02:26:49 -05:00
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
|
|
|
|
visit("/groups/discourse");
|
|
|
|
|
|
|
|
andThen(() => {
|
2016-12-22 00:07:30 -05:00
|
|
|
ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin');
|
|
|
|
ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin');
|
2016-12-15 00:02:50 -05:00
|
|
|
|
|
|
|
equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
|
2016-11-25 02:26:49 -05:00
|
|
|
});
|
2016-12-22 00:07:30 -05:00
|
|
|
|
|
|
|
click(".nav-pills li a[title='Activity']");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
equal(
|
|
|
|
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
|
|
|
|
1,
|
|
|
|
'it should show messages tab if user is admin'
|
|
|
|
);
|
|
|
|
});
|
2016-11-25 02:26:49 -05:00
|
|
|
});
|