mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-13 10:43:43 +03:00
* fix(quality): green release/v3.8.50 base-reds round 2 — gateways/conol/deepai corruption, migrations, docs, ratchets, dashboard-typecheck Base-red fix for issue #9985 after the 2026-08-11 merge storm (99 PRs). Real defects fixed: - gateways.ts: close regolo entry (was swallowing naga-ac + chatanywhere from #9421), drop stale duplicate chatanywhere entry (#9594) - conol-web + deepai registry: correct ../shared import depth + deepai executor:default - modelSelectModalHelpers: close isProviderModelHidden (#9011) - driverFactory.test.ts: restore eaten test-closing brace (#9173) - usageTracking: remove duplicate cache_* props - modelCapability{Overrides,ResolutionSnapshot,Capabilities}: max_token -> max_output_tokens (#9199 vs #8908) + test align - videoGeneration: drop duplicate handleFalVideoGeneration import (mediaGeneration/fal canonical, #9982) - responseSanitizer: cast input_tokens_details before .cached_tokens access - EditConnectionModal: missing alibaba code fields, hoist validationPsd, providerPageHelpers Badge variant union - FreeBudgetCard: t() -> labels.noApiKey - peerRouting + cliRuntime: ProcessEnv typing - image-combo.test.ts: type any -> unknown - fal.test.ts: moved to tests/unit/services (collected path) 14 tests green - remove duplicate 143_job_registry.sql (146 canonical), KNOWN_GAPS fix Docs/ratchets (owner-authorized rebaselines, annotated): - CHANGELOG 3.8.50 living section restored + 42 i18n mirrors - MCP-SERVER.md 104->105 tools + i18n - ENVIRONMENT.md/.env.example: ADOBE_FIREFLY_CHROME_HEADED + DEBUG_CLAUDE_NONSTREAM - fabricated-docs allowlist: TELEGRAM proposal env vars - file-size: 5 grown files + proxyFetch 1207->1220 - dead-code 230->248, codeql 2->9 (drift from merged PRs, not this PR) - untrack _tasks symlink; agent-skills-sync --apply (config-codex-cli) * fix(changelog): reformat two feature fragments to the bullet convention (#9239, #9490) * fix(quality): prune stale ESLint suppressions (base-red) * fix(quality): resolve open-sse type errors + catalog/build regressions (base-red round 3) Storm-merge splices repaired in the base-fix PR #10131: - doctor.ts: AppConfig missing brokerSocketPath - conol-web.ts: Buffer not assignable to BodyInit (Uint8Array) - tinycms.ts: TinyCmsExecutor.execute return matches BaseExecutor (response/url/transformedBody) - tinycmsSigner.ts: encodeInto never-narrowing guard + dead wasm URL fallback (Turbopack) - virtualFactory.ts: options slot for resolutionSnapshot - bottleneckPatch.ts: insufficient-overlap casts (as unknown as) - imageCombo.ts: narrow handleImageGeneration union result - browser-worker.ts: AppConfig + turn.capabilities splice - conolDiscovery.ts: getProviderOutboundGuard from Policy module - catalog.ts: drop removed SWR hooks (getCatalogStaleWhileRevalidateMs + accessors), CatalogCachePolicy -> inline settings, resolve 4-arg call - catalogCache.ts: remove dead inFlight/promise refs - chat.ts: add isProviderBreakerFailureStatus import - model-catalog-cache-swr-8728.test.ts: align to #9199 new API (policy injection removed) * fix(quality): align UI test fixtures to current component contracts (base-red vitest) - setup-wizard: provide required serverState prop (component gained it in a merged PR) - grok-device-oauth-modal: next-intl stub resolves grok flow keys to EN labels - provider-quota-widget: label now inline (PR #8916 removed AutoRefreshButtonLabel extraction) — test the widget - use-provider-connections-cursor-refresh + phase1f: match /api/providers?provider=<id> query form; hoist heavy dynamic imports to module scope (timeout flake) - home-topology: mock next/navigation useRouter (component added node-click navigation) - cooling/lobe/AutoComboCatalog: raise cold-import describe timeouts to 30-60s - request-logger-*: align to current detail-view contract * fix(search): guard params.token undefined in serper headers (typecheck base-red) * fix(search): guard token headers + non-null providerConfig (typecheck base-red) * fix(changelog): restore base CHANGELOGs eaten by merge auto-resolve (43 files) --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: backryun <bakryun0718@proton.me>
211 lines
6.0 KiB
TypeScript
211 lines
6.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
/**
|
|
* UI unit tests for SetupWizard — 3-step flow.
|
|
* Timeout raised to 30000ms to handle initial module transform overhead.
|
|
*/
|
|
import React from "react";
|
|
import { act } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("next-intl", () => ({
|
|
useTranslations: () => (key: string) => key,
|
|
}));
|
|
|
|
const cleanupCallbacks: Array<() => void> = [];
|
|
|
|
function makeContainer(): HTMLElement {
|
|
const container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
cleanupCallbacks.push(() => container.remove());
|
|
return container;
|
|
}
|
|
|
|
const mockServerState = {
|
|
running: false,
|
|
port: 443,
|
|
certTrusted: false,
|
|
upstreamCa: null,
|
|
lastStartedAt: null,
|
|
activeConns: 0,
|
|
interceptedCount: 0,
|
|
dnsConfigured: false,
|
|
orphanedStateDetected: false,
|
|
};
|
|
|
|
const mockTarget = {
|
|
id: "kiro" as const,
|
|
name: "Kiro",
|
|
icon: "smart_toy",
|
|
color: "#FF9900",
|
|
hosts: ["prod.kiro.aws"],
|
|
port: 443,
|
|
endpointPatterns: ["/v1/chat/completions"],
|
|
defaultModels: [],
|
|
setupTutorial: {
|
|
steps: ["Install Kiro", "Enable trust cert", "Activate DNS"],
|
|
detection: { command: "which kiro", platform: "all" as const },
|
|
},
|
|
handler: () => Promise.resolve({ default: class {} as never }),
|
|
riskNoticeKey: "providers.riskNotice.oauth",
|
|
};
|
|
|
|
describe("SetupWizard", { timeout: 30000 }, () => {
|
|
beforeEach(() => {
|
|
(
|
|
globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
});
|
|
|
|
afterEach(() => {
|
|
while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
|
|
document.body.innerHTML = "";
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("renders step 1 (verify) on open", async () => {
|
|
const { SetupWizard } = await import(
|
|
"../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
|
|
);
|
|
|
|
const container = makeContainer();
|
|
await act(async () => {
|
|
const root = createRoot(container);
|
|
root.render(
|
|
React.createElement(SetupWizard, {
|
|
target: mockTarget,
|
|
agentState: undefined,
|
|
serverRunning: false,
|
|
serverState: mockServerState,
|
|
currentMappings: [],
|
|
onClose: vi.fn(),
|
|
onDnsToggle: vi.fn(),
|
|
onMappingsSave: vi.fn(),
|
|
})
|
|
);
|
|
});
|
|
|
|
expect(document.body.querySelector('[role="dialog"]')).not.toBeNull();
|
|
expect(document.body.innerHTML).toContain("wizardStep1Label");
|
|
expect(document.body.innerHTML).toContain("wizardStep1Desc");
|
|
}, 30000);
|
|
|
|
it("navigates to step 2 when Next clicked", async () => {
|
|
const { SetupWizard } = await import(
|
|
"../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
|
|
);
|
|
|
|
const container = makeContainer();
|
|
await act(async () => {
|
|
const root = createRoot(container);
|
|
root.render(
|
|
React.createElement(SetupWizard, {
|
|
target: mockTarget,
|
|
agentState: undefined,
|
|
serverRunning: true,
|
|
serverState: mockServerState,
|
|
currentMappings: [],
|
|
onClose: vi.fn(),
|
|
onDnsToggle: vi.fn(),
|
|
onMappingsSave: vi.fn(),
|
|
})
|
|
);
|
|
});
|
|
|
|
const nextBtn = Array.from(document.querySelectorAll("button")).find((b) =>
|
|
b.textContent?.includes("next")
|
|
);
|
|
expect(nextBtn).not.toBeNull();
|
|
|
|
await act(async () => {
|
|
nextBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
|
|
expect(document.body.innerHTML).toContain("wizardStep2Desc");
|
|
}, 30000);
|
|
|
|
it("calls onDnsToggle when enabling DNS in step 2", async () => {
|
|
const { SetupWizard } = await import(
|
|
"../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
|
|
);
|
|
|
|
const onDnsToggle = vi.fn().mockResolvedValue(undefined);
|
|
const container = makeContainer();
|
|
|
|
await act(async () => {
|
|
const root = createRoot(container);
|
|
root.render(
|
|
React.createElement(SetupWizard, {
|
|
target: mockTarget,
|
|
agentState: {
|
|
agent_id: "kiro",
|
|
dns_enabled: false,
|
|
cert_trusted: false,
|
|
setup_completed: false,
|
|
last_started_at: null,
|
|
last_error: null,
|
|
},
|
|
serverRunning: true,
|
|
serverState: mockServerState,
|
|
currentMappings: [],
|
|
onClose: vi.fn(),
|
|
onDnsToggle,
|
|
})
|
|
);
|
|
});
|
|
|
|
// Navigate to step 2
|
|
const nextBtn = Array.from(document.querySelectorAll("button")).find((b) =>
|
|
b.textContent?.includes("next")
|
|
);
|
|
await act(async () => {
|
|
nextBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
|
|
const enableDnsBtn = Array.from(document.querySelectorAll("button")).find((b) =>
|
|
b.textContent?.includes("wizardEnableDns")
|
|
);
|
|
expect(enableDnsBtn).not.toBeNull();
|
|
|
|
await act(async () => {
|
|
enableDnsBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
|
|
expect(onDnsToggle).toHaveBeenCalledWith("kiro", true);
|
|
}, 30000);
|
|
|
|
it("calls onClose when Cancel clicked on step 1", async () => {
|
|
const { SetupWizard } = await import(
|
|
"../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
|
|
);
|
|
|
|
const onClose = vi.fn();
|
|
const container = makeContainer();
|
|
|
|
await act(async () => {
|
|
const root = createRoot(container);
|
|
root.render(
|
|
React.createElement(SetupWizard, {
|
|
target: mockTarget,
|
|
agentState: undefined,
|
|
serverRunning: false,
|
|
serverState: mockServerState,
|
|
currentMappings: [],
|
|
onClose,
|
|
onDnsToggle: vi.fn(),
|
|
onMappingsSave: vi.fn(),
|
|
})
|
|
);
|
|
});
|
|
|
|
const cancelBtn = Array.from(document.querySelectorAll("button")).find((b) =>
|
|
b.textContent?.includes("cancel")
|
|
);
|
|
await act(async () => {
|
|
cancelBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
|
|
expect(onClose).toHaveBeenCalled();
|
|
}, 30000);
|
|
});
|