fix(test): lazy-load e2e env config

This commit is contained in:
2026-03-08 20:20:23 +04:00
parent 3152858aac
commit 6dd601c7bd

View File

@@ -3,7 +3,6 @@ import { randomUUID } from 'node:crypto'
import { eq } from 'drizzle-orm' import { eq } from 'drizzle-orm'
import { e2eEnv } from '@household/config'
import { createDbClient, schema } from '@household/db' import { createDbClient, schema } from '@household/db'
import { createTelegramBot } from '../../apps/bot/src/bot' import { createTelegramBot } from '../../apps/bot/src/bot'
@@ -13,12 +12,6 @@ import {
registerPurchaseTopicIngestion registerPurchaseTopicIngestion
} from '../../apps/bot/src/purchase-topic-ingestion' } from '../../apps/bot/src/purchase-topic-ingestion'
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 chatId = '-100123456'
const purchaseTopicId = 77 const purchaseTopicId = 77
const commandChatIdNumber = -100123456 const commandChatIdNumber = -100123456
@@ -106,7 +99,21 @@ function parseStatement(text: string): Map<string, string> {
return amounts return amounts
} }
async function loadE2eConfig(): Promise<{ databaseUrl: string }> {
const { e2eEnv } = await import('@household/config')
if (!e2eEnv.E2E_SMOKE_ALLOW_WRITE) {
throw new Error('Set E2E_SMOKE_ALLOW_WRITE=true to run e2e smoke test')
}
return {
databaseUrl: e2eEnv.DATABASE_URL
}
}
async function run(): Promise<void> { async function run(): Promise<void> {
const { databaseUrl } = await loadE2eConfig()
const ids = { const ids = {
household: randomUUID(), household: randomUUID(),
admin: randomUUID(), admin: randomUUID(),