mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
DEV: introduces prettier for es6 files
This commit is contained in:
@ -7,11 +7,7 @@ acceptance("Group", {
|
||||
});
|
||||
|
||||
const response = object => {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
object
|
||||
];
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
|
||||
QUnit.test("Anonymous Viewing Group", async assert => {
|
||||
@ -20,46 +16,59 @@ QUnit.test("Anonymous Viewing Group", async assert => {
|
||||
assert.equal(
|
||||
count(".nav-pills li a[title='Messages']"),
|
||||
0,
|
||||
'it deos not show group messages navigation link'
|
||||
"it deos not show group messages navigation link"
|
||||
);
|
||||
|
||||
await click(".nav-pills li a[title='Activity']");
|
||||
|
||||
assert.ok(count('.user-stream-item') > 0, "it lists stream items");
|
||||
assert.ok(count(".user-stream-item") > 0, "it lists stream items");
|
||||
|
||||
await click(".activity-nav li a[href='/groups/discourse/activity/topics']");
|
||||
|
||||
assert.ok(find('.topic-list'), "it shows the topic list");
|
||||
assert.equal(count('.topic-list-item'), 2, "it lists stream items");
|
||||
assert.ok(find(".topic-list"), "it shows the topic list");
|
||||
assert.equal(count(".topic-list-item"), 2, "it lists stream items");
|
||||
|
||||
await click(".activity-nav li a[href='/groups/discourse/activity/mentions']");
|
||||
|
||||
assert.ok(count('.user-stream-item') > 0, "it lists stream items");
|
||||
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");
|
||||
assert.ok(count(".user-stream-item") > 0, "it lists stream items");
|
||||
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");
|
||||
|
||||
await expandSelectKit('.group-dropdown');
|
||||
await expandSelectKit(".group-dropdown");
|
||||
|
||||
assert.equal(
|
||||
find('.select-kit-row').text().trim(), 'discourse',
|
||||
'it displays the right row'
|
||||
find(".select-kit-row")
|
||||
.text()
|
||||
.trim(),
|
||||
"discourse",
|
||||
"it displays the right row"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find('.group-dropdown-filter').text().trim(), I18n.t("groups.index.all").toLowerCase(),
|
||||
'it displays the right header'
|
||||
find(".group-dropdown-filter")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("groups.index.all").toLowerCase(),
|
||||
"it displays the right header"
|
||||
);
|
||||
|
||||
Discourse.SiteSettings.enable_group_directory = false;
|
||||
|
||||
await visit("/groups");
|
||||
await visit("/groups/discourse");
|
||||
await expandSelectKit('.group-dropdown');
|
||||
await expandSelectKit(".group-dropdown");
|
||||
|
||||
assert.equal(
|
||||
find('.group-dropdown-filter').length, 0,
|
||||
'it should not display the default header'
|
||||
find(".group-dropdown-filter").length,
|
||||
0,
|
||||
"it should not display the default header"
|
||||
);
|
||||
});
|
||||
|
||||
@ -70,7 +79,7 @@ QUnit.test("Anonymous Viewing Automatic Group", assert => {
|
||||
assert.equal(
|
||||
count(".nav-pills li a[title='Manage']"),
|
||||
0,
|
||||
'it deos not show group messages navigation link'
|
||||
"it deos not show group messages navigation link"
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -80,67 +89,167 @@ QUnit.test("User Viewing Group", assert => {
|
||||
Discourse.reset();
|
||||
|
||||
visit("/groups");
|
||||
click('.group-index-request');
|
||||
click(".group-index-request");
|
||||
|
||||
server.post('/groups/Macdonald/request_membership', () => { // eslint-disable-line no-undef
|
||||
server.post("/groups/Macdonald/request_membership", () => {
|
||||
// eslint-disable-line no-undef
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
{ relative_url: '/t/internationalization-localization/280' }
|
||||
{ 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(".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');
|
||||
assert.equal(
|
||||
find(".request-group-membership-form textarea").val(),
|
||||
"Please add me"
|
||||
);
|
||||
});
|
||||
|
||||
click('.modal-footer .btn-primary');
|
||||
click(".modal-footer .btn-primary");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('.fancy-title').text().trim(),
|
||||
find(".fancy-title")
|
||||
.text()
|
||||
.trim(),
|
||||
"Internationalization / localization"
|
||||
);
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("Admin viewing group messages when there are no messages", assert => {
|
||||
server.get('/topics/private-messages-group/eviltrout/discourse.json', () => { // eslint-disable-line no-undef
|
||||
return response({ topic_list: { topics: [] } });
|
||||
});
|
||||
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
visit("/groups/discourse");
|
||||
|
||||
click(".nav-pills li a[title='Messages']");
|
||||
click(".group-message-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(count("#reply-control") === 1, "it opens the composer");
|
||||
assert.equal(
|
||||
find(".alert").text().trim(),
|
||||
I18n.t('choose_topic.none_found'),
|
||||
'it should display the right alert'
|
||||
find(".ac-wrap .item").text(),
|
||||
"discourse",
|
||||
"it prefills the group name"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"Admin viewing group messages when there are no messages",
|
||||
assert => {
|
||||
server.get(
|
||||
"/topics/private-messages-group/eviltrout/discourse.json",
|
||||
() => {
|
||||
// eslint-disable-line no-undef
|
||||
return response({ topic_list: { topics: [] } });
|
||||
}
|
||||
);
|
||||
|
||||
logIn();
|
||||
Discourse.reset();
|
||||
|
||||
visit("/groups/discourse");
|
||||
|
||||
click(".nav-pills li a[title='Messages']");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("choose_topic.none_found"),
|
||||
"it should display the right alert"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("Admin viewing group messages", assert => {
|
||||
server.get('/topics/private-messages-group/eviltrout/discourse.json', () => { // eslint-disable-line no-undef
|
||||
return response({"users":[{"id":2, "username":"bruce1", "avatar_template":"/user_avatar/meta.discourse.org/bruce1/{size}/5245.png"}, {"id":3, "username":"CodingHorror", "avatar_template":"/user_avatar/meta.discourse.org/codinghorror/{size}/5245.png"}], "primary_groups":[], "topic_list":{"can_create_topic":true, "draft":null, "draft_key":"new_topic", "draft_sequence":0, "per_page":30, "topics":[{"id":12199, "title":"This is a private message 1", "fancy_title":"This is a private message 1", "slug":"this-is-a-private-message-1", "posts_count":0, "reply_count":0, "highest_post_number":0, "image_url":null, "created_at":"2018-03-16T03:38:45.583Z", "last_posted_at":null, "bumped":true, "bumped_at":"2018-03-16T03:38:45.583Z", "unseen":false, "pinned":false, "unpinned":null, "visible":true, "closed":false, "archived":false, "bookmarked":null, "liked":null, "views":0, "like_count":0, "has_summary":false, "archetype":"private_message", "last_poster_username":"bruce1", "category_id":null, "pinned_globally":false, "featured_link":null, "posters":[{"extras":"latest single", "description":"Original Poster, Most Recent Poster", "user_id":2, "primary_group_id":null}], "participants":[{"extras":"latest", "description":null, "user_id":2, "primary_group_id":null}, {"extras":null, "description":null, "user_id":3, "primary_group_id":null}]}]}});
|
||||
server.get("/topics/private-messages-group/eviltrout/discourse.json", () => {
|
||||
// eslint-disable-line no-undef
|
||||
return response({
|
||||
users: [
|
||||
{
|
||||
id: 2,
|
||||
username: "bruce1",
|
||||
avatar_template:
|
||||
"/user_avatar/meta.discourse.org/bruce1/{size}/5245.png"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
username: "CodingHorror",
|
||||
avatar_template:
|
||||
"/user_avatar/meta.discourse.org/codinghorror/{size}/5245.png"
|
||||
}
|
||||
],
|
||||
primary_groups: [],
|
||||
topic_list: {
|
||||
can_create_topic: true,
|
||||
draft: null,
|
||||
draft_key: "new_topic",
|
||||
draft_sequence: 0,
|
||||
per_page: 30,
|
||||
topics: [
|
||||
{
|
||||
id: 12199,
|
||||
title: "This is a private message 1",
|
||||
fancy_title: "This is a private message 1",
|
||||
slug: "this-is-a-private-message-1",
|
||||
posts_count: 0,
|
||||
reply_count: 0,
|
||||
highest_post_number: 0,
|
||||
image_url: null,
|
||||
created_at: "2018-03-16T03:38:45.583Z",
|
||||
last_posted_at: null,
|
||||
bumped: true,
|
||||
bumped_at: "2018-03-16T03:38:45.583Z",
|
||||
unseen: false,
|
||||
pinned: false,
|
||||
unpinned: null,
|
||||
visible: true,
|
||||
closed: false,
|
||||
archived: false,
|
||||
bookmarked: null,
|
||||
liked: null,
|
||||
views: 0,
|
||||
like_count: 0,
|
||||
has_summary: false,
|
||||
archetype: "private_message",
|
||||
last_poster_username: "bruce1",
|
||||
category_id: null,
|
||||
pinned_globally: false,
|
||||
featured_link: null,
|
||||
posters: [
|
||||
{
|
||||
extras: "latest single",
|
||||
description: "Original Poster, Most Recent Poster",
|
||||
user_id: 2,
|
||||
primary_group_id: null
|
||||
}
|
||||
],
|
||||
participants: [
|
||||
{
|
||||
extras: "latest",
|
||||
description: null,
|
||||
user_id: 2,
|
||||
primary_group_id: null
|
||||
},
|
||||
{
|
||||
extras: null,
|
||||
description: null,
|
||||
user_id: 3,
|
||||
primary_group_id: null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
logIn();
|
||||
@ -151,9 +260,11 @@ QUnit.test("Admin viewing group messages", assert => {
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".topic-list-item .link-top-line").text().trim(),
|
||||
find(".topic-list-item .link-top-line")
|
||||
.text()
|
||||
.trim(),
|
||||
"This is a private message 1",
|
||||
'it should display the list of group topics'
|
||||
"it should display the list of group topics"
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -167,10 +278,18 @@ QUnit.test("Admin Viewing Group", assert => {
|
||||
andThen(() => {
|
||||
assert.ok(
|
||||
find(".nav-pills li a[title='Manage']").length === 1,
|
||||
'it should show manage group tab if user is admin'
|
||||
"it should show manage group tab if user is admin"
|
||||
);
|
||||
|
||||
assert.equal(count('.group-message-button'), 1, 'it displays show group message button');
|
||||
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
|
||||
assert.equal(
|
||||
count(".group-message-button"),
|
||||
1,
|
||||
"it displays show group message button"
|
||||
);
|
||||
assert.equal(
|
||||
find(".group-info-name").text(),
|
||||
"Awesome Team",
|
||||
"it should display the group name"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user