mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
This simplifies the appearance of the drawer by hiding the header buttons when collapsed, some of them didn't even work in this state before <img width="400" alt="image" src="https://github.com/user-attachments/assets/ec542d3c-8a9b-47e3-9a83-1ed86826de5c" /> after <img width="400" alt="image" src="https://github.com/user-attachments/assets/5dd2ebe8-0ea7-4987-b37d-42d4280afa6c" /> clicking anywhere other than the x will expand the chat again, and when using keyboard nav we still show the expand button as an accessibility affordance: <img width="400" alt="image" src="https://github.com/user-attachments/assets/9d40b834-c47b-48ec-b312-3d8241e39969" /> the minimize icon change is similar to what we did for the composer in https://github.com/discourse/discourse/issues/42017
69 lines
2.4 KiB
Text
Vendored
69 lines
2.4 KiB
Text
Vendored
import { getOwner } from "@ember/owner";
|
|
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import ChatNavbarChannelTitle from "discourse/plugins/chat/discourse/components/chat/navbar/channel-title";
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
|
|
|
module("Component | ChatNavbar | ChannelTitle", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.fabricators = new ChatFabricators(getOwner(this));
|
|
this.chatStateManager = getOwner(this).lookup("service:chat-state-manager");
|
|
});
|
|
|
|
test("shows the star button when the user has joined the channel", async function (assert) {
|
|
this.channel = this.fabricators.channel();
|
|
this.channel.currentUserMembership = { following: true };
|
|
|
|
await render(
|
|
<template><ChatNavbarChannelTitle @channel={{this.channel}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".c-navbar__star-channel-button")
|
|
.exists("the star button is shown");
|
|
});
|
|
|
|
test("does not show the star button when the user has not joined the channel", async function (assert) {
|
|
this.channel = this.fabricators.channel();
|
|
this.channel.currentUserMembership = { following: false };
|
|
|
|
await render(
|
|
<template><ChatNavbarChannelTitle @channel={{this.channel}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".c-navbar__star-channel-button")
|
|
.doesNotExist("the star button is hidden");
|
|
});
|
|
|
|
test("does not show the star button when the drawer is collapsed", async function (assert) {
|
|
this.channel = this.fabricators.channel();
|
|
this.channel.currentUserMembership = { following: true };
|
|
this.chatStateManager.didCollapseDrawer();
|
|
|
|
await render(
|
|
<template><ChatNavbarChannelTitle @channel={{this.channel}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".c-navbar__star-channel-button")
|
|
.doesNotExist("the star button is hidden");
|
|
});
|
|
|
|
test("shows the star button when the drawer is expanded", async function (assert) {
|
|
this.channel = this.fabricators.channel();
|
|
this.channel.currentUserMembership = { following: true };
|
|
this.chatStateManager.didExpandDrawer();
|
|
|
|
await render(
|
|
<template><ChatNavbarChannelTitle @channel={{this.channel}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".c-navbar__star-channel-button")
|
|
.exists("the star button is shown");
|
|
});
|
|
});
|