import { readFileSync } from 'node:fs'; import { describe, expect, it } from 'vitest'; import { excludeInventoryHoldingFromKpiSql } from '../src/services/purchaseCostBucketSql'; describe('财务概览排除库存持有', () => { it('KPI 谓词排除 inventory_holding', () => { expect(excludeInventoryHoldingFromKpiSql('cd')).toContain("inventory_holding"); }); it('成本结构查询与所有成本同一排除', () => { const src = readFileSync(new URL('../src/services/marginQueryService.ts', import.meta.url), 'utf8'); const idx = src.indexOf('const structureBucketResult'); expect(idx).toBeGreaterThan(0); const chunk = src.slice(idx, idx + 2800); expect(chunk).toContain('excludeInventoryHoldingFromKpiSql'); }); });