import assert from "node:assert/strict"; import { readdirSync, readFileSync, statSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import test from "node:test"; import { SupabaseConfigurationError } from "../src/lib/supabase/config.ts"; const srcRoot = fileURLToPath(new URL("../src", import.meta.url)); function walk(directory: string): string[] { const entries = readdirSync(directory); const files: string[] = []; for (const name of entries) { const path = join(directory, name); if (statSync(path).isDirectory()) { files.push(...walk(path)); continue; } if (path.endsWith(".ts") || path.endsWith(".tsx")) files.push(path); } return files; } test("user-visible copy never names Supabase after the PostgreSQL cutover", () => { const stale = [ "Supabase 尚未配置", "请先配置 Supabase 环境变量。", "Supabase 配置缺失", "SUPABASE_NOT_CONFIGURED", ]; const hits: string[] = []; for (const file of walk(srcRoot)) { const source = readFileSync(file, "utf8"); for (const needle of stale) { if (source.includes(needle)) hits.push(`${file.slice(srcRoot.length + 1)}: ${needle}`); } } assert.deepEqual(hits, []); const missing = new SupabaseConfigurationError(["APP_DATABASE_URL"]); assert.equal(missing.code, "DATABASE_NOT_CONFIGURED"); assert.match(missing.message, /数据库配置缺失:APP_DATABASE_URL/); assert.doesNotMatch(missing.message, /Supabase/); });