fix(ui): repair sync test contracts
This commit is contained in:
@@ -4,7 +4,7 @@ import type { Event, PermissionRequest, QuestionRequest } from "@opencode-ai/sdk
|
||||
|
||||
const listPendingQuestionsCalls: Array<{ directories?: Array<string | null | undefined> }> = []
|
||||
const listPendingPermissionsCalls: Array<{ directories?: Array<string | null | undefined> }> = []
|
||||
const todoPersistWrites: Array<{ sessionID: string; todos: unknown }> = []
|
||||
const todoPersistWrites: Array<{ directory: string; sessionID: string; todos: unknown }> = []
|
||||
let pendingQuestionsResponse: QuestionRequest[] = []
|
||||
let pendingPermissionsResponse: PermissionRequest[] = []
|
||||
let pendingQuestionsShouldThrow = false
|
||||
@@ -44,8 +44,8 @@ mock.module("@/stores/useConfigStore", () => ({
|
||||
mock.module("@/stores/useTodosPersistStore", () => ({
|
||||
useTodosPersistStore: {
|
||||
getState: () => ({
|
||||
setSessionTodos: (sessionID: string, todos: unknown) => {
|
||||
todoPersistWrites.push({ sessionID, todos })
|
||||
setSessionTodos: (directory: string, sessionID: string, todos: unknown) => {
|
||||
todoPersistWrites.push({ directory, sessionID, todos })
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -66,6 +66,7 @@ mock.module("@/components/ui", () => ({
|
||||
|
||||
import { INITIAL_STATE, type State } from "../types"
|
||||
import { ChildStoreManager, type DirectoryStore } from "../child-store"
|
||||
import { getRuntimeKey } from "@/lib/runtime-switch"
|
||||
const {
|
||||
createEventRoutingIndex,
|
||||
handleEvent,
|
||||
@@ -257,10 +258,10 @@ describe("resyncBlockingRequestsForDirectory", () => {
|
||||
storeWrites += 1
|
||||
})
|
||||
setActiveSession("/target", "ses_a")
|
||||
handleEvent("global", event, childStores, routingIndex)
|
||||
handleEvent("global", event, childStores, routingIndex, getRuntimeKey())
|
||||
|
||||
expect(store.getState().todo.ses_a).toEqual(todos)
|
||||
expect(todoPersistWrites).toEqual([{ sessionID: "ses_a", todos }])
|
||||
expect(todoPersistWrites).toEqual([{ directory: "/target", sessionID: "ses_a", todos }])
|
||||
expect(storeWrites).toBe(1)
|
||||
|
||||
const stateAfterFirstSnapshot = store.getState()
|
||||
@@ -272,10 +273,10 @@ describe("resyncBlockingRequestsForDirectory", () => {
|
||||
expect(duplicateTodos).not.toBe(todos)
|
||||
expect(duplicateTodos).toEqual(todos)
|
||||
|
||||
handleEvent("global", duplicateEvent, childStores, routingIndex)
|
||||
handleEvent("global", duplicateEvent, childStores, routingIndex, getRuntimeKey())
|
||||
|
||||
expect(store.getState()).toBe(stateAfterFirstSnapshot)
|
||||
expect(todoPersistWrites).toEqual([{ sessionID: "ses_a", todos }])
|
||||
expect(todoPersistWrites).toEqual([{ directory: "/target", sessionID: "ses_a", todos }])
|
||||
expect(storeWrites).toBe(1)
|
||||
unsubscribe()
|
||||
childStores.disposeAll()
|
||||
|
||||
@@ -339,7 +339,7 @@ describe("input-store attachments", () => {
|
||||
expect(await addPromise).toBe(true)
|
||||
const files = useInputStore.getState().attachedFiles
|
||||
expect(files).toHaveLength(1)
|
||||
expect(files[0].sourceDocumentId).toBeUndefined()
|
||||
expect(files[0].sourceDocumentId).toBe(undefined)
|
||||
|
||||
useInputStore.getState().removeAttachedFile(files[0].id)
|
||||
expect(useInputStore.getState().attachedFiles).toEqual([])
|
||||
|
||||
Reference in New Issue
Block a user