mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 12:17:49 +08:00
FIX: Clicking a notification was triggering an error (#25583)
This commit is contained in:
parent
c8c20585a7
commit
21a830b53d
|
@ -61,11 +61,12 @@ export default class UserMenuBaseItem {
|
|||
if (wantsNewWindow(event)) {
|
||||
return;
|
||||
}
|
||||
closeUserMenu();
|
||||
const href = this.linkHref;
|
||||
if (href) {
|
||||
DiscourseURL.routeTo(href);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
closeUserMenu?.();
|
||||
|
||||
if (this.linkHref) {
|
||||
DiscourseURL.routeTo(this.linkHref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import User from "discourse/models/user";
|
||||
import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
publishToMessageBus,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
|
||||
acceptance("Category Notifications", function (needs) {
|
||||
needs.user({ muted_category_ids: [1], indirectly_muted_category_ids: [2] });
|
||||
|
||||
test("New category is muted when parent category is muted", async function (assert) {
|
||||
await visit("/");
|
||||
const user = User.current();
|
||||
const user = getOwner(this).lookup("service:current-user");
|
||||
|
||||
await publishToMessageBus("/categories", {
|
||||
categories: [
|
||||
{
|
||||
|
@ -43,7 +45,7 @@ acceptance("Category Notifications", function (needs) {
|
|||
});
|
||||
|
||||
acceptance(
|
||||
"User Notifications - there is no notifications yet",
|
||||
"User Notifications - there are no notifications yet",
|
||||
function (needs) {
|
||||
needs.user();
|
||||
|
||||
|
@ -55,15 +57,37 @@ acceptance(
|
|||
});
|
||||
});
|
||||
|
||||
test("It renders the empty state panel", async function (assert) {
|
||||
await visit("/u/eviltrout/notifications");
|
||||
assert.ok(exists("div.empty-state"));
|
||||
});
|
||||
|
||||
test("It does not render filter", async function (assert) {
|
||||
test("renders the empty state panel", async function (assert) {
|
||||
await visit("/u/eviltrout/notifications");
|
||||
|
||||
assert.notOk(exists("div.user-notifications-filter"));
|
||||
assert.dom("div.empty-state").exists();
|
||||
assert.dom("div.user-notifications-filter").doesNotExist();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
acceptance("User Notifications", function (needs) {
|
||||
needs.user();
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/notifications", () => {
|
||||
return helper.response(cloneJSON(NotificationFixtures["/notifications"]));
|
||||
});
|
||||
});
|
||||
|
||||
test("shows the notifications list", async function (assert) {
|
||||
await visit("/u/eviltrout/notifications");
|
||||
|
||||
assert.dom("div.empty-state").doesNotExist();
|
||||
assert.dom("div.user-notifications-filter").exists();
|
||||
assert
|
||||
.dom(".user-notifications-list .notification.unread")
|
||||
.exists({ count: 6 });
|
||||
|
||||
await click(".notification.liked-consolidated a");
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/u/eviltrout/notifications/likes-received?acting_username=aquaman"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -37,7 +37,7 @@ export default {
|
|||
notification_type: NOTIFICATION_TYPES.liked_consolidated,
|
||||
acting_user_avatar_template: "/letter_avatar_proxy/v4/letter/o/f05b48/{size}.png",
|
||||
read: false,
|
||||
data: { display_username: "aquaman", count: "5" },
|
||||
data: { username: "aquaman", display_username: "aquaman", count: 5 },
|
||||
},
|
||||
{
|
||||
id: 789,
|
||||
|
|
Loading…
Reference in New Issue
Block a user