fix rpg agent refresh restore route
This commit is contained in:
@@ -3,6 +3,7 @@ import { expect, test } from 'vitest';
|
||||
import {
|
||||
clearCustomWorldAgentUiState,
|
||||
readCustomWorldAgentUiState,
|
||||
shouldRestoreCustomWorldAgentUiState,
|
||||
writeCustomWorldAgentUiState,
|
||||
} from './customWorldAgentUiState';
|
||||
|
||||
@@ -73,3 +74,49 @@ test('custom world agent ui state reads from query first and persists to session
|
||||
clearCustomWorldAgentUiState(env);
|
||||
expect(readCustomWorldAgentUiState(env)).toEqual({});
|
||||
});
|
||||
|
||||
test('custom world agent ui state only auto restores stored pointers on RPG creation paths', () => {
|
||||
const sessionStorage = createMemoryStorage();
|
||||
sessionStorage.setItem(
|
||||
'genarrative.custom-world-agent-ui.v1',
|
||||
JSON.stringify({
|
||||
activeSessionId: 'session-1',
|
||||
ownerUserId: 'user-1',
|
||||
}),
|
||||
);
|
||||
|
||||
expect(
|
||||
shouldRestoreCustomWorldAgentUiState({
|
||||
location: {
|
||||
pathname: '/',
|
||||
search: '',
|
||||
},
|
||||
history: null,
|
||||
sessionStorage,
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
shouldRestoreCustomWorldAgentUiState({
|
||||
location: {
|
||||
pathname: '/creation/rpg/agent',
|
||||
search: '',
|
||||
},
|
||||
history: null,
|
||||
sessionStorage,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test('custom world agent ui state restores explicit query pointers on any main path', () => {
|
||||
expect(
|
||||
shouldRestoreCustomWorldAgentUiState({
|
||||
location: {
|
||||
pathname: '/',
|
||||
search: '?customWorldSessionId=session-1',
|
||||
},
|
||||
history: null,
|
||||
sessionStorage: createMemoryStorage(),
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user