Import apps/android/tests/bot-room-rows.test.ts

This commit is contained in:
QQ 2026-11-17 08:34:33 +08:00
parent 72887a6edf
commit 2d52bfab56
1 changed files with 11 additions and 2 deletions

View File

@ -97,8 +97,17 @@ describe('group round rows transport', () => {
})
describe('which rows a ledger line draws', () => {
it('prefers a live snapshot that already holds replies', async () => {
expect(preferredRoomRows([{ text: 'live' }], [{ text: 'fetched' }])).toEqual([{ text: 'live' }])
it('replaces a partial live cache with the complete Host round', () => {
const first = { botId: 'first', text: 'HARU_GROUP_OK' }
const second = { botId: 'second', text: 'HARU_GROUP_OK' }
expect(preferredRoomRows([first], [first, second])).toEqual([first, second])
})
it('keeps cached replies until a read succeeds, but respects an authoritative empty result', () => {
const cached = [{ text: 'cached' }]
expect(preferredRoomRows(cached, undefined)).toEqual(cached)
expect(preferredRoomRows(undefined, undefined)).toEqual([])
expect(preferredRoomRows(cached, [])).toEqual([])
})
it('falls back to the fetched rows when the live snapshot is empty', async () => {