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