From 483c67f0382b0f6b2303e808e892a106580cbf21 Mon Sep 17 00:00:00 2001 From: tahayusab Date: Thu, 10 Sep 2026 12:59:54 +0300 Subject: [PATCH] fix(tests): tolerate CRLF working-tree line endings in freshness and style gates --- scripts/sync-plugin-bootstrap.ts | 5 ++++- src/__tests__/architecture/plugin-bootstrap-fresh.test.ts | 3 ++- src/__tests__/site-explorer/siteExplorerPanel.test.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/sync-plugin-bootstrap.ts b/scripts/sync-plugin-bootstrap.ts index 86f9949e3..1daa237bb 100644 --- a/scripts/sync-plugin-bootstrap.ts +++ b/scripts/sync-plugin-bootstrap.ts @@ -85,7 +85,10 @@ async function bundleEntry(entry: string): Promise { `[sync-plugin-bootstrap] expected exactly one output for ${entry}, got ${result.outputs.length}`, ) } - return await result.outputs[0].text() + const text = await result.outputs[0].text() + // Normalize line endings so the emitted artifact (and the in-memory + // comparison in the freshness gate) is identical on LF and CRLF checkouts. + return text.replace(/\r\n/g, '\n') } /** diff --git a/src/__tests__/architecture/plugin-bootstrap-fresh.test.ts b/src/__tests__/architecture/plugin-bootstrap-fresh.test.ts index 2d0e30a3d..39d4687f1 100644 --- a/src/__tests__/architecture/plugin-bootstrap-fresh.test.ts +++ b/src/__tests__/architecture/plugin-bootstrap-fresh.test.ts @@ -30,7 +30,8 @@ describe('generated plugin bootstrap artifacts', () => { for (const { outFile, content } of built) { const path = join(GENERATED_DIR, outFile) expect(existsSync(path), `missing generated/${outFile}`).toBe(true) - const current = readFileSync(path, 'utf8') + // Tolerate CRLF working-tree line endings on Windows checkouts. + const current = readFileSync(path, 'utf8').replace(/\r\n/g, '\n') expect( current === content, `generated/${outFile} is stale — run \`bun run bootstrap:sync\``, diff --git a/src/__tests__/site-explorer/siteExplorerPanel.test.tsx b/src/__tests__/site-explorer/siteExplorerPanel.test.tsx index 237c0cdef..ac4bb1435 100644 --- a/src/__tests__/site-explorer/siteExplorerPanel.test.tsx +++ b/src/__tests__/site-explorer/siteExplorerPanel.test.tsx @@ -400,7 +400,7 @@ describe('SiteExplorerPanel', () => { expect(treeDropCss).toContain('.dropInside') expect(css).toContain('.dragOverlayRow') - const beforeAfterBlock = treeDropCss.match(/\.dropBefore::before,\n\.dropAfter::after,\n\.dropRoot::after,\n\.rootDropGapActive::after\s*\{[^}]*\}/s)?.[0] ?? '' + const beforeAfterBlock = treeDropCss.match(/\.dropBefore::before,\r?\n\.dropAfter::after,\r?\n\.dropRoot::after,\r?\n\.rootDropGapActive::after\s*\{[^}]*\}/s)?.[0] ?? '' expect(beforeAfterBlock).toContain('position: absolute') expect(beforeAfterBlock).not.toMatch(/(?:^|\n)\s*(margin|padding)\b/)