1
0
Fork 0

test(arma-locker-sync): scope locker.apply assertions to this run

The helper counted arma-commands DB-wide, so any spec file that leaves a
game-server online (operation-*, supply-*, respawn-tickets) made later
web-originated locker edits leak into the count once vitest's timing-based
file order put those files first. Filter commands by this run's instance
refs, and mark the grid-metadata fixture write with the lockerSyncOrigin
context flag so it stops enqueuing an echo command of its own.
This commit is contained in:
Jason Fraley 2026-10-06 23:31:38 -04:00
parent 8cda724e21
commit 565e190c7e

View file

@ -59,7 +59,20 @@ async function findLockerApplyCommands(): Promise<{ id: number; payload: unknown
depth: 0,
overrideAccess: true,
});
return found.docs.map((doc) => ({ id: doc.id, payload: (doc as { payload?: unknown }).payload }));
// Scope to this run's instances: other spec files leave game-servers online,
// so their web-originated locker edits also enqueue locker.apply commands.
// An unscoped count made this file order-dependent (25 foreign rows once
// vitest's timing-based file order put those files first).
return found.docs
.filter((doc) => {
const commandPayload = (doc as { payload?: unknown }).payload;
const instanceRef = Array.isArray(commandPayload) ? commandPayload[0] : undefined;
return (
typeof instanceRef === "string" &&
(instanceRef.includes(STEAM_ID) || instanceRef.includes(SLUG))
);
})
.map((doc) => ({ id: doc.id, payload: (doc as { payload?: unknown }).payload }));
}
async function lockerDoc() {
@ -300,6 +313,10 @@ describe("Arma locker sync", () => {
},
],
} as never,
// Fixture write, not an echo-guard test: suppress the locker.apply
// enqueue so this file's absolute command counts stay stable even
// when other spec files leave a game-server online.
context: { lockerSyncOrigin: true },
overrideAccess: true,
depth: 0,
});