Skip to content

Commit 739d210

Browse files
committed
test(webview): 为历史消息测试添加类型注解
- 引入 SessionMessage 类型以增强消息数据的类型安全 - 在测试用例中为消息数组明确指定 SessionMessage 类型 - 移除未使用的 state 字段 askPermissions 和 activeSessionStatus - 优化历史记录加载相关测试代码的可读性和维护性
1 parent d01d7d5 commit 739d210

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

packages/vscode-ide-companion/src/webview/components/InputPrompt.test.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import React from "react";
1212
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
1313
import { describe, it, expect, vi, beforeEach } from "vitest";
1414
import InputPrompt, { type InputPromptProps } from "./InputPrompt";
15-
import type { SkillInfo } from "@/webview/types";
15+
import type { SessionMessage, SkillInfo } from "@/webview/types";
1616

1717
// Mock dependencies
1818
vi.mock("@/webview/components/SkillsPanel", () => ({
@@ -136,8 +136,6 @@ const defaultProps: InputPromptProps = {
136136
selectedSkills: [] as SkillInfo[],
137137
availableSkills: [] as SkillInfo[],
138138
pendingPermissionReply: null,
139-
askPermissions: [],
140-
activeSessionStatus: null,
141139
tokenTelemetry: {
142140
model: "test",
143141
thinkingEnabled: false,
@@ -413,7 +411,7 @@ describe("InputPrompt", () => {
413411

414412
describe("Loading history from messages", () => {
415413
it("loads user messages from messages prop into history", async () => {
416-
const messages = [
414+
const messages: SessionMessage[] = [
417415
{ role: "user", content: "First message from history" },
418416
{ role: "assistant", content: "Assistant response" },
419417
{ role: "user", content: "Second message from history" },
@@ -456,7 +454,7 @@ describe("InputPrompt", () => {
456454
});
457455

458456
it("ignores non-user messages when building history", async () => {
459-
const messages = [
457+
const messages: SessionMessage[] = [
460458
{ role: "user", content: "User message" },
461459
{ role: "assistant", content: "Should be ignored" },
462460
{ role: "tool", content: "Should also be ignored" },

0 commit comments

Comments
 (0)