컴퓨터 방 자동 정리 + 게스트 계정 삭제(로그아웃·하루 미접속) + 테스트 10분→1분
- 방 화면을 벗어나면(홈·규칙) detach: 자리·접속 상태는 유지, 방 접속 수에서 빠짐 - 컴퓨터가 있는 방: 사람이 모두 [방 나가기]하면 바로 닫고, 아무도 안 보면 대기실·끝난 방 1분, 게임 중 30분 뒤 정리 - 게스트 로그아웃 = 계정 삭제(자리·전적·세션·소켓), 사이트를 닫고 24시간 지난 게스트도 1분 주기로 삭제 - users.last_seen_at을 요청·소켓 종료 때 갱신(이전엔 갱신 안 됨), 003 마이그레이션에서 기존 게스트 시계 초기화 - 테스트: 무작위 대국 시드를 playoutSeeds()로 평소 1/10, test:full은 전부. bun test --parallel=4, 테스트 서버 종료 대기 1s→50ms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,53 @@ try {
|
||||
console.log(` one-card: my turns ${mine}, computer turns seen ${botTurns}`);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------- leaving practice rooms, guest logout
|
||||
const codeOf = (p: Page) => new URL(p.url()).pathname.split('/').pop()!;
|
||||
const userId = (nick: string) => app.db.query<{ id: string }, [string]>('SELECT id FROM users WHERE nickname = ?').get(nick)?.id;
|
||||
|
||||
await step('오목(게임 중): ← 홈 → 자리는 남고 접속은 끊김, 아무도 안 보면 30분 뒤 정리', async () => {
|
||||
const code = codeOf(a);
|
||||
await a.getByRole('button', { name: '홈으로' }).click();
|
||||
await a.waitForURL(`${ORIGIN}/`);
|
||||
const room = app.rooms.get(code)!;
|
||||
for (let i = 0; i < 50 && room.conns.size; i++) await Bun.sleep(20);
|
||||
if (room.conns.size !== 0) throw new Error(`room still counts ${room.conns.size} connection(s)`);
|
||||
if (room.seatOf(userId('호랑이')!) < 0) throw new Error('seat was not kept');
|
||||
app.rooms.sweep();
|
||||
if (!app.rooms.get(code)) throw new Error('closed too early');
|
||||
room.emptySince = Date.now() - 29 * 60_000;
|
||||
app.rooms.sweep();
|
||||
if (!app.rooms.get(code)) throw new Error('running practice game closed before 30 minutes');
|
||||
room.emptySince = Date.now() - 31 * 60_000;
|
||||
app.rooms.sweep();
|
||||
if (app.rooms.get(code)) throw new Error('practice room nobody looks at was not closed');
|
||||
});
|
||||
|
||||
await step('원카드: 메뉴 → 방 나가기 → 방이 바로 닫힘', async () => {
|
||||
const code = codeOf(b);
|
||||
if (!app.rooms.get(code)) throw new Error('room missing before leaving');
|
||||
const result = b.getByRole('dialog', { name: '게임 결과' });
|
||||
if (await result.count()) await result.getByRole('button', { name: '방 나가기' }).click();
|
||||
else {
|
||||
await b.getByRole('button', { name: '메뉴' }).click();
|
||||
await b.getByRole('button', { name: '🚪 방 나가기' }).click();
|
||||
await b.getByRole('button', { name: '나가기', exact: true }).click();
|
||||
}
|
||||
await b.waitForURL(`${ORIGIN}/`);
|
||||
for (let i = 0; i < 50 && app.rooms.get(code); i++) await Bun.sleep(20);
|
||||
if (app.rooms.get(code)) throw new Error('room still open after everyone left');
|
||||
});
|
||||
|
||||
await step('게스트 로그아웃 → 계정 삭제', async () => {
|
||||
const id = userId('호랑이')!;
|
||||
await a.getByRole('button', { name: '내 계정: 호랑이' }).click();
|
||||
await a.getByRole('menuitem', { name: '🚪 로그아웃' }).click();
|
||||
await a.getByText('게스트 계정은 로그아웃하면 이름과 기록이 모두 지워져요.').waitFor();
|
||||
await a.getByRole('button', { name: '로그아웃', exact: true }).last().click();
|
||||
await a.getByRole('link', { name: /로그인/ }).first().waitFor();
|
||||
if (app.db.query('SELECT 1 FROM users WHERE id = ?').get(id)) throw new Error('guest row still there');
|
||||
});
|
||||
|
||||
if (errors.length) throw new Error(`page errors: ${errors.join(' | ')}`);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
|
||||
Reference in New Issue
Block a user