discourse/test/javascripts/acceptance/group-manage-logs-test.js.es6

120 lines
3.2 KiB
Plaintext
Raw Normal View History

2016-12-11 23:36:15 +08:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Group logs", {
2016-12-11 23:36:15 +08:00
loggedIn: true,
2017-06-15 01:57:58 +08:00
beforeEach() {
2016-12-11 23:36:15 +08:00
const response = object => {
2018-06-15 23:03:24 +08:00
return [200, { "Content-Type": "application/json" }, object];
2016-12-11 23:36:15 +08:00
};
2018-06-16 00:18:45 +08:00
// prettier-ignore
server.get("/groups/snorlax.json", () => { // eslint-disable-line no-undef
2018-06-15 23:03:24 +08:00
return response({
group: {
id: 41,
automatic: false,
name: "snorlax",
user_count: 1,
alias_level: 0,
visible: true,
automatic_membership_email_domains: "",
automatic_membership_retroactive: false,
primary_group: true,
title: "Team Snorlax",
grant_trust_level: null,
incoming_email: null,
has_messages: false,
flair_url: "",
flair_bg_color: "",
flair_color: "",
bio_raw: "",
bio_cooked: null,
public: true,
is_group_user: true,
is_group_owner: true
}
});
2016-12-11 23:36:15 +08:00
});
// Workaround while awaiting https://github.com/tildeio/route-recognizer/issues/53
2018-06-16 00:18:45 +08:00
// prettier-ignore
server.get("/groups/snorlax/logs.json", request => { // eslint-disable-line no-undef
2016-12-11 23:36:15 +08:00
if (request.queryParams["filters[action]"]) {
2018-06-15 23:03:24 +08:00
return response({
logs: [
{
action: "change_group_setting",
subject: "title",
prev_value: null,
new_value: "Team Snorlax",
created_at: "2016-12-12T08:27:46.408Z",
acting_user: {
id: 1,
username: "tgx",
avatar_template: "/images/avatar.png"
},
target_user: null
}
],
all_loaded: true
});
2016-12-11 23:36:15 +08:00
} else {
2018-06-15 23:03:24 +08:00
return response({
logs: [
{
action: "change_group_setting",
subject: "title",
prev_value: null,
new_value: "Team Snorlax",
created_at: "2016-12-12T08:27:46.408Z",
acting_user: {
id: 1,
username: "tgx",
avatar_template: "/images/avatar.png"
},
target_user: null
},
{
action: "add_user_to_group",
subject: null,
prev_value: null,
new_value: null,
created_at: "2016-12-12T08:27:27.725Z",
acting_user: {
id: 1,
username: "tgx",
avatar_template: "/images/avatar.png"
},
target_user: {
id: 1,
username: "tgx",
avatar_template: "/images/avatar.png"
}
}
],
all_loaded: true
});
2016-12-11 23:36:15 +08:00
}
});
}
});
2017-06-15 01:57:58 +08:00
QUnit.test("Browsing group logs", assert => {
visit("/groups/snorlax/manage/logs");
2016-12-11 23:36:15 +08:00
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find("tr.group-manage-logs-row").length === 2,
"it should display the right number of logs"
);
click(find(".group-manage-logs-row button")[0]);
2016-12-11 23:36:15 +08:00
});
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find("tr.group-manage-logs-row").length === 1,
"it should display the right number of logs"
);
2016-12-11 23:36:15 +08:00
});
});