fix(platform): preserve recoverable outcomes and terminal sessions

This commit is contained in:
2026-09-05 10:50:55 +08:00
parent 1e3a21b476
commit 8eae3258ca
16 changed files with 500 additions and 48 deletions
@@ -74,6 +74,7 @@ test('real modern vertical replay preserves wire contracts, room ordering and te
const configRequests: Array<{ url: string; init: RequestInit | undefined }> = [];
const scenes: string[] = [];
const fatals: Error[] = [];
const denials: Array<{ readonly rpc: string; readonly state: number; readonly data: unknown }> = [];
const observations: string[] = [];
const attached: GameHost[] = [];
const restored: unknown[] = [];
@@ -154,6 +155,7 @@ test('real modern vertical replay preserves wire contracts, room ordering and te
showLoading() { scenes.push('loading'); }, showLogin() { scenes.push('login'); },
showLobby() { scenes.push('lobby'); }, showRoom() { scenes.push('room'); },
showReconnect() { scenes.push('reconnect'); }, showKicked() { scenes.push('kicked'); },
showServerDenial(outcome) { denials.push(outcome); },
showFatal(error) { fatals.push(error); },
},
loadResources: async () => {}, waitForMinimumDisplay: async () => {}, clock,
@@ -205,6 +207,18 @@ test('real modern vertical replay preserves wire contracts, room ordering and te
await push(agent, fixture('player-login-success'));
assert.equal(scenes[scenes.length - 1], 'lobby');
assert.equal(runtime.state.room.kind, 'outside');
const lobby = runtime.state;
runtime.joinRoom({ roomcode: '999999', location: { latitude: 1, longitude: 2 }, ip: '127.0.0.1' });
expectedFrames.push({ ...JOIN, data: { ...JOIN.data, roomcode: '999999' } });
const denied = await push(agent, {
route: 'agent', rpc: 'self_join_room',
data: { state: 99, roomcode: '999999', showerror: 1, error: 'Room does not exist' },
});
assert.equal(runtime.state, lobby);
assert.equal(scenes[scenes.length - 1], 'lobby');
assert.equal(denials.length, 1);
assert.deepEqual(denials[0], { rpc: 'self_join_room', state: 99, data: denied.data });
assert.equal(denials[0]?.data, denied.data);
runtime.joinRoom({ roomcode: '100001', location: { latitude: 1, longitude: 2 }, ip: '127.0.0.1' });
expectedFrames.push(JOIN);
verifyFrames();