fix: restore puzzle runtime url state

This commit is contained in:
2026-05-25 22:52:38 +08:00
parent 30cf8abbf7
commit eb6ab404e2
12 changed files with 1917 additions and 177 deletions

View File

@@ -1,6 +1,9 @@
/* @vitest-environment jsdom */
import { describe, expect, it } from 'vitest';
import {
pushAppHistoryPath,
resolvePathForSelectionStage,
resolveSelectionStageFromPath,
} from './appPageRoutes';
@@ -117,4 +120,43 @@ describe('appPageRoutes', () => {
'/creation/baby-object-match',
);
});
it('preserves creation restore query params within the same creation flow', () => {
window.history.replaceState(
null,
'',
'/creation/rpg?sessionId=session-1&profileId=profile-1&draftId=draft-1&workId=work-1&clientRuntime=wechat_mini_program',
);
pushAppHistoryPath('/creation/rpg/result');
expect(window.location.pathname).toBe('/creation/rpg/result');
expect(window.location.search).toBe(
'?sessionId=session-1&profileId=profile-1&draftId=draft-1&workId=work-1',
);
});
it('clears creation restore query params when leaving the flow or switching flows', () => {
window.history.replaceState(
null,
'',
'/creation/rpg?sessionId=session-1&profileId=profile-1',
);
pushAppHistoryPath('/creation/puzzle');
expect(window.location.pathname).toBe('/creation/puzzle');
expect(window.location.search).toBe('');
window.history.replaceState(
null,
'',
'/creation/rpg?sessionId=session-2&profileId=profile-2',
);
pushAppHistoryPath('/');
expect(window.location.pathname).toBe('/');
expect(window.location.search).toBe('');
});
});