Files
AgentHub/client/src/test-setup.ts
T
nntrivi2001 2942ced3ec style(config): give Codex the same tab bar as Claude Code, drop the Cursor tab
The Codex tab strip wrapped onto a second row while Claude Code's stayed
one scrollable row, so two panels that are meant to be twins read as
different components. Both now render the same ConfigTabBar — the
scroller lifted out of CcConfig, with the fade edges and chevrons that
only appear when there is somewhere to scroll. The deferral note in
CodexConfig that predicted this is gone with it.

The bar also carries role="tablist"/"tab" and aria-selected now: Codex
had them, Claude Code did not, and one of the two had to win.

Cursor's placeholder tab goes away with the machinery that served only
it — the optional Panel, the "soon" badge, the coming-soon card, and
their four i18n keys.

Element.scrollBy and friends move to test-setup: jsdom has none of them,
and the tab bar now calls them from both pages.
2026-09-09 14:44:25 +07:00

42 lines
1.4 KiB
TypeScript

/**
* @file test-setup.ts
* @description Vitest global setup for the React client test suite. Pulls in
* jest-dom matchers, initializes the real i18n bundle (same as production),
* forces English before each test for deterministic assertions, and runs
* Testing Library cleanup after every test to prevent DOM leakage between cases.
*
* Imported from `vitest.config.ts` via `setupFiles`.
*
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import "@testing-library/jest-dom/vitest";
import { cleanup } from "@testing-library/react";
import { afterEach, beforeEach } from "vitest";
import "./i18n/index";
import i18n from "i18next";
/** jsdom does not implement ResizeObserver — stub it for components that use it. */
// @ts-expect-error global stub
global.ResizeObserver = class {
observe() {}
disconnect() {}
};
/** jsdom implements no scrolling — stub the methods the tab bars call. */
for (const fn of ["scrollIntoView", "scrollBy", "scrollTo"] as const) {
if (!(Element.prototype as unknown as Record<string, unknown>)[fn]) {
(Element.prototype as unknown as Record<string, unknown>)[fn] = function () {};
}
}
/** Pin locale to English — LanguageDetector may otherwise pick up zh/vi from the host OS. */
beforeEach(() => {
i18n.changeLanguage("en");
});
/** Unmount rendered trees and reset the document between tests. */
afterEach(() => {
cleanup();
});