2022-11-02 09:41:30 -04:00
|
|
|
import {
|
|
|
|
acceptance,
|
|
|
|
exists,
|
|
|
|
loggedInUser,
|
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
import { click, currentURL, visit } from "@ember/test-helpers";
|
|
|
|
import {
|
|
|
|
chatChannels,
|
|
|
|
generateChatView,
|
|
|
|
} from "discourse/plugins/chat/chat-fixtures";
|
|
|
|
import { test } from "qunit";
|
|
|
|
|
|
|
|
acceptance("Discourse Chat - Mobile test", function (needs) {
|
|
|
|
needs.user({ can_chat: true, has_chat_enabled: true });
|
|
|
|
|
|
|
|
needs.mobileView();
|
|
|
|
|
|
|
|
needs.pretender((server, helper) => {
|
|
|
|
server.get("/chat/chat_channels.json", () => helper.response(chatChannels));
|
|
|
|
server.get("/chat/:id/messages.json", () =>
|
|
|
|
helper.response(generateChatView(loggedInUser()))
|
|
|
|
);
|
|
|
|
server.get("/u/search/users", () => {
|
|
|
|
return helper.response([]);
|
|
|
|
});
|
2022-11-03 04:06:30 -04:00
|
|
|
|
|
|
|
server.get("/chat/api/chat_channels.json", () => {
|
|
|
|
const channels = [];
|
|
|
|
return helper.response(channels);
|
|
|
|
});
|
2022-11-02 09:41:30 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
needs.settings({
|
|
|
|
chat_enabled: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Chat index route shows channels list", async function (assert) {
|
|
|
|
await visit("/latest");
|
|
|
|
await click(".header-dropdown-toggle.open-chat");
|
|
|
|
assert.equal(currentURL(), "/chat");
|
|
|
|
assert.ok(exists(".channels-list"));
|
|
|
|
await click(".chat-channel-row.chat-channel-7");
|
2022-11-11 00:39:15 -05:00
|
|
|
assert.notOk(exists(".open-drawer-btn"));
|
2022-11-02 09:41:30 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("Chat new personal chat buttons", async function (assert) {
|
|
|
|
await visit("/chat");
|
2022-11-11 00:39:15 -05:00
|
|
|
await click(".open-draft-channel-page-btn.btn-floating");
|
|
|
|
|
2022-11-02 09:41:30 -04:00
|
|
|
assert.strictEqual(
|
|
|
|
currentURL(),
|
|
|
|
"/chat/draft-channel",
|
|
|
|
"Clicking the floating + button opens the new chat screen"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(".chat-draft-header__btn");
|
2022-11-11 00:39:15 -05:00
|
|
|
|
2022-11-02 09:41:30 -04:00
|
|
|
assert.strictEqual(
|
|
|
|
currentURL(),
|
|
|
|
"/chat",
|
|
|
|
"Clicking the left arrow button returns to the channels list"
|
|
|
|
);
|
|
|
|
});
|
2022-11-03 04:06:30 -04:00
|
|
|
|
|
|
|
test("Chat browse screen back button", async function (assert) {
|
|
|
|
await visit("/chat/browse");
|
2022-11-11 00:39:15 -05:00
|
|
|
await click(".chat-full-page-header__back-btn");
|
|
|
|
|
2022-11-03 04:06:30 -04:00
|
|
|
assert.strictEqual(
|
|
|
|
currentURL(),
|
|
|
|
"/chat",
|
|
|
|
"Clicking the back button returns to the channels list"
|
|
|
|
);
|
|
|
|
});
|
2022-11-02 09:41:30 -04:00
|
|
|
});
|