test: strengthen user-path coverage and CI gates (#5308)

This commit is contained in:
chengyongru
2026-08-09 21:37:06 +08:00
committed by GitHub
parent 411d6061ae
commit 55ecda275d
19 changed files with 1090 additions and 87 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -304,6 +304,7 @@ describe("App layout", () => {
});
afterEach(() => {
cleanup();
vi.useRealTimers();
});
@@ -2252,7 +2253,7 @@ describe("App layout", () => {
const searchButton = within(sidebar).getByRole("button", { name: "Search" });
const appsButton = within(sidebar).getByRole("button", { name: "Apps" });
expect(searchButton.compareDocumentPosition(appsButton) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(within(sidebar).getByRole("button", { name: "Settings" }));
await user.click(within(sidebar).getByRole("button", { name: "Settings" }));
expect(
await screen.findByRole("navigation", { name: "Settings sections" }),
+6 -1
View File
@@ -1,4 +1,4 @@
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -399,9 +399,14 @@ describe("SettingsView Apps catalog", () => {
dispatchEvent: vi.fn(),
})),
);
vi.stubGlobal(
"fetch",
vi.fn(() => new Promise<Response>(() => {})),
);
});
afterEach(() => {
cleanup();
localStorage.removeItem("nanobot-webui.settings-preferences");
vi.useRealTimers();
vi.unstubAllGlobals();
+4 -2
View File
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
@@ -56,7 +56,9 @@ describe("ThreadMessages", () => {
});
it("preserves an answer's markdown tree across completion and the next prompt", async () => {
await preloadMarkdownText();
await act(async () => {
await preloadMarkdownText();
});
const turnId = "turn-1";
const streaming: UIMessage[] = [
{