feat(test): add local billing smoke test

This commit is contained in:
2026-03-08 20:14:36 +04:00
parent 082d0f7dcc
commit 3152858aac
4 changed files with 107 additions and 1 deletions

View File

@@ -50,4 +50,13 @@ describe('extractPurchaseTopicCandidate', () => {
expect(record).toBeNull()
})
test('skips slash commands in purchase topic', () => {
const record = extractPurchaseTopicCandidate(
candidate({ rawText: '/statement 2026-03' }),
config
)
expect(record).toBeNull()
})
})

View File

@@ -36,6 +36,10 @@ export function extractPurchaseTopicCandidate(
value: PurchaseTopicCandidate,
config: PurchaseTopicIngestionConfig
): PurchaseTopicRecord | null {
if (value.rawText.trim().startsWith('/')) {
return null
}
if (value.chatId !== config.householdChatId) {
return null
}
@@ -195,14 +199,16 @@ export function registerPurchaseTopicIngestion(
llmFallback?: PurchaseParserLlmFallback
} = {}
): void {
bot.on('message:text', async (ctx) => {
bot.on('message:text', async (ctx, next) => {
const candidate = toCandidateFromContext(ctx)
if (!candidate) {
await next()
return
}
const record = extractPurchaseTopicCandidate(candidate, config)
if (!record) {
await next()
return
}