From 67cd56acc73c137a6cdabcd25cb54a8e32c7de61 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 12 May 2026 22:11:09 +0200 Subject: [PATCH] ci(unit-tests): extend grep guard to async vi.mock with dynamic import The pdfjs-dist literal grep added in 9260866f only caught one named trigger of the birpc teardown race; the underlying mechanism (ADR 012 / #553) is any async vi.mock factory whose body performs `await import(...)`. Add a second PCRE-multiline grep matching that shape. Scoped to **/*.{spec,test}.ts under frontend/src/, excluding __meta__ (which holds the fixture strings exercising the meta-test). Defence in depth pairs with the ESLint rule (saves at edit time) and the in-suite meta-test (catches when tests run). Verified locally with real GNU grep against a planted synthetic offender. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index aa65e565..5aa5d748 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -39,10 +39,22 @@ jobs: - name: Assert no banned vi.mock patterns shell: bash run: | + # Literal pdfjs-dist (libLoader pattern — ADR 012) if grep -rF "vi.mock('pdfjs-dist'" frontend/src/; then echo "FAIL: banned vi.mock('pdfjs-dist') pattern found — see ADR 012. Use the libLoader prop injection pattern instead." exit 1 fi + # Async factory with dynamic import in body (named mechanism — ADR 012 / #553). + # Multiline PCRE matches `vi.mock(, async ... { ... await import(...) ... })` + # across line breaks. __meta__ is excluded because it contains fixture strings + # demonstrating the very pattern this check is meant to forbid. + if grep -rPzln 'vi\.mock\([^)]+,\s*async[^{]*\{[\s\S]*?await\s+import\s*\(' \ + --include='*.spec.ts' --include='*.test.ts' \ + --exclude-dir='__meta__' \ + frontend/src/; then + echo "FAIL: banned async vi.mock factory with dynamic import in body — see ADR 012 / #553. Use a synchronous factory + vi.hoisted instead." + exit 1 + fi - name: Run unit and component tests with coverage shell: bash