Add recoverable administrator room removal and restoration
Preserve room JSON, seats, credentials and messages while removed rooms deny ordinary reads and writes. Add deliberate room-scoped controls, removed-directory filters, persistent player notices and live-authorized atomic version/revision audit receipts. Retain uncertain room/seat requests and hidden recovery drafts through removal; restore the prior pause/join settings without reviving revoked credentials. Fix AI readiness after a joining human or human faction change so real lobby starts remain legal. Verified types, lint, 5314 offline tests, 52 HTTP tests and build. Fourteen authenticated HTTP groups and independent privacy/persistence review passed. Desktop/mobile browser QA confirmed a saved removal after a lost response and refresh, one audit on exact retry, persistent notices and recovery draft continuity. All 1,945 baseline rooms, 4,121 seats and related records preserved. Positive authenticated production admin acceptance remains pending authorized QA operator access; full admin and rules gates remain open.
This commit is contained in:
1 parent
c0cc4de9e1
commit
238de3860d
44 files changed
+4626
-90
No files matched your search
@@ -4,11 +4,38 @@ import {
|
||||
ClientRequestError,
|
||||
requestJson,
|
||||
requestMayHaveCompleted,
|
||||
isRoomRemoved,
|
||||
subscribeRoomRemoval,
|
||||
} from '../lib/client-request';
|
||||
|
||||
const never = () => new Promise<never>(() => {});
|
||||
const pause = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
void test('typed removal retains post-commit proofs and notifies only the affected public room', async () => {
|
||||
const rooms: string[] = [];
|
||||
const stop = subscribeRoomRemoval(room => rooms.push(room));
|
||||
const fetcher: typeof fetch = async () => Response.json({ code: 'ROOM_REMOVED', error: 'Room removed', private: 'NOT_FOR_LISTENERS' }, { status: 410 });
|
||||
try {
|
||||
for (const path of ['/api/rooms/TEST2345', '/api/rooms/TEST2345/control', '/api/rooms/TEST2345/messages', '/api/rooms'])
|
||||
await assert.rejects(requestJson(path, { method: 'POST' }, { fetcher }), error => isRoomRemoved(error) && error.status === 410 && requestMayHaveCompleted(error));
|
||||
assert.deepEqual(rooms, ['TEST2345', 'TEST2345', 'TEST2345']);
|
||||
} finally { stop(); }
|
||||
await assert.rejects(requestJson('/api/rooms/TEST2345', {}, { fetcher }));
|
||||
assert.equal(rooms.length, 3, 'Unmounted controllers no longer receive removal events');
|
||||
assert.equal(requestMayHaveCompleted(new ClientRequestError('Ordinary rejection', 'http', 410)), false);
|
||||
});
|
||||
|
||||
void test('removal observers cannot swallow the typed error or trigger automatic request retries', async () => {
|
||||
let calls = 0;
|
||||
const stop = subscribeRoomRemoval(() => { throw new Error('Controller failed'); });
|
||||
try {
|
||||
await assert.rejects(requestJson('/api/rooms/TEST2345', {}, { fetcher: async () => {
|
||||
calls++; return Response.json({ code: 'ROOM_REMOVED', error: 'Removed' }, { status: 410 });
|
||||
} }), isRoomRemoved);
|
||||
assert.equal(calls, 1);
|
||||
} finally { stop(); }
|
||||
});
|
||||
|
||||
void test('successful JSON preserves mutation body, version and credential options, with one fetch', async () => {
|
||||
let calls = 0;
|
||||
let signal: AbortSignal | null | undefined;
|
||||
|
||||
Reference in new issue
Block a user