Files
OmniRoute/tests/unit/ui/combo-timeout-fields.test.tsx
Bob.Hou 4be37d149b feat(dashboard): expose comboTimeoutMs next to Target timeout (#13857)
* feat(dashboard): expose comboTimeoutMs next to Target timeout

The runtime already applied config.comboTimeoutMs as the whole-combo
wall-clock budget (0 = 10-minute hang-stop). Schema treated it as an
unknown passthrough key and the dashboard only painted Target timeout,
so operators could not raise the 15-step failover ceiling from the UI.

Declare comboTimeoutMs on comboRuntimeConfigSchema, mount both knobs in
the combo editor Advanced panel and Combo defaults, and keep
comboTimeoutMs longer than targetTimeoutMs so failover still has time.

Signed-off-by: Minxi Hou <houminxi@gmail.com>

* docs(changelog): attach #13857 to comboTimeoutMs fragment

Signed-off-by: Minxi Hou <houminxi@gmail.com>

* test(dashboard): name comboTimeoutMs store as milliseconds

The input is seconds; the stored config field is milliseconds. The old
title said "in seconds" while asserting 1_200_000.

Signed-off-by: Minxi Hou <houminxi@gmail.com>

* chore(i18n,changelog): translate #13857 keys into all locales and drop the CHANGELOG hunk

---------

Signed-off-by: Minxi Hou <houminxi@gmail.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
2026-09-17 18:47:07 -03:00

53 lines
1.6 KiB
TypeScript

// @vitest-environment jsdom
import { describe, it, expect, afterEach } from "vitest";
import { cleanup, fireEvent, render } from "@testing-library/react";
import ComboTimeoutFields from "@/app/(dashboard)/dashboard/combos/ComboTimeoutFields";
function t(key: string): string {
return key;
}
t.has = () => false;
describe("ComboTimeoutFields", () => {
afterEach(() => {
cleanup();
});
it("renders both timeout inputs and stores comboTimeoutMs in milliseconds", () => {
const captured: Record<string, unknown>[] = [];
const { getByTestId } = render(
<ComboTimeoutFields
config={{ targetTimeoutMs: 600_000 }}
setConfig={(next) => {
captured.push(next);
}}
t={t}
/>
);
const target = getByTestId("combo-target-timeout-ms") as HTMLInputElement;
const combo = getByTestId("combo-combo-timeout-ms") as HTMLInputElement;
expect(target.value).toBe("600");
expect(combo.value).toBe("");
fireEvent.change(combo, { target: { value: "1200" } });
expect(captured.at(-1)?.comboTimeoutMs).toBe(1_200_000);
});
it("clears comboTimeoutMs when the field is emptied", () => {
const captured: Record<string, unknown>[] = [];
const { getByTestId } = render(
<ComboTimeoutFields
config={{ comboTimeoutMs: 1_200_000 }}
setConfig={(next) => {
captured.push(next);
}}
t={t}
/>
);
fireEvent.change(getByTestId("combo-combo-timeout-ms"), { target: { value: "" } });
expect(captured.at(-1)?.comboTimeoutMs).toBeUndefined();
});
});