discourse/test/javascripts/acceptance/groups-test.js.es6

105 lines
3.1 KiB
Plaintext
Raw Normal View History

import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("Groups");
2017-06-14 13:57:58 -04:00
QUnit.test("Browsing Groups", assert => {
2016-12-14 04:26:16 -05:00
visit("/groups");
andThen(() => {
2017-06-14 13:57:58 -04: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');
});
click('.group-index-join');
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
});
click('.login-modal .close');
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(invisible('.modal.login-modal'), 'it closes the login modal');
});
click('.group-index-request');
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.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(() => {
2017-06-14 13:57:58 -04:00
assert.equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
2016-12-14 04:26:16 -05:00
});
click('.group-index-join');
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(exists('.modal.login-modal'), 'it shows the login modal');
});
2016-12-14 04:26:16 -05:00
});
2017-06-14 13:57:58 -04:00
QUnit.test("Viewing Group", assert => {
visit("/groups/discourse");
andThen(() => {
2017-06-14 13:57:58 -04: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");
});
click(".nav-pills li a[title='Activity']");
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/topics']");
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']");
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.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'
);
2017-06-14 13:57:58 -04: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');
assert.ok(count('.user-stream .item') > 0, "it lists stream items");
});
});
2017-06-14 13:57:58 -04:00
QUnit.test("Admin Viewing Group", assert => {
logIn();
Discourse.reset();
visit("/groups/discourse");
andThen(() => {
2017-06-14 13:57:58 -04: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');
2016-12-15 00:02:50 -05:00
2017-06-14 13:57:58 -04:00
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
});
click(".nav-pills li a[title='Activity']");
andThen(() => {
2017-06-14 13:57:58 -04:00
assert.equal(
find(".group-activity li a[href='/groups/discourse/activity/messages']").length,
1,
'it should show messages tab if user is admin'
);
});
2017-06-14 13:57:58 -04:00
});