fix(webui): stabilize interaction tests and tooltip dismissal
This commit is contained in:
1 parent
c4dac649da
commit
8aa0deaca3
9 files changed
+172
-24
No files matched your search
@@ -18,10 +18,10 @@ export function HoverHint({ content, children, enabled = true, side = "top", ali
|
||||
<TooltipProvider>
|
||||
<Tooltip open={enabled && open} onOpenChange={(next) => setOpen(enabled && next)}>
|
||||
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
||||
<TooltipContent side={side} align={align} sideOffset={sideOffset}
|
||||
{enabled && open ? <TooltipContent side={side} align={align} sideOffset={sideOffset}
|
||||
className={cn("max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words", contentClassName)}>
|
||||
{content}
|
||||
</TooltipContent>
|
||||
</TooltipContent> : null}
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { MessageBlockMenuActions, MessageBubble } from "@/components/MessageBubble";
|
||||
import { preloadMarkdownText } from "@/components/MarkdownText";
|
||||
import { ThreadMessages } from "@/components/thread/ThreadMessages";
|
||||
import { setAppLanguage } from "@/i18n";
|
||||
import { parseWebuiThreadPayload } from "@/lib/api";
|
||||
@@ -110,6 +111,8 @@ function menuActions(root: ParentNode = document): HTMLElement {
|
||||
}
|
||||
|
||||
describe("MessageBubble", () => {
|
||||
beforeAll(preloadMarkdownText);
|
||||
|
||||
it.each(["live", "paged history"] as const)("renders and copies literal output unchanged through %s, alongside ordinary Markdown", async (source) => {
|
||||
const raw = [
|
||||
" Switched model preset to `raw`.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { act, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { SessionInfoPopover } from "@/components/thread/SessionInfoPopover";
|
||||
import { setAppLanguage } from "@/i18n";
|
||||
@@ -34,6 +34,8 @@ function automationsResponse(jobs: unknown[]) {
|
||||
}
|
||||
|
||||
describe("SessionInfoPopover", () => {
|
||||
beforeAll(async () => { await import("@/components/settings/system/AutomationsSettings"); });
|
||||
|
||||
beforeEach(async () => {
|
||||
await setAppLanguage("en");
|
||||
requestMutation.mockReset();
|
||||
|
||||
@@ -49,12 +49,17 @@ describe("Inline shared proxy setup", () => {
|
||||
const url = within(parent).getByPlaceholderText("https://api.example.com/v1");
|
||||
const key = within(parent).getByPlaceholderText("Enter API key");
|
||||
await user.type(name, "Keep this draft");
|
||||
await user.type(url, "https://gateway.example/v1");
|
||||
await user.type(key, "draft-key");
|
||||
await user.click(url);
|
||||
await user.paste("https://gateway.example/v1");
|
||||
await user.click(key);
|
||||
await user.paste("draft-key");
|
||||
await user.click(within(parent).getByRole("button", { name: "Advanced options" }));
|
||||
await user.click(within(parent).getByRole("button", { name: "Configure proxy" }));
|
||||
let setup = await screen.findByRole("dialog", { name: "Shared proxy" });
|
||||
await user.type(within(setup).getByRole("textbox"), "http://127.0.0.1:7890");
|
||||
let proxy = within(setup).getByRole("textbox");
|
||||
await user.click(proxy);
|
||||
await user.paste("http://127.0.0.1:7890");
|
||||
expect(proxy).toHaveValue("http://127.0.0.1:7890");
|
||||
await user.click(within(setup).getByRole("button", { name: "Cancel" }));
|
||||
expect(name).toHaveValue("Keep this draft");
|
||||
expect(url).toHaveValue("https://gateway.example/v1");
|
||||
@@ -62,8 +67,10 @@ describe("Inline shared proxy setup", () => {
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
await user.click(within(parent).getByRole("button", { name: "Configure proxy" }));
|
||||
setup = await screen.findByRole("dialog", { name: "Shared proxy" });
|
||||
expect(within(setup).getByRole("textbox")).toHaveValue("");
|
||||
await user.type(within(setup).getByRole("textbox"), "http://127.0.0.1:7890");
|
||||
proxy = within(setup).getByRole("textbox");
|
||||
expect(proxy).toHaveValue("");
|
||||
await user.click(proxy);
|
||||
await user.paste("http://127.0.0.1:7890");
|
||||
requestMutationMock.mockResolvedValueOnce(saved);
|
||||
await user.click(within(setup).getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Shared proxy" })).not.toBeInTheDocument());
|
||||
|
||||
@@ -991,19 +991,29 @@ describe("session-owned task UI", () => {
|
||||
|
||||
it("keeps elapsed time in task rows without repeating it in details", async () => {
|
||||
vi.useFakeTimers();
|
||||
// At 12s row elapsed, the independent activity clock reads 1m 12s.
|
||||
vi.setSystemTime(new Date(162_000));
|
||||
vi.spyOn(performance, "now").mockImplementation(() => Date.now());
|
||||
render(layout());
|
||||
await act(async () => { await Promise.resolve(); });
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(10_000); });
|
||||
fireEvent.click(screen.getByTestId("subagent-task-dock-trigger"));
|
||||
const row = within(screen.getByTestId("subagent-task-tree")).getByRole("button", { name: /Config check Running/ });
|
||||
expect(row).toHaveTextContent("12s");
|
||||
expect(within(row).getByText("12s", { exact: true })).toBeVisible();
|
||||
fireEvent.click(row);
|
||||
const detail = screen.getByRole("dialog", { name: "Config check" });
|
||||
expect(detail).toHaveAccessibleDescription("Running");
|
||||
expect(detail).not.toHaveTextContent("12s");
|
||||
// The child activity has its own wall-clock duration, not the row's elapsed time.
|
||||
const activity = within(detail).getByRole("status", { name: "Working for 1m 12s" });
|
||||
expect(activity).toHaveTextContent(/^Working for 1m 12s$/);
|
||||
const duplicateElapsed = (elapsed: string) => within(detail).queryByText((text, element) =>
|
||||
new RegExp(`\\b${elapsed}\\b`).test(text) && !activity.contains(element));
|
||||
expect(duplicateElapsed("12s")).not.toBeInTheDocument();
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(1000); });
|
||||
expect(row).toHaveTextContent("13s");
|
||||
expect(within(row).getByText("13s", { exact: true })).toBeVisible();
|
||||
expect(activity).toHaveAccessibleName("Working for 1m 13s");
|
||||
expect(activity).toHaveTextContent(/^Working for 1m 13s$/);
|
||||
expect(duplicateElapsed("13s")).not.toBeInTheDocument();
|
||||
expect(fetch).toHaveBeenCalledTimes(1);
|
||||
vi.mocked(performance.now).mockRestore();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { Window as HappyWindow } from "happy-dom";
|
||||
|
||||
import {
|
||||
assistantForkFlags,
|
||||
@@ -62,7 +63,17 @@ describe("ThreadMessages", () => {
|
||||
link.focus();
|
||||
expect(fireEvent.keyDown(link, { key: "F10", shiftKey: true })).toBe(true);
|
||||
expect(link).toHaveFocus();
|
||||
expect(fireEvent.click(link, { ctrlKey: true })).toBe(true);
|
||||
expect(link).toHaveAttribute("href", "https://example.com/?q=one#two");
|
||||
expect(link).toHaveAttribute("target", "_blank");
|
||||
// Happy DOM follows native links; verify the event without accessing the network.
|
||||
const navigation = (window as unknown as HappyWindow).happyDOM.settings.navigation;
|
||||
const previous = navigation.disableMainFrameNavigation;
|
||||
navigation.disableMainFrameNavigation = true;
|
||||
try {
|
||||
expect(fireEvent.click(link, { ctrlKey: true })).toBe(true);
|
||||
} finally {
|
||||
navigation.disableMainFrameNavigation = previous;
|
||||
}
|
||||
});
|
||||
|
||||
it.each(["diff", "collapsed_diff"] as const)(
|
||||
|
||||
Reference in new issue
Block a user