mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 22:44:03 +00:00
test(adapters-db): increase integration test timeouts to 10s
This commit is contained in:
@@ -28,67 +28,71 @@ describe('createDbTopicMessageHistoryRepository', () => {
|
||||
await queryClient.end({ timeout: 5 })
|
||||
})
|
||||
|
||||
testIfDatabase('lists the latest same-day chat messages in chronological order', async () => {
|
||||
const householdClient = createDbHouseholdConfigurationRepository(databaseUrl!)
|
||||
const historyClient = createDbTopicMessageHistoryRepository(databaseUrl!)
|
||||
const telegramChatId = `-100${Date.now()}`
|
||||
const registered = await householdClient.repository.registerTelegramHouseholdChat({
|
||||
householdName: `History Household ${randomUUID()}`,
|
||||
telegramChatId,
|
||||
telegramChatType: 'supergroup',
|
||||
title: 'History Household'
|
||||
})
|
||||
testIfDatabase(
|
||||
'lists the latest same-day chat messages in chronological order',
|
||||
async () => {
|
||||
const householdClient = createDbHouseholdConfigurationRepository(databaseUrl!)
|
||||
const historyClient = createDbTopicMessageHistoryRepository(databaseUrl!)
|
||||
const telegramChatId = `-100${Date.now()}`
|
||||
const registered = await householdClient.repository.registerTelegramHouseholdChat({
|
||||
householdName: `History Household ${randomUUID()}`,
|
||||
telegramChatId,
|
||||
telegramChatType: 'supergroup',
|
||||
title: 'History Household'
|
||||
})
|
||||
|
||||
createdHouseholdIds.push(registered.household.householdId)
|
||||
createdHouseholdIds.push(registered.household.householdId)
|
||||
|
||||
const baseMessage = {
|
||||
householdId: registered.household.householdId,
|
||||
telegramChatId,
|
||||
telegramThreadId: '777',
|
||||
senderTelegramUserId: '10002',
|
||||
senderDisplayName: 'Mia',
|
||||
isBot: false
|
||||
} as const
|
||||
const baseMessage = {
|
||||
householdId: registered.household.householdId,
|
||||
telegramChatId,
|
||||
telegramThreadId: '777',
|
||||
senderTelegramUserId: '10002',
|
||||
senderDisplayName: 'Mia',
|
||||
isBot: false
|
||||
} as const
|
||||
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-1',
|
||||
telegramUpdateId: 'upd-1',
|
||||
rawText: '08:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T08:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-2',
|
||||
telegramUpdateId: 'upd-2',
|
||||
rawText: '10:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T10:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-3',
|
||||
telegramUpdateId: 'upd-3',
|
||||
rawText: '11:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T11:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-4',
|
||||
telegramUpdateId: 'upd-4',
|
||||
rawText: '12:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T12:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-1',
|
||||
telegramUpdateId: 'upd-1',
|
||||
rawText: '08:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T08:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-2',
|
||||
telegramUpdateId: 'upd-2',
|
||||
rawText: '10:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T10:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-3',
|
||||
telegramUpdateId: 'upd-3',
|
||||
rawText: '11:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T11:00:00.000Z')
|
||||
})
|
||||
await historyClient.repository.saveMessage({
|
||||
...baseMessage,
|
||||
telegramMessageId: 'msg-4',
|
||||
telegramUpdateId: 'upd-4',
|
||||
rawText: '12:00',
|
||||
messageSentAt: instantFromIso('2026-03-05T12:00:00.000Z')
|
||||
})
|
||||
|
||||
const rows = await historyClient.repository.listRecentChatMessages({
|
||||
householdId: registered.household.householdId,
|
||||
telegramChatId,
|
||||
sentAtOrAfter: instantFromIso('2026-03-05T00:00:00.000Z'),
|
||||
limit: 2
|
||||
})
|
||||
const rows = await historyClient.repository.listRecentChatMessages({
|
||||
householdId: registered.household.householdId,
|
||||
telegramChatId,
|
||||
sentAtOrAfter: instantFromIso('2026-03-05T00:00:00.000Z'),
|
||||
limit: 2
|
||||
})
|
||||
|
||||
expect(rows.map((row) => row.rawText)).toEqual(['11:00', '12:00'])
|
||||
expect(rows.map((row) => row.rawText)).toEqual(['11:00', '12:00'])
|
||||
|
||||
await householdClient.close()
|
||||
await historyClient.close()
|
||||
})
|
||||
await householdClient.close()
|
||||
await historyClient.close()
|
||||
},
|
||||
10000
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user