mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 10:24:02 +00:00
fix(review): address CodeRabbit review feedback
- Guard prepare script for Docker builds without .git - Add pre-push hook for heavier quality gates (typecheck/test/build) - Pin drizzle-orm version in scripts/package.json - Add E2E_SMOKE_ALLOW_WRITE opt-in guard via e2eEnv abstraction - Create @household/config env-e2e.ts using same t3-env + zod pattern - Make e2e teardown robust with optional chaining + allSettled - Fix markdown code block language identifier (MD040) - Fix CI integration docs to reflect actual workflow
This commit is contained in:
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto'
|
||||
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
import { e2eEnv } from '@household/config'
|
||||
import { createDbClient, schema } from '@household/db'
|
||||
|
||||
import { createTelegramBot } from '../../apps/bot/src/bot'
|
||||
@@ -12,11 +13,12 @@ import {
|
||||
registerPurchaseTopicIngestion
|
||||
} from '../../apps/bot/src/purchase-topic-ingestion'
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL
|
||||
if (!databaseUrl) {
|
||||
throw new Error('DATABASE_URL is required for e2e smoke test')
|
||||
if (!e2eEnv.E2E_SMOKE_ALLOW_WRITE) {
|
||||
throw new Error('Set E2E_SMOKE_ALLOW_WRITE=true to run e2e smoke test')
|
||||
}
|
||||
|
||||
const databaseUrl: string = e2eEnv.DATABASE_URL
|
||||
|
||||
const chatId = '-100123456'
|
||||
const purchaseTopicId = 77
|
||||
const commandChatIdNumber = -100123456
|
||||
@@ -118,15 +120,9 @@ async function run(): Promise<void> {
|
||||
carol: '900003'
|
||||
}
|
||||
|
||||
const coreClient = createDbClient(databaseUrl as string, {
|
||||
max: 2,
|
||||
prepare: false
|
||||
})
|
||||
|
||||
const ingestionClient = createPurchaseMessageRepository(databaseUrl as string)
|
||||
const financeService = createFinanceCommandsService(databaseUrl as string, {
|
||||
householdId: ids.household
|
||||
})
|
||||
let coreClient: ReturnType<typeof createDbClient> | undefined
|
||||
let ingestionClient: ReturnType<typeof createPurchaseMessageRepository> | undefined
|
||||
let financeService: ReturnType<typeof createFinanceCommandsService> | undefined
|
||||
|
||||
const bot = createTelegramBot('000000:test-token')
|
||||
const replies: string[] = []
|
||||
@@ -154,19 +150,29 @@ async function run(): Promise<void> {
|
||||
return { ok: true, result: true } as any
|
||||
})
|
||||
|
||||
registerPurchaseTopicIngestion(
|
||||
bot,
|
||||
{
|
||||
householdId: ids.household,
|
||||
householdChatId: chatId,
|
||||
purchaseTopicId
|
||||
},
|
||||
ingestionClient.repository
|
||||
)
|
||||
|
||||
financeService.register(bot)
|
||||
|
||||
try {
|
||||
coreClient = createDbClient(databaseUrl, {
|
||||
max: 2,
|
||||
prepare: false
|
||||
})
|
||||
|
||||
ingestionClient = createPurchaseMessageRepository(databaseUrl)
|
||||
financeService = createFinanceCommandsService(databaseUrl, {
|
||||
householdId: ids.household
|
||||
})
|
||||
|
||||
registerPurchaseTopicIngestion(
|
||||
bot,
|
||||
{
|
||||
householdId: ids.household,
|
||||
householdChatId: chatId,
|
||||
purchaseTopicId
|
||||
},
|
||||
ingestionClient.repository
|
||||
)
|
||||
|
||||
financeService.register(bot)
|
||||
|
||||
await coreClient.db.insert(schema.households).values({
|
||||
id: ids.household,
|
||||
name: 'E2E Smoke Household'
|
||||
@@ -303,12 +309,13 @@ async function run(): Promise<void> {
|
||||
'E2E smoke passed: purchase ingestion, utility updates, and statements are deterministic'
|
||||
)
|
||||
} finally {
|
||||
await coreClient.db.delete(schema.households).where(eq(schema.households.id, ids.household))
|
||||
|
||||
await Promise.all([
|
||||
coreClient.queryClient.end({ timeout: 5 }),
|
||||
ingestionClient.close(),
|
||||
financeService.close()
|
||||
await Promise.allSettled([
|
||||
coreClient
|
||||
? coreClient.db.delete(schema.households).where(eq(schema.households.id, ids.household))
|
||||
: undefined,
|
||||
coreClient?.queryClient.end({ timeout: 5 }),
|
||||
ingestionClient?.close(),
|
||||
financeService?.close()
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"typecheck": "tsgo --project tsconfig.json --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"drizzle-orm": "*",
|
||||
"drizzle-orm": "^0.44.5",
|
||||
"@household/config": "workspace:*",
|
||||
"@household/db": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user