Commit
Cover summary sorting and deletion in store tests
commit
98b8a2f
1 changed file with +13 and −3
modified server/store/sessionStore.test.ts +13 −3
| @@ -60,7 +60,7 @@describe('SessionStore', () => { | ||
| 60 | 60 | expect(updated.status).toBe('done') |
| 61 | 61 | }) |
| 62 | 62 | |
| 63 | - it('lists sessions with id, name, status only', async () => { | |
| 63 | + it('lists sessions as summaries, newest first', async () => { | |
| 64 | 64 | const a = await store.createSession('alpha', '/tmp/a') |
| 65 | 65 | const b = await store.createSession('beta', '/tmp/b') |
| 66 | 66 | await store.updateTurn(b.id, { status: 'done' }) |
| @@ -69,10 +69,20 @@describe('SessionStore', () => { | ||
| 69 | 69 | expect(list).toHaveLength(2) |
| 70 | 70 | expect(list).toEqual( |
| 71 | 71 | expect.arrayContaining([ |
| 72 | - { id: a.id, name: 'alpha', status: 'interviewing' }, | |
| 73 | - { id: b.id, name: 'beta', status: 'done' }, | |
| 72 | + { id: a.id, name: 'alpha', status: 'interviewing', createdAt: a.createdAt }, | |
| 73 | + { id: b.id, name: 'beta', status: 'done', createdAt: b.createdAt }, | |
| 74 | 74 | ]), |
| 75 | 75 | ) |
| 76 | + const sorted = [...list].sort((x, y) => y.createdAt.localeCompare(x.createdAt)) | |
| 77 | + expect(list).toEqual(sorted) | |
| 78 | + }) | |
| 79 | + | |
| 80 | + it('deletes a session and reports missing ones', async () => { | |
| 81 | + const session = await store.createSession('gone soon', '/tmp/g') | |
| 82 | + expect(await store.deleteSession(session.id)).toBe(true) | |
| 83 | + expect(await store.getSession(session.id)).toBeNull() | |
| 84 | + expect(await store.listSessions()).toEqual([]) | |
| 85 | + expect(await store.deleteSession(session.id)).toBe(false) | |
| 76 | 86 | }) |
| 77 | 87 | |
| 78 | 88 | it('lists no sessions when the base directory does not exist yet', async () => { |