Skip to content

A platform for community discussion. Free, open, simple.

DEV: Make 'username' optional for bookmark notifications (#19851)

Isaac Janzen28078d78e2b5
diff --git a/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js b/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js
index c7ec173d1e5..e58b40f2f7e 100644
--- a/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js
+++ b/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js
@@ -70,7 +70,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-bookmarks", {
href,
title: bookmark.name,
content: bookmark.title,
- username: bookmark.user.username,
+ username: bookmark.user?.username,
});
},
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/quick-access-item-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/quick-access-item-test.js
index 9e3dbb26168..4b17281f38e 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/quick-access-item-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/quick-access-item-test.js
@@ -32,5 +32,21 @@ module(
const contentDiv = query(CONTENT_DIV_SELECTOR);
assert.strictEqual(contentDiv.innerText, '"quote"');
});
+
+ test("Renders the notification content with no username when username is not present", async function (assert) {
+ this.set("args", {
+ content: "content",
+ username: undefined,
+ });
+
+ await render(
+ hbs`<MountWidget @widget="quick-access-item" @args={{this.args}} />`
+ );
+
+ const contentDiv = query(CONTENT_DIV_SELECTOR);
+ const usernameSpan = query("li a div span");
+ assert.strictEqual(contentDiv.innerText, "content");
+ assert.strictEqual(usernameSpan.innerText, "");
+ });
}
);