관리자 사용자 목록: 게스트 삭제 예정 시각 표시
게스트는 사이트를 나가고 하루 지나면 자동 삭제된다. 목록과 상세에 마지막 접속 + 24시간을 보여 주고, 접속 중이거나 방에 자리가 있으면 삭제 보류로 표시한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/** Admin site tests (docs/14-admin.md §9). */
|
||||
import { afterEach, describe, expect, test } from 'bun:test';
|
||||
import { Client, TEST_SUPERADMINS, api, boot, guest, sleep } from './test-utils';
|
||||
import { GUEST_IDLE_MS } from './server';
|
||||
|
||||
const [SUPER, SUPER2] = TEST_SUPERADMINS;
|
||||
type Booted = ReturnType<typeof boot>;
|
||||
@@ -238,4 +239,20 @@ describe('site settings, rooms, users', () => {
|
||||
const actions = (await api(s.base, '/api/admin/audit', { cookie: sup.cookie })).body.entries.map((e: any) => e.action);
|
||||
expect(actions).toEqual(['user.unban', 'user.ban', 'user.rename']);
|
||||
});
|
||||
|
||||
test('superadmin sees when an idle guest will be deleted; none for members or guests still online', async () => {
|
||||
const s = start();
|
||||
const sup = await discordLogin(s, SUPER);
|
||||
const away = await guest(s.base, '떠난손님');
|
||||
const here = await guest(s.base, '있는손님');
|
||||
const c = await new Client(s.base, here.cookie, here.id).connect();
|
||||
clients.push(c);
|
||||
const seen = (s.db.query('SELECT last_seen_at AS t FROM users WHERE id = ?').get(away.id) as { t: number }).t;
|
||||
const list = (await api(s.base, '/api/admin/users', { cookie: sup.cookie })).body.users;
|
||||
const byId = (id: string) => list.find((u: any) => u.id === id);
|
||||
expect(byId(away.id).deleteAt).toBe(seen + GUEST_IDLE_MS);
|
||||
expect(byId(here.id).deleteAt).toBeNull();
|
||||
expect(byId(sup.id).deleteAt).toBeNull();
|
||||
expect((await api(s.base, `/api/admin/users/${away.id}`, { cookie: sup.cookie })).body.user.deleteAt).toBe(seen + GUEST_IDLE_MS);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user