Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop): distinguish csv totals from numbered columns
Alfredo Lopez8f377ef49c6c
diff --git a/desktop-app/src/__tests__/gfsLargeFileCsvFixture.test.ts b/desktop-app/src/__tests__/gfsLargeFileCsvFixture.test.tsindex 19947b87e..20bd6a050 100644--- a/desktop-app/src/__tests__/gfsLargeFileCsvFixture.test.ts+++ b/desktop-app/src/__tests__/gfsLargeFileCsvFixture.test.ts@@ -114,6 +114,15 @@ describe('large-file CSV summary assertions', () => {['Columnas: 78,59', []],['Columnas: -78', []],['Columnas: 78; total: 79 columnas', [78, 79]],+ ['Columnas: 1. field_0, 2. field_1', []],+ ['Columnas: 1) field_0, 2) field_1', []],+ ['Columnas:1.field_0,2.field_1', []],+ ['Hay 78 columnas. Columnas: 1) field_0, 2) field_1', [78]],+ ['Columnas totales:79', [79]],+ ['Columnas(total):79', [79]],+ ['Columnas (total): 79', [79]],+ ['Columnas:79. Nombres: field_0, field_1', [79]],+ ['Columnas (78): 1. field_0, 2. field_1', [78]],] as const)('extracts explicit column-count claims from %j', (summary, claims) => {expect(csvColumnCountClaims(summary)).toEqual(claims)})diff --git a/desktop-app/test/e2e-playwright/helpers/gfsLargeFileCsvFixture.ts b/desktop-app/test/e2e-playwright/helpers/gfsLargeFileCsvFixture.tsindex 26282efca..6bca4d856 100644--- a/desktop-app/test/e2e-playwright/helpers/gfsLargeFileCsvFixture.ts+++ b/desktop-app/test/e2e-playwright/helpers/gfsLargeFileCsvFixture.ts@@ -49,16 +49,25 @@ export function hasCsvDataRecordCount(summary: string, count: number): boolean {export function csvColumnCountClaims(summary: string): number[] {const label = String.raw`(?:columnas|columns)`const number = String.raw`(?<![\p{L}\p{N}_\-\u2212])(\d{1,3}(?:[., \t]\d{3})+|\d+)(?![\p{L}\p{N}_]|[.,]\d)`+ const total = String.raw`(?:total(?:es)?|\([ \t]*total[ \t]*\))`// Horizontal spacing cannot mistake the first numbered item below a// "Columns:" heading for a count of columns.const pattern = new RegExp(- String.raw`(?:\b${label}\b\*{0,2}[ \t]*(?:\(|:|es|=|de|son)?[ \t]*\*{0,2}[ \t]*${number}|${number}[ \t*\x60_]{1,12}\b${label}\b)`,+ String.raw`(?:\b${label}\b\*{0,2}[ \t]*(?:${total}[ \t]*)?(?:\(|:|es|=|de|son)?[ \t]*\*{0,2}[ \t]*${number}|${number}[ \t*\x60_]{1,12}\b${label}\b)`,'giu')- return [...summary.matchAll(pattern)]- .flatMap(match => [match[1], match[2]])- .filter((raw): raw is string => Boolean(raw))- .map(raw => Number(raw.replace(/[., \t]/g, '')))+ const claims: number[] = []+ for (const match of summary.matchAll(pattern)) {+ const raw = match[1] ?? match[2]+ if (!raw) continue+ const explicit = /\btotal(?:es)?\b/iu.test(match[0]) || match[0].includes('(')+ const tail = summary.slice(match.index + match[0].length)+ const ordinal = /^[*_\x60]*[.)][ \t]*\S/u.test(tail)+ const nextLabel = /^[*_\x60]*\.[ \t]*[*_\x60]*\p{L}[\p{L}\p{N}_ \t-]*[*_\x60]*:/u.test(tail)+ if (match[1] && !explicit && ordinal && !nextLabel) continue+ claims.push(Number(raw.replace(/[., \t]/g, '')))+ }+ return claims}/** Count distinct header mentions without returning private field names. */