mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 04:03:45 +08:00
5c699e4384
* DEV: Rnemae channel path to just c Also swap the channel id and channel slug params to be consistent with core. * linting * channel_path * Drop slugify helper and channel route without slug * Request slug and route models through the channel model if possible * DEV: Pass messageId as a dynamic segment instead of a query param * Ensure change is backwards-compatible * drop query param from oneboxes * Correctly extract channelId from routes * Better route organization using siblings for regular and near-message * Ensures sessions are unique even when using parallelism * prevents didReceiveAttrs to clear input mid test * we disable animations in capybara so sometimes the message was barely showing * adds wait * ensures finished loading * is it causing more harm than good? * this check is slowing things for no reason * actually target the button * more resilient select chat message * apply similar fix to bookmark * fix --------- Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
|
import { render } from "@ember/test-helpers";
|
|
import { deepMerge } from "discourse-common/lib/object";
|
|
import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types";
|
|
import Notification from "discourse/models/notification";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
|
|
|
|
function getNotification(overrides = {}) {
|
|
return Notification.create(
|
|
deepMerge(
|
|
{
|
|
id: 11,
|
|
notification_type: NOTIFICATION_TYPES.chat_invitation,
|
|
read: false,
|
|
data: {
|
|
message: "chat.invitation_notification",
|
|
invited_by_username: "eviltrout",
|
|
chat_channel_id: 9,
|
|
chat_message_id: 2,
|
|
chat_channel_title: "Site",
|
|
},
|
|
},
|
|
overrides
|
|
)
|
|
);
|
|
}
|
|
|
|
module(
|
|
"Discourse Chat | Widget | chat-invitation-notification-item",
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("notification url", async function (assert) {
|
|
this.set("args", getNotification());
|
|
|
|
await render(
|
|
hbs`<MountWidget @widget="chat-invitation-notification-item" @args={{this.args}} />`
|
|
);
|
|
|
|
const data = this.args.data;
|
|
assert.strictEqual(
|
|
query(".chat-invitation a").getAttribute("href"),
|
|
`/chat/c/${slugifyChannel({
|
|
title: data.chat_channel_title,
|
|
})}/${data.chat_channel_id}/${data.chat_message_id}`
|
|
);
|
|
});
|
|
}
|
|
);
|