diff --git a/src-tauri/src/config/tests.rs b/src-tauri/src/config/tests.rs index 207c8f3d8..8779288d3 100644 --- a/src-tauri/src/config/tests.rs +++ b/src-tauri/src/config/tests.rs @@ -5,8 +5,8 @@ use proptest::prelude::*; use proxycast_core::config::{ collapse_tilde, contains_tilde, expand_tilde, Config, ConfigManager, CustomProviderConfig, - HotReloadManager, LoggingConfig, ProviderConfig, ProvidersConfig, ReloadResult, - RetrySettings, RoutingConfig, ServerConfig, YamlService, + HotReloadManager, LoggingConfig, ProviderConfig, ProvidersConfig, ReloadResult, RetrySettings, + RoutingConfig, ServerConfig, YamlService, }; use std::io::Write; use tempfile::NamedTempFile; diff --git a/src/components/agent/chat/utils/legacyQuestionnaireA2UI.test.ts b/src/components/agent/chat/utils/legacyQuestionnaireA2UI.test.ts index edd1fe7fe..8bb89604a 100644 --- a/src/components/agent/chat/utils/legacyQuestionnaireA2UI.test.ts +++ b/src/components/agent/chat/utils/legacyQuestionnaireA2UI.test.ts @@ -1,5 +1,11 @@ import { describe, expect, it } from "vitest"; +import type { + A2UIComponent, + ChoicePickerComponent, + TextFieldComponent, +} from "@/components/content-creator/a2ui/types"; + import { buildLegacyQuestionnaireSubmissionPayload, buildLegacyQuestionnaireA2UI, @@ -16,6 +22,20 @@ const LEGACY_QUESTIONNAIRE = `为了继续推进,我需要你先补充以下 - 语气偏好:正式严谨 / 友好专业 / 直接高效 - 是否需要加入明确行动号召?`; +type LegacyQuestionFieldComponent = (ChoicePickerComponent | TextFieldComponent) & { + label: string; +}; + +function isLegacyQuestionFieldComponent( + component: A2UIComponent, +): component is LegacyQuestionFieldComponent { + return ( + (component.component === "ChoicePicker" || + component.component === "TextField") && + typeof component.label === "string" + ); +} + describe("legacyQuestionnaireA2UI", () => { it("应将结构化问卷正文转换为输入区可渲染的 A2UI 表单", () => { const response = buildLegacyQuestionnaireA2UI(LEGACY_QUESTIONNAIRE); @@ -62,13 +82,7 @@ describe("legacyQuestionnaireA2UI", () => { const componentsByLabel = Object.fromEntries( response.components - .filter( - (component) => - (component.component === "ChoicePicker" || - component.component === "TextField") && - "label" in component && - typeof component.label === "string", - ) + .filter(isLegacyQuestionFieldComponent) .map((component) => [component.label, component.id]), ); @@ -95,13 +109,7 @@ describe("legacyQuestionnaireA2UI", () => { const componentsByLabel = Object.fromEntries( response.components - .filter( - (component) => - (component.component === "ChoicePicker" || - component.component === "TextField") && - "label" in component && - typeof component.label === "string", - ) + .filter(isLegacyQuestionFieldComponent) .map((component) => [component.label, component.id]), ); diff --git a/src/lib/tauri-mock/core.ts b/src/lib/tauri-mock/core.ts index 794d2ecef..345562900 100644 --- a/src/lib/tauri-mock/core.ts +++ b/src/lib/tauri-mock/core.ts @@ -2,6 +2,9 @@ * Mock for @tauri-apps/api/core */ +import type { AutomationJobRecord } from "../api/automation"; +import type { AgentRun } from "../api/executionRun"; + import { invokeViaHttp, isDevBridgeAvailable, @@ -226,7 +229,7 @@ function buildMockBrowserSessionLaunchResponse(request: any) { }); } -const mockAutomationJobs = [ +const mockAutomationJobs: AutomationJobRecord[] = [ { id: "automation-job-daily-brief", name: "每日线索巡检", @@ -318,7 +321,7 @@ const mockAutomationJobs = [ }, ]; -const mockAutomationRuns = [ +const mockAutomationRuns: AgentRun[] = [ { id: "automation-run-1", source: "automation",