π OpenHands: AI-Driven Development
test: Weekly test sweep: remove low-value tests + simplify (#16574)
Engel Nyst81e83760a196
diff --git a/AGENTS.md b/AGENTS.mdindex 65fb4d44c7..be457120e1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -74,6 +74,7 @@ Create TDD tests for behavioral changes. Keep tests focused on user behavior and- Mock an underlying service rather than the hook that consumes it.- Extend an existing test file when it is a natural home; create a new file only when necessary.- Avoid brittle presentation-only assertions. Test functional CSS contracts directly when they are behavior.+- Do not mirror literal source, fixture, translation, or class-string definitions in tests. Assert consumer behavior or an actual build/runtime contract instead, and do not export internals solely to make them testable. Preserve coverage for routing, accessibility, async behavior, behavioral contracts, and functional CSS/build contracts.- Use the minimum number of cases that fully cover the intended behavior and edge cases.Use the `e2e-testing` skill for suite selection and E2E-specific requirements.diff --git a/__tests__/components/features/conversation/conversation-tab-content-crossfade.test.tsx b/__tests__/components/features/conversation/conversation-tab-content-crossfade.test.tsxdeleted file mode 100644index 38b8fc7e5c..0000000000--- a/__tests__/components/features/conversation/conversation-tab-content-crossfade.test.tsx+++ /dev/null@@ -1,15 +0,0 @@-import { render, screen } from "@testing-library/react";-import { describe, it, expect } from "vitest";-import { ConversationTabContentCrossfade } from "#/components/features/conversation/conversation-tabs/conversation-tab-content/conversation-tab-content-crossfade";--describe("ConversationTabContentCrossfade", () => {- it("renders the tab content when not loading", () => {- render(- <ConversationTabContentCrossfade showAgentLoading={false} tabKey="files">- <div data-testid="tab-child" />- </ConversationTabContentCrossfade>,- );-- expect(screen.getByTestId("tab-child")).toBeInTheDocument();- });-});diff --git a/__tests__/fixtures/table-demo-conversation.test.ts b/__tests__/fixtures/table-demo-conversation.test.tsdeleted file mode 100644index e186ce616d..0000000000--- a/__tests__/fixtures/table-demo-conversation.test.ts+++ /dev/null@@ -1,24 +0,0 @@-import { describe, expect, it } from "vitest";-import {- TABLE_DEMO_CONVERSATION_ID,- TABLE_DEMO_EVENTS,-} from "#/fixtures/table-demo-conversation";--describe("table demo conversation fixture", () => {- it("seeds a user message and an agent reply with a wide markdown table", () => {- expect(TABLE_DEMO_CONVERSATION_ID).toBe("table-demo");- expect(TABLE_DEMO_EVENTS).toHaveLength(2);- expect(TABLE_DEMO_EVENTS[0]?.source).toBe("user");- expect(TABLE_DEMO_EVENTS[1]?.source).toBe("agent");-- const agentText =- "llm_message" in TABLE_DEMO_EVENTS[1]!- ? TABLE_DEMO_EVENTS[1].llm_message.content[0]- : null;- expect(agentText).toMatchObject({ type: "text" });- if (agentText && "text" in agentText) {- expect(agentText.text).toContain("| Feature | OpenHands |");- expect(agentText.text).toContain("| Continue |");- }- });-});diff --git a/__tests__/i18n/files-diff-label.test.ts b/__tests__/i18n/files-diff-label.test.tsdeleted file mode 100644index 46c65e3006..0000000000--- a/__tests__/i18n/files-diff-label.test.ts+++ /dev/null@@ -1,22 +0,0 @@-import { describe, expect, it } from "vitest";-import fs from "fs";-import path from "path";--// The Files-tab diff toggle was renamed from "Diff view" to just "Diff".-// Lock that down at the source-of-truth (translation.json) rather than the-// rendered label, because the test environment's i18next mock returns keys-// rather than translated strings.-describe("FILES$DIFF_VIEW label", () => {- const translationPath = path.join(- __dirname,- "../../src/i18n/translation.json",- );- const translation = JSON.parse(- fs.readFileSync(translationPath, "utf-8"),- ) as Record<string, Record<string, string>>;-- it('uses "Diff" (not "Diff view") in English', () => {- expect(translation.FILES$DIFF_VIEW).toBeDefined();- expect(translation.FILES$DIFF_VIEW.en).toBe("Diff");- });-});diff --git a/__tests__/i18n/sidebar-mcp-directory-label.test.ts b/__tests__/i18n/sidebar-mcp-directory-label.test.tsdeleted file mode 100644index 5b4e6f064c..0000000000--- a/__tests__/i18n/sidebar-mcp-directory-label.test.ts+++ /dev/null@@ -1,21 +0,0 @@-import fs from "fs";-import path from "path";-import { describe, expect, it } from "vitest";--// The sidebar MCP entry must not use the ambiguous "Integrations" label.-// Lock this down at translation.json because the test i18next mock returns keys.-describe("SIDEBAR$MCP_DIRECTORY label", () => {- const translationPath = path.join(- __dirname,- "../../src/i18n/translation.json",- );- const translation = JSON.parse(- fs.readFileSync(translationPath, "utf-8"),- ) as Record<string, Record<string, string>>;-- it('uses "MCP Directory" (not "Integrations") in English', () => {- expect(translation.SIDEBAR$MCP_DIRECTORY).toBeDefined();- expect(translation.SIDEBAR$MCP_DIRECTORY.en).toBe("MCP Directory");- expect(translation.SIDEBAR$MCP_DIRECTORY.en).not.toBe("Integrations");- });-});diff --git a/__tests__/scripts/dev-with-automation.test.ts b/__tests__/scripts/dev-with-automation.test.tsindex 06bed5c973..5a3ae30db5 100644--- a/__tests__/scripts/dev-with-automation.test.ts+++ b/__tests__/scripts/dev-with-automation.test.ts@@ -33,8 +33,6 @@ import {DEFAULT_AUTOMATION_REPO,DEFAULT_AUTOMATION_PACKAGE,DEFAULT_AUTOMATION_VERSION,- DEFAULT_BACKEND_PORT,- DEFAULT_AUTOMATION_PORT,} from "../../scripts/dev-with-automation.mjs";import {buildAgentServerEnv,@@ -390,22 +388,23 @@ describe("buildConfig", () => {});it("throws when ingress port is busy", async () => {- const busyPort = 8100;-- // Block port 8100const server = net.createServer();- await new Promise<void>((resolve, reject) => {- server.listen(busyPort, "127.0.0.1", () => {+ const busyPort = await new Promise<number>((resolve, reject) => {+ server.listen(0, "127.0.0.1", () => {+ const address = server.address();+ if (!address || typeof address === "string") {+ reject(new Error("Expected a TCP server address"));+ return;+ }servers.push(server);- resolve();+ resolve(address.port);});server.on("error", reject);});- // Should throw instead of falling back to a different portawait expect(buildConfig({ port: busyPort }, envWithIsolatedKeyPath()),- ).rejects.toThrow(/ingress.*port 8100/i);+ ).rejects.toThrow(new RegExp(`ingress.*port ${busyPort}`, "i"));});it("allocates valid ports for all services", async () => {@@ -849,26 +848,6 @@ describe("stack mode routing", () => {});});-describe("default constants", () => {- it("has expected default automation repo", () => {- expect(DEFAULT_AUTOMATION_REPO).toBe(- "https://github.com/OpenHands/automation",- );- });-- it("has expected default automation package", () => {- expect(DEFAULT_AUTOMATION_PACKAGE).toBe("openhands-automation");- });-- it("has expected default backend port", () => {- expect(DEFAULT_BACKEND_PORT).toBe(18000);- });-- it("has expected default automation port", () => {- expect(DEFAULT_AUTOMATION_PORT).toBe(18001);- });-});-describe("setServiceLogListener", () => {afterEach(() => {// Always clear the listener so it doesn't leak between tests.diff --git a/__tests__/utils/extension-module-card-classes.test.ts b/__tests__/utils/extension-module-card-classes.test.tsdeleted file mode 100644index 91fbfd09d4..0000000000--- a/__tests__/utils/extension-module-card-classes.test.ts+++ /dev/null@@ -1,42 +0,0 @@-import { describe, expect, it } from "vitest";-import {- EXTENSION_MODULE_CARD_GRID_SINGLE_COLUMN_MAX_PX,- EXTENSION_MODULE_CARD_INTERACTIVE_CLASS,- extensionModuleCardGridClassName,- extensionModuleCardGridContainerClassName,- extensionModuleCardInteractiveClassName,- extensionModuleCardPillClassName,- extensionModuleCardSurfaceClassName,-} from "#/utils/extension-module-card-classes";--describe("extensionModuleCardInteractive class", () => {- it("uses a dedicated CSS class for focus styling", () => {- expect(EXTENSION_MODULE_CARD_INTERACTIVE_CLASS).toBe(- "extension-module-card-interactive",- );- expect(extensionModuleCardInteractiveClassName).toBe(- EXTENSION_MODULE_CARD_INTERACTIVE_CLASS,- );- });-});--describe("extensionModuleCardSurface class", () => {- it("omits a resting border so tiles stay flush until hover", () => {- expect(extensionModuleCardSurfaceClassName).not.toContain("border");- });-});--describe("extensionModuleCardPill class", () => {- it("omits an outline so chips stay fill-only", () => {- expect(extensionModuleCardPillClassName).not.toContain("border");- });-});--describe("extensionModuleCardGrid classes", () => {- it("uses a container query breakpoint at 600px column width", () => {- expect(EXTENSION_MODULE_CARD_GRID_SINGLE_COLUMN_MAX_PX).toBe(599);- expect(extensionModuleCardGridContainerClassName).toContain("@container");- expect(extensionModuleCardGridClassName).toContain("@min-[600px]:grid-cols-2");- expect(extensionModuleCardGridClassName).not.toContain("md:grid-cols-2");- });-});diff --git a/__tests__/utils/form-control-classes.test.ts b/__tests__/utils/form-control-classes.test.tsdeleted file mode 100644index c2f83ce6f9..0000000000--- a/__tests__/utils/form-control-classes.test.ts+++ /dev/null@@ -1,22 +0,0 @@-import { describe, expect, it } from "vitest";-import {- formControlButtonClassName,- formControlFieldClassName,- formControlShellClassName,-} from "#/utils/form-control-classes";--describe("formControlClasses", () => {- it("standardizes fields, shells, and buttons to 36px with rounded-lg", () => {- expect(formControlFieldClassName).toContain("h-9");- expect(formControlFieldClassName).toContain("rounded-lg");- expect(formControlFieldClassName).toContain("border-border");- expect(formControlFieldClassName).toContain("bg-base-secondary");-- expect(formControlShellClassName).toContain("h-9");- expect(formControlShellClassName).toContain("rounded-lg");- expect(formControlShellClassName).toContain("focus-within:ring-1");-- expect(formControlButtonClassName).toContain("h-9");- expect(formControlButtonClassName).toContain("rounded-lg");- });-});diff --git a/__tests__/utils/hover-reveal-classes.test.ts b/__tests__/utils/hover-reveal-classes.test.tsindex 76f2f47c6b..b5faaaf84c 100644--- a/__tests__/utils/hover-reveal-classes.test.ts+++ b/__tests__/utils/hover-reveal-classes.test.ts@@ -1,13 +1,9 @@-import { describe, expect, it } from "vitest";import { createRequire } from "node:module";import { readFileSync } from "node:fs";import path from "node:path";import { compile } from "tailwindcss";+import { describe, expect, it } from "vitest";import {- FINE_HOVER_ACTION_CLASSES,- FINE_HOVER_PINNED_TIMESTAMP_CLASSES,- FINE_HOVER_RESERVE_CLASSES,- FINE_HOVER_YIELD_CLASSES,hoverRevealActionClassName,hoverRevealPinnedTimestampClassName,hoverRevealReserveClassName,@@ -38,75 +34,32 @@ async function loadStylesheet(id: string, base: string) {}describe("hover-reveal-classes", () => {- it("keeps overflow actions visible by default and only hides them under fine-hover media", () => {- const classes = hoverRevealActionClassName();-- expect(classes).toContain("pointer-events-auto");- expect(classes).toContain("opacity-100");- for (const candidate of FINE_HOVER_ACTION_CLASSES) {- expect(classes).toContain(candidate);- }- });-- it("force-visible actions stay interactable without fine-hover hiding", () => {+ it("keeps force-visible actions interactable", () => {expect(hoverRevealActionClassName(true)).toBe("pointer-events-auto visible opacity-100",);});- it("yields timestamp space on touch and restores it under fine-hover media", () => {- const classes = hoverRevealYieldClassName();-- expect(classes).toContain("opacity-0");- for (const candidate of FINE_HOVER_YIELD_CLASSES) {- expect(classes).toContain(candidate);- }- });-- it("reserves action width on touch and collapses it under fine-hover media", () => {- const classes = hoverRevealReserveClassName();-- expect(classes).toContain("min-w-[3.75rem]");- for (const candidate of FINE_HOVER_RESERVE_CLASSES) {- expect(classes).toContain(candidate);- }- });-- it("hides the pinned-card timestamp under the ellipsis on touch", () => {- const classes = hoverRevealPinnedTimestampClassName();-- expect(classes).toContain("hidden");- for (const candidate of FINE_HOVER_PINNED_TIMESTAMP_CLASSES) {- expect(classes).toContain(candidate);- }- });-- it("keeps fine-hover candidates as complete source literals for Tailwind scanning", () => {+ it("keeps fine-hover candidates discoverable and compilable", async () => {const source = readFileSync(HOVER_REVEAL_SOURCE_PATH, "utf8");const candidates = [- ...FINE_HOVER_ACTION_CLASSES,- ...FINE_HOVER_YIELD_CLASSES,- ...FINE_HOVER_RESERVE_CLASSES,- ...FINE_HOVER_PINNED_TIMESTAMP_CLASSES,- ];+ hoverRevealActionClassName(),+ hoverRevealYieldClassName(),+ hoverRevealReserveClassName(),+ hoverRevealPinnedTimestampClassName(),+ ]+ .flatMap((className) => className.split(" "))+ .filter((candidate) => candidate.startsWith("[@media"));for (const candidate of candidates) {expect(source).toContain(`"${candidate}"`);}- });- it("emits fine-hover media rules into compiled CSS for the literal candidates", async () => {- const candidates = [- ...FINE_HOVER_ACTION_CLASSES,- ...FINE_HOVER_YIELD_CLASSES,- ...FINE_HOVER_RESERVE_CLASSES,- ...FINE_HOVER_PINNED_TIMESTAMP_CLASSES,- ];const { build } = await compile('@import "tailwindcss" source(none);', {base: process.cwd(),loadStylesheet,});- const css = build([...candidates]);+ const css = build(candidates);expect(css).toContain("@media (hover:hover) and (pointer:fine)");expect(css).toContain("pointer-events: none");diff --git a/__tests__/utils/table-row-classes.test.ts b/__tests__/utils/table-row-classes.test.tsdeleted file mode 100644index 89e9192c4d..0000000000--- a/__tests__/utils/table-row-classes.test.ts+++ /dev/null@@ -1,15 +0,0 @@-import { describe, expect, it } from "vitest";-import {- tableCellClassName,- tableRowHeightClassName,- tableRowHoverClassName,-} from "#/utils/table-row-classes";--describe("tableRowClasses", () => {- it("uses a fixed 44px row height and subtle hover token", () => {- expect(tableRowHeightClassName).toBe("h-11");- expect(tableCellClassName).toContain("px-3");- expect(tableCellClassName).toContain("align-middle");- expect(tableRowHoverClassName).toContain("hover:bg-interactive-hover-low");- });-});diff --git a/scripts/dev-with-automation.mjs b/scripts/dev-with-automation.mjsindex 6e47ccbc8a..b19a19472d 100644--- a/scripts/dev-with-automation.mjs+++ b/scripts/dev-with-automation.mjs@@ -1769,8 +1769,6 @@ export {DEFAULT_AUTOMATION_PACKAGE,DEFAULT_AUTOMATION_VERSION,DEFAULT_AUTOMATION_SDK_VERSION,- DEFAULT_BACKEND_PORT,- DEFAULT_AUTOMATION_PORT,};// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdiff --git a/src/utils/extension-module-card-classes.ts b/src/utils/extension-module-card-classes.tsindex 7be857b2a0..f7ee6103b9 100644--- a/src/utils/extension-module-card-classes.ts+++ b/src/utils/extension-module-card-classes.ts@@ -3,19 +3,13 @@ export const extensionModuleCardSurfaceClassName ="rounded-xl bg-base-secondary";/** See `.extension-module-card-interactive` in `src/tailwind.css`. */-export const EXTENSION_MODULE_CARD_INTERACTIVE_CLASS =- "extension-module-card-interactive";-export const extensionModuleCardInteractiveClassName =- EXTENSION_MODULE_CARD_INTERACTIVE_CLASS;+ "extension-module-card-interactive";/** Shared pill chrome for Skills, automation cards, and related modals. */export const extensionModuleCardPillClassName ="inline-flex max-w-full shrink-0 items-center whitespace-nowrap rounded-full bg-[rgba(255,255,255,0.04)] px-2 py-0.5 text-[11px] leading-4 text-tertiary-light";-/** Two-column card grids switch back to one column at or below this width (px). */-export const EXTENSION_MODULE_CARD_GRID_SINGLE_COLUMN_MAX_PX = 599;-/** Establishes the inline-size container queried by {@link extensionModuleCardGridClassName}. */export const extensionModuleCardGridContainerClassName ="@container min-w-0 w-full";diff --git a/src/utils/hover-reveal-classes.ts b/src/utils/hover-reveal-classes.tsindex d8ac8f5ccd..7dbf900f31 100644--- a/src/utils/hover-reveal-classes.ts+++ b/src/utils/hover-reveal-classes.ts@@ -8,7 +8,7 @@ import { cn } from "#/utils/utils";* scanner can emit the arbitrary-variant rules (dynamic prefix concatenation* is not discoverable).*/-export const FINE_HOVER_ACTION_CLASSES = [+const FINE_HOVER_ACTION_CLASSES = ["[@media(hover:hover)_and_(pointer:fine)]:pointer-events-none","[@media(hover:hover)_and_(pointer:fine)]:invisible","[@media(hover:hover)_and_(pointer:fine)]:opacity-0",@@ -20,19 +20,19 @@ export const FINE_HOVER_ACTION_CLASSES = ["[@media(hover:hover)_and_(pointer:fine)]:group-focus-within:opacity-100",] as const;-export const FINE_HOVER_YIELD_CLASSES = [+const FINE_HOVER_YIELD_CLASSES = ["[@media(hover:hover)_and_(pointer:fine)]:opacity-100","[@media(hover:hover)_and_(pointer:fine)]:group-hover:opacity-0","[@media(hover:hover)_and_(pointer:fine)]:group-focus-within:opacity-0",] as const;-export const FINE_HOVER_RESERVE_CLASSES = [+const FINE_HOVER_RESERVE_CLASSES = ["[@media(hover:hover)_and_(pointer:fine)]:min-w-0","[@media(hover:hover)_and_(pointer:fine)]:group-hover:min-w-[3.75rem]","[@media(hover:hover)_and_(pointer:fine)]:group-focus-within:min-w-[3.75rem]",] as const;-export const FINE_HOVER_PINNED_TIMESTAMP_CLASSES = [+const FINE_HOVER_PINNED_TIMESTAMP_CLASSES = ["[@media(hover:hover)_and_(pointer:fine)]:flex","[@media(hover:hover)_and_(pointer:fine)]:group-hover:hidden","[@media(hover:hover)_and_(pointer:fine)]:group-focus-within:hidden",diff --git a/src/utils/table-row-classes.ts b/src/utils/table-row-classes.tsindex c75728b624..768de4be32 100644--- a/src/utils/table-row-classes.ts+++ b/src/utils/table-row-classes.ts@@ -3,15 +3,15 @@ export const tableContainerClassName ="overflow-hidden rounded-md border border-border bg-base-secondary";/** Fixed 44px row height for compact data tables (secrets, automations, MCP). */-export const tableRowHeightClassName = "h-11";+const tableRowHeightClassName = "h-11";-export const tableRowClassName = [+const tableRowClassName = [tableRowHeightClassName,"border-t border-border transition-colors",].join(" ");/** Subtle row highlight on base-secondary tables. */-export const tableRowHoverClassName =+const tableRowHoverClassName ="hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low";export const tableCellClassName = "px-3 align-middle";