@@ -6,11 +6,12 @@ import { createDeferred } from "../../../test/helpers/promise.js";
66import { createTempDirTracker } from "../../../test/helpers/temp-dir.js" ;
77import { createEmptyPluginRegistry } from "../../plugins/registry-empty.js" ;
88import { withPluginRuntimeRegistryScope } from "../../plugins/runtime/gateway-request-scope.js" ;
9+ import { openClawStateDatabaseCache } from "../../state/openclaw-state-db-cache.js" ;
910import {
1011 closeOpenClawStateDatabaseByPath ,
1112 closeOpenClawStateDatabaseForTest ,
12- getOpenClawStateDatabaseIfOpen ,
1313} from "../../state/openclaw-state-db.js" ;
14+ import { resolveOpenClawStateSqlitePath } from "../../state/openclaw-state-db.paths.js" ;
1415import type {
1516 TranscriptSourceProvider ,
1617 TranscriptStartRequest ,
@@ -52,6 +53,7 @@ describe("transcripts auto-start stop reporting", () => {
5253 ] ) ( "$name preserves state and finishes siblings" , async ( { blocked, outcome, manual } ) => {
5354 const stateDir = await fs . realpath ( tempDirs . make ( "openclaw-transcripts-auto-stop-" ) ) ;
5455 const options = { env : { ...process . env , OPENCLAW_STATE_DIR : stateDir } } ;
56+ const databasePath = path . resolve ( resolveOpenClawStateSqlitePath ( options . env ) ) ;
5557 const exportRoot = path . join ( stateDir , "transcripts" ) ;
5658 const store = new TranscriptsStore ( exportRoot , options ) ;
5759 const requests = new Map < string , TranscriptStartRequest > ( ) ;
@@ -150,7 +152,8 @@ describe("transcripts auto-start stop reporting", () => {
150152 expect ( stop ) . toHaveBeenCalledTimes ( 2 ) ;
151153 expect ( logger . warn . mock . calls . map ( ( [ message ] ) => message ) ) . toEqual ( warnings ) ;
152154
153- const database = getOpenClawStateDatabaseIfOpen ( options ) ! ;
155+ const database =
156+ openClawStateDatabaseCache . getOpenClawStateDatabaseIfOpenAtPath ( databasePath ) ! ;
154157 expect ( database . db . isOpen ) . toBe ( true ) ;
155158 expect ( closeOpenClawStateDatabaseByPath ( database . path ) ) . toBe ( true ) ;
156159 expect ( database . db . isOpen ) . toBe ( false ) ;
@@ -178,7 +181,9 @@ describe("transcripts auto-start stop reporting", () => {
178181 ) . toContain ( capturedText ) ;
179182 }
180183 }
181- expect ( getOpenClawStateDatabaseIfOpen ( options ) ) . not . toBe ( database ) ;
184+ expect (
185+ openClawStateDatabaseCache . getOpenClawStateDatabaseIfOpenAtPath ( databasePath ) ,
186+ ) . not . toBe ( database ) ;
182187 await expect ( execute ( "status" ) ) . resolves . toMatchObject ( {
183188 details : {
184189 active :
0 commit comments