test(FN-5146): complete Step 4 — update autosize caps and growth regression coverage
Fusion-Task-Id: FN-5146 Fusion-Task-Lineage: 55a9837f-d0e1-475b-9f7f-45262141352e
This commit is contained in:
committed by
gsxdsm
parent
5a1f20f864
commit
6db8c60bef
@@ -217,6 +217,20 @@ describe("ChatView composer autosize", () => {
|
||||
expect(threeLineHeight).toBeGreaterThan(oneLineHeight);
|
||||
});
|
||||
|
||||
it("keeps direct-chat text visible for growth between old and new caps", async () => {
|
||||
renderChatView();
|
||||
|
||||
const textarea = screen.getByPlaceholderText("Type a message...") as HTMLTextAreaElement;
|
||||
Object.defineProperty(textarea, "scrollHeight", {
|
||||
configurable: true,
|
||||
get: () => 500,
|
||||
});
|
||||
|
||||
await userEvent.type(textarea, "large draft");
|
||||
|
||||
expect(textarea.style.height).toBe("500px");
|
||||
});
|
||||
|
||||
it("grows composer height in rooms scope", async () => {
|
||||
localStorage.setItem("fusion:chat-scope", "rooms");
|
||||
renderChatView();
|
||||
@@ -233,6 +247,21 @@ describe("ChatView composer autosize", () => {
|
||||
expect(Number.parseInt(textarea.style.height, 10)).toBeGreaterThan(clampChatInputHeight(40));
|
||||
});
|
||||
|
||||
it("keeps rooms text visible for growth between old and new caps", async () => {
|
||||
localStorage.setItem("fusion:chat-scope", "rooms");
|
||||
renderChatView();
|
||||
|
||||
const textarea = screen.getByTestId("chat-input") as HTMLTextAreaElement;
|
||||
Object.defineProperty(textarea, "scrollHeight", {
|
||||
configurable: true,
|
||||
get: () => 500,
|
||||
});
|
||||
|
||||
await userEvent.type(textarea, "room draft");
|
||||
|
||||
expect(textarea.style.height).toBe("500px");
|
||||
});
|
||||
|
||||
it("recomputes rooms composer height on room switch", async () => {
|
||||
localStorage.setItem("fusion:chat-scope", "rooms");
|
||||
const roomTwo = { ...roomOne, id: "room-002", name: "Room Two", slug: "room-two" };
|
||||
|
||||
@@ -10,11 +10,12 @@ describe("ChatView chat input autosize", () => {
|
||||
const textareaRule = chatViewCss.match(/\.chat-input-textarea\s*\{[^}]*\}/);
|
||||
|
||||
expect(textareaRule).not.toBeNull();
|
||||
expect(textareaRule?.[0]).toContain("max-height: 320px");
|
||||
expect(textareaRule?.[0]).toContain("max-height: 640px");
|
||||
});
|
||||
|
||||
it("clamps oversized textarea growth to the new max height", () => {
|
||||
expect(clampChatInputHeight(600)).toBe(320);
|
||||
expect(clampChatInputHeight(600)).toBe(600);
|
||||
expect(clampChatInputHeight(800)).toBe(640);
|
||||
expect(clampChatInputHeight(600)).not.toBe(120);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,16 +4,20 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { QuickChatFAB, clampQuickChatInputHeight } from "../QuickChatFAB";
|
||||
|
||||
vi.mock("../../api", () => ({
|
||||
fetchDiscoveredSkills: vi.fn().mockResolvedValue([]),
|
||||
fetchModels: vi.fn().mockResolvedValue({
|
||||
models: [],
|
||||
favoriteProviders: [],
|
||||
favoriteModels: [],
|
||||
defaultProvider: "",
|
||||
defaultModelId: "",
|
||||
}),
|
||||
}));
|
||||
vi.mock("../../api", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../../api")>();
|
||||
return {
|
||||
...actual,
|
||||
fetchDiscoveredSkills: vi.fn().mockResolvedValue([]),
|
||||
fetchModels: vi.fn().mockResolvedValue({
|
||||
models: [],
|
||||
favoriteProviders: [],
|
||||
favoriteModels: [],
|
||||
defaultProvider: "",
|
||||
defaultModelId: "",
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../../hooks/useQuickChat", () => ({
|
||||
FN_AGENT_ID: "__fn_agent__",
|
||||
@@ -93,12 +97,13 @@ describe("QuickChatFAB autosize", () => {
|
||||
const textareaRule = quickChatCss.match(/\.quick-chat-textarea\s*\{[^}]*\}/);
|
||||
|
||||
expect(textareaRule).not.toBeNull();
|
||||
expect(textareaRule?.[0]).toContain("max-height: 320px");
|
||||
expect(textareaRule?.[0]).toContain("max-height: 640px");
|
||||
expect(textareaRule?.[0]).toContain("min-height: 40px");
|
||||
});
|
||||
|
||||
it("clamps composer heights to the expected floor and cap", () => {
|
||||
expect(clampQuickChatInputHeight(600)).toBe(320);
|
||||
expect(clampQuickChatInputHeight(600)).toBe(600);
|
||||
expect(clampQuickChatInputHeight(800)).toBe(640);
|
||||
expect(clampQuickChatInputHeight(80)).toBe(80);
|
||||
expect(clampQuickChatInputHeight(20)).toBe(40);
|
||||
});
|
||||
@@ -117,4 +122,18 @@ describe("QuickChatFAB autosize", () => {
|
||||
expect(input.tagName).toBe("TEXTAREA");
|
||||
expect((input as HTMLTextAreaElement).style.height).toMatch(/^\d+px$/);
|
||||
});
|
||||
|
||||
it("keeps quick chat text visible for growth between old and new caps", () => {
|
||||
render(<QuickChatFAB addToast={vi.fn()} projectId="proj-1" open />);
|
||||
|
||||
const input = screen.getByTestId("quick-chat-input") as HTMLTextAreaElement;
|
||||
Object.defineProperty(input, "scrollHeight", {
|
||||
configurable: true,
|
||||
get: () => 500,
|
||||
});
|
||||
|
||||
fireEvent.change(input, { target: { value: "line 1\nline 2\nline 3\nline 4" } });
|
||||
|
||||
expect(input.style.height).toBe("500px");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user