refactor: 收口创作直达恢复判定

This commit is contained in:
2026-06-04 01:43:31 +08:00
parent 75593b8860
commit 0d2d391cb2
6 changed files with 98 additions and 19 deletions

View File

@@ -32,6 +32,7 @@ import {
hasCreationUrlStateValue,
hasPuzzleRuntimeUrlStateValue,
normalizeCreationUrlValue,
resolveInitialCreationUrlRestoreDecision,
} from './platformCreationUrlStateModel';
describe('platformCreationUrlStateModel', () => {
@@ -49,6 +50,50 @@ describe('platformCreationUrlStateModel', () => {
expect(hasCreationUrlStateValue({})).toBe(false);
});
test('resolves initial creation url restore readiness', () => {
const readyParams = {
handled: false,
pathname: '/creation/puzzle/result',
state: { sessionId: 'puzzle-session-1' },
isLoadingPlatform: false,
canReadProtectedData: true,
};
expect(
resolveInitialCreationUrlRestoreDecision({
...readyParams,
handled: true,
}),
).toEqual({ type: 'skip' });
expect(
resolveInitialCreationUrlRestoreDecision({
...readyParams,
pathname: '/works/detail',
}),
).toEqual({ type: 'mark-handled' });
expect(
resolveInitialCreationUrlRestoreDecision({
...readyParams,
state: {},
}),
).toEqual({ type: 'mark-handled' });
expect(
resolveInitialCreationUrlRestoreDecision({
...readyParams,
isLoadingPlatform: true,
}),
).toEqual({ type: 'wait' });
expect(
resolveInitialCreationUrlRestoreDecision({
...readyParams,
canReadProtectedData: false,
}),
).toEqual({ type: 'wait' });
expect(resolveInitialCreationUrlRestoreDecision(readyParams)).toEqual({
type: 'restore',
});
});
test('builds creation restore state for core session based plays', () => {
expect(
buildBigFishCreationUrlState({