mirror of
https://github.com/azaion/ui.git
synced 2026-06-21 13:21:11 +00:00
23746ec61d
Closes architecture baseline finding F4. Every component now exposes its Public API through `src/<component>/index.ts`; cross-component imports go through the barrel. `scripts/check-arch-imports.mjs` plus `STC-ARCH-01` in the static profile enforce the rule; tests in `tests/architecture_imports.test.ts` cover AC-4/AC-5 + 2 exemption cases. One F3-pending exemption (`classColors`) is documented in 5 places (barrel, consumer, script, doc, test) to avoid a circular import. Phase B cycle 1 batch 1 of 2 (epic AZ-447). Batch 2 is AZ-486 (endpoint builders) — blocked on this commit landing. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import i18n from '../src/i18n'
|
|
|
|
// AZ-465 — i18n detector + persistence (fast counterparts).
|
|
//
|
|
// FT-P-24 (row 47) — i18n detector path used at first boot
|
|
// Profile: fast — `quarantined` per blackbox-tests.md
|
|
// until the navigator.language detector is added in
|
|
// Step 4. Today src/i18n/i18n.ts hardcodes `lng: 'en'`
|
|
// so the test would assert the detector branch ran when
|
|
// no detector exists.
|
|
// FT-P-25 (row 48) — i18n persistence across reload
|
|
// Profile: e2e — `quarantined` per spec until detector
|
|
// + persistence land. Fast counterpart asserts the
|
|
// i18n instance carries no persisted-language detector
|
|
// so persistence can't have shipped yet.
|
|
//
|
|
// Both tests write the QUARANTINE marker (Vitest's `.skip` reporter line +
|
|
// inline reason). When the detector + persistence feature lands, the marker
|
|
// flips: removing `.skip` reveals the assertion, which then drives the
|
|
// production feature green.
|
|
//
|
|
// Black-box discipline: import `i18n` (the `00_foundation` public API) only;
|
|
// no React-component internals.
|
|
|
|
describe('AZ-465 / src/i18n/i18n.ts — detector + persistence (quarantined)', () => {
|
|
describe('FT-P-24 (row 47) — detector path on first boot', () => {
|
|
it.skip('first boot reads navigator.language; no hardcoded `lng: "en"` (QUARANTINE: detector pending Step 4)', () => {
|
|
// Arrange — when the feature lands the test should:
|
|
// 1. Mount the SPA in jsdom with `Object.defineProperty(navigator, 'language', { value: 'uk' })`.
|
|
// 2. Reload the i18n instance.
|
|
// 3. Assert i18n.language === 'uk' or starts with 'uk'.
|
|
// 4. Assert that src/i18n/i18n.ts source no longer contains `lng: 'en'`
|
|
// (covered by a static check FT-P-24 partial).
|
|
//
|
|
// Today the production code initialises with `lng: 'en'` so the
|
|
// detector branch never fires. Skipping per spec.
|
|
expect(true).toBe(false)
|
|
})
|
|
|
|
it('control: today the i18n instance defaults to en (drives the QUARANTINE flip)', () => {
|
|
// Arrange + Assert
|
|
expect(i18n.language).toBe('en')
|
|
})
|
|
})
|
|
|
|
describe('FT-P-25 (row 48) — persistence across reload', () => {
|
|
it.skip('toggle to uk, reload, language persists (QUARANTINE: persistence pending Step 4)', () => {
|
|
// Arrange — when the feature lands the test should:
|
|
// 1. Switch language to uk via i18n.changeLanguage('uk').
|
|
// 2. Persist (i18next-browser-languagedetector with localStorage).
|
|
// 3. Re-create the i18n instance and assert .language === 'uk'.
|
|
//
|
|
// Today no language-detector or storage adapter is configured.
|
|
expect(true).toBe(false)
|
|
})
|
|
|
|
it('control: i18n config has no persistence adapter today', () => {
|
|
// Arrange + Assert — i18next options exposes the language detector
|
|
// chain via `services.languageDetector`. With no detector configured,
|
|
// services.languageDetector is undefined — confirming persistence
|
|
// hasn't shipped yet.
|
|
const detector = (i18n as unknown as { services: { languageDetector?: unknown } }).services.languageDetector
|
|
expect(detector).toBeUndefined()
|
|
})
|
|
})
|
|
})
|