Files
ui/_docs/02_tasks/todo/AZ-465_test_i18n.md
T
Oleksandr Bezdieniezhnykh 15a878d6f1 [AZ-455] Decompose Step 3 — test task specs (AZ-457..AZ-482)
Adds 26 blackbox-test task specs under epic AZ-455 plus the matching
rows in _dependencies_table.md. Each task depends on AZ-456 (test
infrastructure). Advances autodev existing-code flow Step 5 → Step 6
(Implement Tests, cycle 1) ready for batch implementation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 01:49:44 +03:00

2.9 KiB

Test — i18n Coverage & Persistence

Task: AZ-465_test_i18n Name: i18n key parity + t() coverage + detector + persistence Description: Implement the 4 blackbox tests that pin the i18n contract: en↔ua key parity (static), t() coverage (no raw user-visible strings), boot-time language detector, and persistence across reload. Complexity: 3 points Dependencies: AZ-456_test_infrastructure Component: 03_shared-ui + 10_app-shell (i18n) (Blackbox Tests) Tracker: AZ-465 Epic: AZ-455

Problem

A missing translation key or a hardcoded user-visible string only surfaces when a user switches language — by which point it's a customer-visible defect. Static checks + a behavioral test for detect/persist catch these at commit time.

Outcome

  • 4 scenarios pass per the contract.
  • The "no raw strings" check is enforceable in CI and produces a clear allow-list mechanism for legitimate non-i18n text (e.g. brand names).

Scope

Included

Scenario Profile Source file results_report row
FT-P-22 — i18n key parity en ↔ ua static blackbox-tests.md 45
FT-P-23 — no raw user-visible strings outside t(...) static blackbox-tests.md 46
FT-P-24 — i18n detector path used at first boot fast + e2e blackbox-tests.md 47
FT-P-25 — i18n persistence across reload fast + e2e blackbox-tests.md 48

Excluded

  • Adding a third language (project is en + ua per scope).
  • RTL support (not required by any AC).

Acceptance Criteria

AC-1: Key parity Static check: keys(en.json) == keys(ua.json) (set equality). Test FAILS on any drift.

AC-2: t() coverage Static check via ripgrep + AST walker: every JSX text node and string-literal aria-* / title / placeholder either lives in an i18n key, is in the allow-list (brand names, version strings), or fails the check.

AC-3: Detector path First boot with no persisted language preference: SPA reads navigator.language and renders the matching bundle.

AC-4: Persistence After user switches to UA and reloads, the UA bundle is rendered without explicit user action.

System Under Test Boundary

  • System under test: src/i18n/i18n.ts + every React component rendering user-visible text.
  • Allowed stubs: none beyond the standard test renderer.
  • Disallowed: reading the i18n state directly — the test asserts the rendered DOM text.
  • Expected observables per rows 45-48.

Constraints

  • Allow-list file lives at tests/i18n-allowlist.json; CI enforces it must not grow without a code-review reason.

Risks & Mitigation

Risk 1 — AST walker false positives

  • Risk: the t() coverage walker may misclassify dynamic strings (e.g. t(\key_${id}`)`) or ternaries.
  • Mitigation: explicit allow-list per file, plus a comment marker // i18n-ok: <reason> honored by the walker.