From 496b0891020721f83b3acca6a10b9b679f8fe24c Mon Sep 17 00:00:00 2001 From: Oleksandr Bezdieniezhnykh Date: Mon, 11 May 2026 03:01:31 +0300 Subject: [PATCH] [AZ-456] Clarify Blackbox Tests imports rule (helpers vs test bodies) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split the "Imports from" entry for the Blackbox Tests cross-cutting component into two cases: - Test bodies (*.test.{ts,tsx}, *.spec.{ts,tsx}, e2e specs) keep the strict "00_foundation only / src/types only" rule per black-box discipline (P9 / environment.md). - Test infrastructure (tests/setup.ts, tests/msw/**, tests/helpers/**, tests/fixtures/**, e2e/playwright.config.ts, e2e/stubs/**, etc.) MAY import testability-purpose production accessors from any layer (e.g. setToken on 01_api-transport, AuthProvider on 02_auth, i18n on 00_foundation) — these helpers ARE the production-equivalent composition root for tests. Surfaced during AZ-456 self-review when render.tsx / auth.ts / navigate.ts had to import production accessors that the task spec explicitly mandated. The original rule was unambiguous-but-incomplete; the doc now matches the practical reality without weakening the black-box discipline for test bodies themselves. Co-authored-by: Cursor --- _docs/02_document/module-layout.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_docs/02_document/module-layout.md b/_docs/02_document/module-layout.md index f85ce0f..5f5caca 100644 --- a/_docs/02_document/module-layout.md +++ b/_docs/02_document/module-layout.md @@ -171,7 +171,9 @@ - `scripts/run-tests.sh`, `scripts/run-performance-tests.sh` (extension only — the files were created in autodev Step 4 as Step 6 placeholders). - `package.json` test-scoped sections only: `scripts.test*`, `scripts.lint:tests`, `devDependencies` for runners (`vitest`, `@vitest/*`, `@playwright/test`, `msw`, `@testing-library/*`), and any test-only `peerDependencies` overrides. - ESLint test-override blocks (`overrides` entries scoped to `tests/**`, `e2e/**`, `**/*.test.{ts,tsx}`). -- **Imports from**: `00_foundation` only (and only `src/types/index.ts` — typed wire-contract enums per `_docs/02_document/tests/environment.md` § Black-box discipline / `P9`). NEVER any other production component's internal files. The static profile enforces this via ripgrep. +- **Imports from**: + - **Test bodies** (files matching `**/*.test.{ts,tsx}` / `**/*.spec.{ts,tsx}` and any e2e spec under `e2e/tests/`): `00_foundation` only (and only `src/types/index.ts` — typed wire-contract enums per `_docs/02_document/tests/environment.md` § Black-box discipline / `P9`). NEVER any other production component's internal files. The static profile enforces this via ripgrep. + - **Test infrastructure** (everything else under `tests/**` and `e2e/**` — `setup.ts`, MSW handlers, fixtures, helpers/wrappers, Playwright configs, runner Dockerfiles, stub services): MAY import production accessors from any layer when the accessor was created specifically for testability (e.g. `setToken` / `setNavigateToLogin` on `01_api-transport`'s `client.ts`, `AuthProvider` on `02_auth`, `i18n` on `00_foundation`). These helpers ARE the production-equivalent composition root for tests; black-box discipline applies to what test bodies observe, not to how the test environment is wired. Imports MUST still be public-API entry points (no reaching into internal files of other components). - **Consumed by**: (none — tests are not part of production runtime). - **Notes**: - Every test task spec under epic AZ-455 carries `**Component**: Blackbox Tests` and resolves its file ownership through this entry.