mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
test(vscode): cover terminal outcome stories
This commit is contained in:
@@ -44,6 +44,7 @@ import type {
|
||||
KilocodeNotification,
|
||||
PermissionRequest,
|
||||
ProviderAuthState,
|
||||
SessionCloseReason,
|
||||
QuestionRequest,
|
||||
SuggestionRequest,
|
||||
} from "../types/messages"
|
||||
@@ -160,6 +161,7 @@ export function mockSessionValue(overrides?: {
|
||||
questions?: QuestionRequest[]
|
||||
suggestions?: SuggestionRequest[]
|
||||
status?: string
|
||||
closeReason?: SessionCloseReason
|
||||
}) {
|
||||
const id = overrides?.id ?? "story-session-001"
|
||||
const permissions = overrides?.permissions ?? []
|
||||
@@ -179,6 +181,7 @@ export function mockSessionValue(overrides?: {
|
||||
sessions: () => [],
|
||||
status: () => status,
|
||||
statusInfo: () => ({ type: status }),
|
||||
closeReason: () => overrides?.closeReason,
|
||||
statusText: () => (status === "idle" ? undefined : "Thinking…"),
|
||||
busySince: () => (status === "busy" ? Date.now() - 2000 : undefined),
|
||||
loading: () => false,
|
||||
|
||||
@@ -14,6 +14,7 @@ import { TaskHeader } from "../components/chat/TaskHeader"
|
||||
import { QuestionDock } from "../components/chat/QuestionDock"
|
||||
import { SuggestBar } from "../components/chat/SuggestBar"
|
||||
import { MessageList } from "../components/chat/MessageList"
|
||||
import { TurnOutcome } from "../components/shared/TurnOutcome"
|
||||
import { SessionContext } from "../context/session"
|
||||
import { ServerContext } from "../context/server"
|
||||
import type { Message, Part, QuestionRequest, SuggestionRequest, TodoItem } from "../types/messages"
|
||||
@@ -445,6 +446,52 @@ export const MessageListSubagentToQueuedUserSpacing: Story = {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TurnOutcome - abnormal terminal state cards
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const outcomeMessage: Message = {
|
||||
id: "asst-msg-outcome-001",
|
||||
sessionID: SESSION_ID,
|
||||
role: "assistant",
|
||||
createdAt: new Date(subNow).toISOString(),
|
||||
finish: "unknown",
|
||||
}
|
||||
|
||||
export const TurnOutcomeUnknown: Story = {
|
||||
name: "TurnOutcome - response ended without a finish reason",
|
||||
render: () => {
|
||||
const session = {
|
||||
...mockSessionValue({ id: SESSION_ID, status: "idle", closeReason: "completed" }),
|
||||
visibleMessages: () => [outcomeMessage],
|
||||
}
|
||||
return (
|
||||
<StoryProviders sessionID={SESSION_ID} status="idle" noPadding>
|
||||
<SessionContext.Provider value={session as any}>
|
||||
<TurnOutcome />
|
||||
</SessionContext.Provider>
|
||||
</StoryProviders>
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
export const TurnOutcomeFailed: Story = {
|
||||
name: "TurnOutcome - failed turn fallback",
|
||||
render: () => {
|
||||
const session = {
|
||||
...mockSessionValue({ id: SESSION_ID, status: "idle", closeReason: "error" }),
|
||||
visibleMessages: () => [{ ...outcomeMessage, id: "asst-msg-outcome-002", finish: "error" }],
|
||||
}
|
||||
return (
|
||||
<StoryProviders sessionID={SESSION_ID} status="idle" noPadding>
|
||||
<SessionContext.Provider value={session as any}>
|
||||
<TurnOutcome />
|
||||
</SessionContext.Provider>
|
||||
</StoryProviders>
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TaskHeader with todos
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user