mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 16:02:50 +00:00
test(native-chat): make the structured session test harness type-portable
This commit is contained in:
Generated
+19
@@ -6,6 +6,9 @@ importers:
|
||||
.:
|
||||
configDependencies: {}
|
||||
packageManagerDependencies:
|
||||
'@pnpm/exe':
|
||||
specifier: 12.0.0
|
||||
version: 12.0.0
|
||||
pnpm:
|
||||
specifier: 12.0.0
|
||||
version: 12.0.0
|
||||
@@ -56,6 +59,11 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@pnpm/exe@12.0.0':
|
||||
resolution: {integrity: sha512-405vw2qYPPghNxoPRt2cvkGtGNU5gnInDcIe5TztQxe73yUZLqFJN/jCJFGs1xbVaIWDXEVuQ71P8npFZeatZQ==}
|
||||
engines: {node: '>=18.*'}
|
||||
hasBin: true
|
||||
|
||||
pnpm@12.0.0:
|
||||
resolution: {integrity: sha512-ni49w5EZlYaNyUuBdcIXwn6VQI+gO0oidJd48rNPdzt3zdOznt6BcbIvzVO+ajU0Lp+smUimjvWN9kiM6Jp+Zw==}
|
||||
engines: {node: '>=18.*'}
|
||||
@@ -87,6 +95,17 @@ snapshots:
|
||||
'@pnpm/exe.win32-x64@12.0.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe@12.0.0':
|
||||
optionalDependencies:
|
||||
'@pnpm/exe.darwin-arm64': 12.0.0
|
||||
'@pnpm/exe.darwin-x64': 12.0.0
|
||||
'@pnpm/exe.linux-arm64': 12.0.0
|
||||
'@pnpm/exe.linux-arm64-musl': 12.0.0
|
||||
'@pnpm/exe.linux-x64': 12.0.0
|
||||
'@pnpm/exe.linux-x64-musl': 12.0.0
|
||||
'@pnpm/exe.win32-arm64': 12.0.0
|
||||
'@pnpm/exe.win32-x64': 12.0.0
|
||||
|
||||
pnpm@12.0.0:
|
||||
optionalDependencies:
|
||||
'@pnpm/exe.darwin-arm64': 12.0.0
|
||||
|
||||
+16
-13
@@ -1,10 +1,13 @@
|
||||
import React, { forwardRef, useImperativeHandle } from 'react'
|
||||
import { vi } from 'vitest'
|
||||
import { forwardRef, useImperativeHandle } from 'react'
|
||||
import { vi, type Mock } from 'vitest'
|
||||
import type { AgentJournalRenderItem } from '../../../../shared/agent-session-journal-types'
|
||||
import type { AgentSessionBackgroundTask } from '../../../../shared/agent-session-wire'
|
||||
import type { NativeChatQuestionCardProps } from './NativeChatQuestionCard'
|
||||
import type { NativeChatLaunchSeed } from './native-chat-composer-types'
|
||||
|
||||
// Why: a named spy type keeps the harness's inferred return type portable across the test files.
|
||||
type StructuredSessionSpy = Mock
|
||||
|
||||
/**
|
||||
* Shared mock state and `vi.mock` factories for the NativeChatStructuredSession test files.
|
||||
* Load it through `await vi.hoisted(async () => (await import(...)).createStructuredSessionMocks())`
|
||||
@@ -12,8 +15,8 @@ import type { NativeChatLaunchSeed } from './native-chat-composer-types'
|
||||
*/
|
||||
export function createStructuredSessionMocks() {
|
||||
const mocks = {
|
||||
call: vi.fn(),
|
||||
fileLinkClick: vi.fn(),
|
||||
call: vi.fn() as StructuredSessionSpy,
|
||||
fileLinkClick: vi.fn() as StructuredSessionSpy,
|
||||
mode: 'static' as 'static' | 'outbox',
|
||||
status: 'ready' as 'idle' | 'loading' | 'ready' | 'error',
|
||||
messages: null as null | unknown[],
|
||||
@@ -30,14 +33,14 @@ export function createStructuredSessionMocks() {
|
||||
},
|
||||
questionCardProps: null as NativeChatQuestionCardProps | null,
|
||||
promptItems: [] as AgentJournalRenderItem[],
|
||||
respond: vi.fn(),
|
||||
handlePasteEvent: vi.fn(),
|
||||
pasteFromClipboard: vi.fn(),
|
||||
respond: vi.fn() as StructuredSessionSpy,
|
||||
handlePasteEvent: vi.fn() as StructuredSessionSpy,
|
||||
pasteFromClipboard: vi.fn() as StructuredSessionSpy,
|
||||
submissions: [] as unknown[],
|
||||
monitoringBackgroundTasks: false,
|
||||
supportsBackgroundTaskStop: false,
|
||||
backgroundTasks: [] as AgentSessionBackgroundTask[],
|
||||
stopBackgroundTask: vi.fn()
|
||||
stopBackgroundTask: vi.fn() as StructuredSessionSpy
|
||||
}
|
||||
|
||||
const moduleFactories = {
|
||||
@@ -81,7 +84,7 @@ export function createStructuredSessionMocks() {
|
||||
error: outbox.error,
|
||||
hasOlder: false,
|
||||
loadingOlder: false,
|
||||
loadOlder: vi.fn(),
|
||||
loadOlder: vi.fn() as StructuredSessionSpy,
|
||||
prompts: mocks.promptItems,
|
||||
outbox: outbox.outbox,
|
||||
blockedClientMessageId: outbox.blockedClientMessageId,
|
||||
@@ -92,7 +95,7 @@ export function createStructuredSessionMocks() {
|
||||
supportsBackgroundTaskStop: mocks.supportsBackgroundTaskStop,
|
||||
backgroundTasks: mocks.backgroundTasks,
|
||||
turnId: null,
|
||||
cancel: vi.fn(),
|
||||
cancel: vi.fn() as StructuredSessionSpy,
|
||||
stopBackgroundTask: (taskId?: string) =>
|
||||
mocks.stopBackgroundTask(props.sessionId, taskId),
|
||||
respond: mocks.respond,
|
||||
@@ -112,11 +115,11 @@ export function createStructuredSessionMocks() {
|
||||
],
|
||||
optionSurface: {
|
||||
getSnapshot: () => [],
|
||||
setOption: vi.fn(),
|
||||
invokeAction: vi.fn(),
|
||||
setOption: vi.fn() as StructuredSessionSpy,
|
||||
invokeAction: vi.fn() as StructuredSessionSpy,
|
||||
subscribe: () => () => {}
|
||||
},
|
||||
setStructuredOption: vi.fn()
|
||||
setStructuredOption: vi.fn() as StructuredSessionSpy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import React from 'react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { decodeAgentSessionQuestionAnswers } from '../../../../shared/agent-session-question-answer'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
Reference in New Issue
Block a user