fix(platform): preserve recoverable outcomes and terminal sessions
This commit is contained in:
@@ -17,7 +17,11 @@ import {
|
||||
type GameContractHost,
|
||||
} from '../../YouleNexus/assets/framework/sdk/testing/game-contract-harness.ts';
|
||||
|
||||
test('assertGameContract runs the reusable isolated session conformance suite', () => {
|
||||
const GAME_ROOMTYPE = JSON.parse(readFileSync(
|
||||
new URL('../fixtures/contracts/player-login-room.json', import.meta.url), 'utf8',
|
||||
)).data.roomtype as readonly unknown[];
|
||||
|
||||
test('assertGameContract accepts a fixed-four game with its real nested roomtype and host fixture', () => {
|
||||
let invalidations = 0;
|
||||
let nextModuleId = 0;
|
||||
const restoredDeskinfo: unknown[] = [];
|
||||
@@ -25,17 +29,17 @@ test('assertGameContract runs the reusable isolated session conformance suite',
|
||||
key: 'fixture',
|
||||
gameId: 41,
|
||||
route: 'fixture-route',
|
||||
resolveSeatCount: (roomtype) => {
|
||||
const seats = roomtype[0];
|
||||
if (seats === 2 || seats === 4 || seats === 10) return seats;
|
||||
return 4;
|
||||
},
|
||||
resolveSeatCount: () => 4,
|
||||
createModule: () => makeModule(++nextModuleId, (deskinfo) => { restoredDeskinfo.push(deskinfo); }),
|
||||
};
|
||||
|
||||
assert.doesNotThrow(() => assertGameContract(
|
||||
entry,
|
||||
makeConformanceHost(entry, () => { invalidations++; }, restoredDeskinfo),
|
||||
[{
|
||||
roomtype: GAME_ROOMTYPE,
|
||||
expectedSeatCount: 4,
|
||||
makeHost: makeConformanceHost(entry, () => { invalidations++; }, restoredDeskinfo),
|
||||
}],
|
||||
));
|
||||
assert.equal(invalidations, 2);
|
||||
assert.equal(restoredDeskinfo.length, 0);
|
||||
@@ -65,7 +69,8 @@ function makeModule(id: number, onRestore: (deskinfo: unknown) => void): GameMod
|
||||
handlePlatformEvent(event) {
|
||||
eventCount++;
|
||||
if (event.type === 'room.entered') {
|
||||
assert.equal(event.roomtype[0], 4);
|
||||
assert.deepEqual(event.roomtype, GAME_ROOMTYPE);
|
||||
assert.deepEqual(host!.getSnapshot().room.roomtype, event.roomtype);
|
||||
}
|
||||
},
|
||||
handleGameMessage(message) {
|
||||
@@ -105,7 +110,6 @@ function makeConformanceHost(
|
||||
new URL('../fixtures/contracts/player-login-room.json', import.meta.url),
|
||||
'utf8',
|
||||
)) as { data: Record<string, unknown> };
|
||||
login.data.roomtype = [4];
|
||||
login.data.isbattle = 0;
|
||||
const store = new PlatformStore();
|
||||
store.applyLoginSuccess(parseLoginResponse(login.data));
|
||||
|
||||
Reference in New Issue
Block a user