Files
Neon-Desk/scripts/e2e-prepare.test.ts

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'bun:test';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { Database } from 'bun:sqlite';
import { ensureFinancialIngestionSchemaHealthy } from '../lib/server/db/financial-ingestion-schema';
import { hasColumn, hasTable } from '../lib/server/db/sqlite-schema-compat';
import { prepareE2eDatabase } from './e2e-prepare';
describe('prepareE2eDatabase', () => {
it('bootstraps a fresh e2e database with the current taxonomy schema shape', () => {
const tempDir = mkdtempSync(join(tmpdir(), 'fiscal-e2e-prepare-'));
const databasePath = join(tempDir, 'e2e.sqlite');
const workflowDataDir = join(tempDir, 'workflow-data');
try {
prepareE2eDatabase({ databasePath, workflowDataDir });
const client = new Database(databasePath, { create: true });
try {
client.exec('PRAGMA foreign_keys = ON;');
expect(hasColumn(client, 'filing_taxonomy_snapshot', 'parser_engine')).toBe(true);
expect(hasTable(client, 'filing_taxonomy_context')).toBe(true);
const health = ensureFinancialIngestionSchemaHealthy(client, { mode: 'auto' });
expect(health.ok).toBe(true);
} finally {
client.close();
}
} finally {
rmSync(tempDir, { force: true, recursive: true });
}
});
});