import { createSeedWorkspace } from "../../core/index"; import { useWorkspace } from "../../workspaceStore"; const REGRESSION_CASE_ID = "tc-opsx-http8-regression"; /** 装载 / 刷新本地 Gin echo 八组合回归用例(不整库清空) */ export function installHttp8Regression(): string { const seed = createSeedWorkspace(); const state = useWorkspace.getState(); const seedCase = seed.testCases.find((c) => c.id === REGRESSION_CASE_ID) ?? seed.testCases[0]!; const localEnv = seed.environments.find((e) => e.name === "本地") ?? seed.environments[0]; const hasCase = state.testCases.some((c) => c.id === REGRESSION_CASE_ID); const hasCollection = state.collections.some((c) => c.name === "示例集合"); const localExisting = state.environments.find((e) => e.name === "本地"); state.loadWorkspaceData({ version: 2, collections: hasCollection ? state.collections.map((c) => (c.name === "示例集合" ? seed.collections[0]! : c)) : [...state.collections, ...seed.collections], environments: localExisting ? state.environments : [...state.environments, ...seed.environments.filter((e) => e.name === "本地")], activeEnvironmentId: localExisting?.id ?? localEnv?.id ?? state.activeEnvironmentId, history: state.history, settings: state.settings, testCases: hasCase ? state.testCases.map((c) => (c.id === REGRESSION_CASE_ID ? seedCase : c)) : [...state.testCases, seedCase], testRuns: state.testRuns, schedules: state.schedules, }); return seedCase.id; }