mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 22:53:44 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
65 lines
2.1 KiB
JavaScript
65 lines
2.1 KiB
JavaScript
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
import { click, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import { ORIGINS } from "discourse/plugins/chat/discourse/services/chat-channel-info-route-origin-manager";
|
|
import { getOwner } from "discourse-common/lib/get-owner";
|
|
import fabricators from "../helpers/fabricators";
|
|
|
|
acceptance("Discourse Chat - chat channel info", function (needs) {
|
|
needs.user({ has_chat_enabled: true, can_chat: true });
|
|
|
|
needs.settings({ chat_enabled: true });
|
|
|
|
needs.pretender((server, helper) => {
|
|
const channel = fabricators.chatChannel();
|
|
server.get("/chat/chat_channels.json", () => {
|
|
return helper.response({
|
|
publicMessageChannels: [channel],
|
|
directMessageChannels: [],
|
|
});
|
|
});
|
|
server.get("/chat/chat_channels/:id.json", () => {
|
|
return helper.response(channel);
|
|
});
|
|
server.get("/chat/api/chat_channels.json", () =>
|
|
helper.response([channel])
|
|
);
|
|
server.get("/chat/api/chat_channels/:id/memberships.json", () =>
|
|
helper.response([])
|
|
);
|
|
server.get("/chat/:id/messages.json", () =>
|
|
helper.response({ chat_messages: [], meta: {} })
|
|
);
|
|
});
|
|
|
|
needs.hooks.beforeEach(function () {
|
|
this.manager = getOwner(this).lookup(
|
|
"service:chat-channel-info-route-origin-manager"
|
|
);
|
|
});
|
|
|
|
needs.hooks.afterEach(function () {
|
|
this.manager.origin = null;
|
|
});
|
|
|
|
test("Direct visit sets origin as channel", async function (assert) {
|
|
await visit("/chat/channel/1/my-category-title/info");
|
|
|
|
assert.strictEqual(this.manager.origin, ORIGINS.channel);
|
|
});
|
|
|
|
test("Visit from browse sets origin as browse", async function (assert) {
|
|
await visit("/chat/browse/open");
|
|
await click(".chat-channel-card__setting");
|
|
|
|
assert.strictEqual(this.manager.origin, ORIGINS.browse);
|
|
});
|
|
|
|
test("Visit from channel sets origin as channel", async function (assert) {
|
|
await visit("/chat/channel/1/my-category-title");
|
|
await visit("/chat/channel/1/my-category-title/info");
|
|
|
|
assert.strictEqual(this.manager.origin, ORIGINS.channel);
|
|
});
|
|
});
|