A11Y: Improve "my posts" sidebar link title (#19132)

This commit is contained in:
Kris 2022-11-22 08:36:43 -05:00 committed by GitHub
parent 91701d677f
commit 69e55a0e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View File

@ -47,7 +47,11 @@ export default class MyPostsSectionLink extends BaseSectionLink {
}
get title() {
return I18n.t("sidebar.sections.community.links.my_posts.title");
if (this._hasDraft) {
return I18n.t("sidebar.sections.community.links.my_posts.title_drafts");
} else {
return I18n.t("sidebar.sections.community.links.my_posts.title");
}
}
get text() {

View File

@ -564,6 +564,26 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
);
});
test("my posts title changes when drafts are present", async function (assert) {
await visit("/");
assert.strictEqual(
query(".sidebar-section-link-my-posts").title,
I18n.t("sidebar.sections.community.links.my_posts.title"),
"displays the default title when no drafts are present"
);
await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
draft_count: 1,
});
assert.strictEqual(
query(".sidebar-section-link-my-posts").title,
I18n.t("sidebar.sections.community.links.my_posts.title_drafts"),
"displays the draft title when drafts are present"
);
});
test("visiting top route", async function (assert) {
await visit("/top");

View File

@ -4248,7 +4248,8 @@ en:
title: "All users"
my_posts:
content: "My Posts"
title: "My posts"
title: "My recent topic activity"
title_drafts: "My unposted drafts"
draft_count:
one: "%{count} draft"
other: "%{count} drafts"