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

80 lines
2.3 KiB
Plaintext
Raw Normal View History

import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("Groups");
test("Browsing Groups", () => {
2016-12-14 17:26:16 +08:00
visit("/groups");
andThen(() => {
equal(count('.groups-table-row'), 18, 'it displays visible groups');
});
click("a[href='/groups/discourse/members']");
andThen(() => {
2016-12-15 13:02:50 +08:00
equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page");
2016-12-14 17:26:16 +08:00
});
});
test("Viewing Group", () => {
visit("/groups/discourse");
andThen(() => {
ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair");
2016-06-02 21:21:43 +08:00
ok(count('.group-members tr') > 0, "it lists group members");
});
click(".nav-pills li a[title='Activity']");
andThen(() => {
2016-06-02 21:21:43 +08:00
ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/topics']");
andThen(() => {
ok(count('.user-stream .item') > 0, "it lists stream items");
});
click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']");
andThen(() => {
ok(count('.user-stream .item') > 0, "it lists stream items");
});
andThen(() => {
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'
);
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');
ok(count('.user-stream .item') > 0, "it lists stream items");
});
});
2016-12-14 17:26:16 +08:00
test("Admin Viewing Group", () => {
logIn();
Discourse.reset();
visit("/groups/discourse");
andThen(() => {
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 13:02:50 +08:00
equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
});
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'
);
});
});