@@ -15,10 +15,10 @@ import {
1515} from "../lib/nodes/index.ts" ;
1616import * as nodes from "../lib/nodes/index.ts" ;
1717import {
18- migrateCloudSessionRecoveryScope ,
19- readCloudSessionRecovery ,
20- writeCloudSessionRecovery ,
21- } from "../lib/sessions/cloud -recovery.ts" ;
18+ migrateSessionPlacementRecoveryScope ,
19+ readSessionPlacementRecovery ,
20+ writeSessionPlacementRecovery ,
21+ } from "../lib/sessions/session-placement -recovery.ts" ;
2222import { createStorageMock } from "../test-helpers/storage.ts" ;
2323
2424const wsInstances = vi . hoisted ( ( ) : MockWebSocket [ ] => [ ] ) ;
@@ -27,7 +27,7 @@ const recoveryMigrationRuntimeMock = vi.hoisted(() => ({
2727 migrate : vi . fn ( ) ,
2828} ) ) ;
2929
30- vi . mock ( "../lib/sessions/cloud -recovery-migration.runtime.ts" , ( ) => {
30+ vi . mock ( "../lib/sessions/session-placement -recovery-migration.runtime.ts" , ( ) => {
3131 recoveryMigrationRuntimeMock . loaded ( ) ;
3232 return {
3333 default : ( gatewayUrl : string , sourceScope : string , destinationScope : string ) =>
@@ -424,7 +424,7 @@ describe("GatewayBrowserClient", () => {
424424 loadOrCreateDeviceIdentityMock . mockReset ( ) ;
425425 signDevicePayloadMock . mockClear ( ) ;
426426 recoveryMigrationRuntimeMock . loaded . mockClear ( ) ;
427- recoveryMigrationRuntimeMock . migrate . mockImplementation ( migrateCloudSessionRecoveryScope ) ;
427+ recoveryMigrationRuntimeMock . migrate . mockImplementation ( migrateSessionPlacementRecoveryScope ) ;
428428 loadOrCreateDeviceIdentityMock . mockResolvedValue ( {
429429 deviceId : "device-1" ,
430430 privateKey : "private-key" , // pragma: allowlist secret
@@ -1225,13 +1225,13 @@ describe("GatewayBrowserClient", () => {
12251225 sessionKey : "agent:cloud:stale" ,
12261226 messageId : "message-stale" ,
12271227 message : "keep the current connection" ,
1228- profileId : "aws" ,
1228+ target : { kind : "profile" as const , profileId : "aws" } ,
12291229 agentId : "cloud" ,
12301230 gatewayUrl : DEFAULT_GATEWAY_URL ,
12311231 recoveryScope : legacyScope ,
12321232 phase : "sending" as const ,
12331233 } ;
1234- expect ( writeCloudSessionRecovery ( recovery ) ) . toBe ( true ) ;
1234+ expect ( writeSessionPlacementRecovery ( recovery ) ) . toBe ( true ) ;
12351235 const onRecoveryScopeChange = vi . fn ( ) ;
12361236 const client = new GatewayBrowserClient ( {
12371237 url : DEFAULT_GATEWAY_URL ,
@@ -1270,11 +1270,11 @@ describe("GatewayBrowserClient", () => {
12701270 expect ( onRecoveryScopeChange ) . not . toHaveBeenCalled ( ) ;
12711271 expect ( recoveryMigrationRuntimeMock . migrate ) . not . toHaveBeenCalled ( ) ;
12721272 expect ( client . recoveryScopeReady ) . toBe ( false ) ;
1273- expect ( readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ) . toEqual (
1274- recovery ,
1275- ) ;
12761273 expect (
1277- readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , "server-stale" , recovery . sessionKey ) ,
1274+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ,
1275+ ) . toEqual ( recovery ) ;
1276+ expect (
1277+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , "server-stale" , recovery . sessionKey ) ,
12781278 ) . toBeNull ( ) ;
12791279
12801280 secondWs . emitMessage ( {
@@ -1309,13 +1309,13 @@ describe("GatewayBrowserClient", () => {
13091309 expect ( client . recoveryScopeReady ) . toBe ( true ) ;
13101310 expect ( client . recoveryScope ) . toBe ( "server-current" ) ;
13111311 expect (
1312- readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ,
1312+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ,
13131313 ) . toBeNull ( ) ;
13141314 expect (
1315- readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , "server-stale" , recovery . sessionKey ) ,
1315+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , "server-stale" , recovery . sessionKey ) ,
13161316 ) . toBeNull ( ) ;
13171317 expect (
1318- readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , "server-current" , recovery . sessionKey ) ,
1318+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , "server-current" , recovery . sessionKey ) ,
13191319 ) . toEqual ( { ...recovery , recoveryScope : "server-current" } ) ;
13201320 client . stop ( ) ;
13211321 expect ( client . recoveryScopeReady ) . toBe ( false ) ;
@@ -1330,13 +1330,13 @@ describe("GatewayBrowserClient", () => {
13301330 sessionKey : "agent:cloud:shared-browser" ,
13311331 messageId : "message-shared-browser" ,
13321332 message : "keep this task with its credential owner" ,
1333- profileId : "aws" ,
1333+ target : { kind : "profile" as const , profileId : "aws" } ,
13341334 agentId : "cloud" ,
13351335 gatewayUrl : DEFAULT_GATEWAY_URL ,
13361336 recoveryScope : legacyScope ,
13371337 phase : "sending" as const ,
13381338 } ;
1339- expect ( writeCloudSessionRecovery ( recovery ) ) . toBe ( true ) ;
1339+ expect ( writeSessionPlacementRecovery ( recovery ) ) . toBe ( true ) ;
13401340 const onRecoveryScopeChange = vi . fn ( ) ;
13411341 const client = new GatewayBrowserClient ( {
13421342 url : DEFAULT_GATEWAY_URL ,
@@ -1361,11 +1361,11 @@ describe("GatewayBrowserClient", () => {
13611361 } ) ;
13621362 await vi . waitFor ( ( ) => expect ( onRecoveryScopeChange ) . toHaveBeenCalledOnce ( ) ) ;
13631363 expect ( client . recoveryScope ) . toBe ( principalScope ) ;
1364- expect ( readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ) . toEqual (
1365- recovery ,
1366- ) ;
13671364 expect (
1368- readCloudSessionRecovery ( DEFAULT_GATEWAY_URL , principalScope , recovery . sessionKey ) ,
1365+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , legacyScope , recovery . sessionKey ) ,
1366+ ) . toEqual ( recovery ) ;
1367+ expect (
1368+ readSessionPlacementRecovery ( DEFAULT_GATEWAY_URL , principalScope , recovery . sessionKey ) ,
13691369 ) . toBeNull ( ) ;
13701370 client . stop ( ) ;
13711371 } ) ;
0 commit comments