FIX: Ensure group inboxes in messages section is sorted by group name (#18508)

This commit is contained in:
Alan Guo Xiang Tan 2022-10-10 14:47:55 +08:00 committed by GitHub
parent 7009f9c95e
commit b2a14eeb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 23 deletions

View File

@ -122,7 +122,9 @@ export default class SidebarUserMessagesSection extends Component {
get groupMessagesSectionLinks() {
const links = [];
this.currentUser.groupsWithMessages.forEach((group) => {
this.currentUser.groupsWithMessages
.sort((a, b) => a.name.localeCompare(b.name))
.forEach((group) => {
GROUP_MESSAGES_INBOX_FILTERS.forEach((groupMessageLink) => {
links.push(
new GroupMessageSectionLink({

View File

@ -7,6 +7,7 @@ import {
exists,
publishToMessageBus,
query,
queryAll,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
import { NotificationLevels } from "discourse/lib/notification-levels";
@ -175,7 +176,7 @@ acceptance(
updateCurrentUser({
groups: [
{
name: "group1",
name: "group3",
has_messages: true,
},
{
@ -183,7 +184,7 @@ acceptance(
has_messages: false,
},
{
name: "group3",
name: "group1",
has_messages: true,
},
],
@ -191,18 +192,16 @@ acceptance(
await visit("/");
assert.ok(
exists(
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1"
),
"displays group1 inbox link"
const groupSectionLinks = queryAll(
".sidebar-section-messages .sidebar-section-link"
);
assert.ok(
exists(
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group3"
),
"displays group3 inbox link"
assert.deepEqual(
groupSectionLinks
.toArray()
.map((sectionLink) => sectionLink.textContent.trim()),
["Inbox", "group1", "group3"],
"displays group section links sorted by name"
);
await visit("/u/eviltrout/messages/group/GrOuP1");