mirror of
https://github.com/azaion/ui.git
synced 2026-06-21 09:51:11 +00:00
[AZ-447] Close testability refactor run; advance to Step 5
- Archive Batch 2 task specs (AZ-448, AZ-449, AZ-453) to _docs/02_tasks/done/. - Write testability_changes_summary.md (refactor Phase 4.5; user-acked via autodev existing-code Step 4 gate). - Write FINAL_report.md closing the 01-testability-refactoring run. - Advance autodev state pointer to Step 5 (Decompose Tests). Refactor Phases 5/6/7 are no-ops for testability runs (no tests exist yet; doc updates are deferred to autodev Step 13). Verification axis for this run is the static-check matrix recorded in testability_changes_summary.md § Verification snapshot. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# 01-testability-refactoring — FINAL Report
|
||||
|
||||
## Run metadata
|
||||
|
||||
- **Mode**: guided (invoked by autodev existing-code Step 4)
|
||||
- **Input source**: `autodev-testability-analysis` → `list-of-changes.md`
|
||||
- **Epic**: [AZ-447](https://denyspopov.atlassian.net/browse/AZ-447)
|
||||
- **Tasks**: AZ-448 .. AZ-454 (7 tasks; all `In Testing` in Jira)
|
||||
- **Run folder**: `_docs/04_refactoring/01-testability-refactoring/`
|
||||
|
||||
## Phases executed
|
||||
|
||||
| Phase | Status | Notes |
|
||||
|-------|--------|-------|
|
||||
| 0 — Baseline | n/a (testability run; no test suite to baseline) | Skipped by design |
|
||||
| 1 — Discovery | done | `list-of-changes.md` (7 entries) + `deferred_to_refactor.md` (13 entries) |
|
||||
| 2 — Analysis | done | `analysis/research_findings.md`, `analysis/refactoring_roadmap.md`, 7 task specs written, epic + tasks created in Jira |
|
||||
| 3 — Safety Net | **skipped by design** | Testability runs have no pre-existing tests — compensating control was the user-approved Phase-1 `list-of-changes.md` gate |
|
||||
| 4 — Execution | done | 2 batches (Batch 1: AZ-450/451/452/454; Batch 2: AZ-448/449/453); commits `<batch-1-sha>` and `ed81034` |
|
||||
| 4.5 — Testability Changes Summary | done; acknowledged | `testability_changes_summary.md`; user acked via autodev Step 4 gate |
|
||||
| 5 — Test Sync | no-op | No tests exist yet; autodev hands off to Step 5 (Decompose Tests) for the initial test suite |
|
||||
| 6 — Verification | done (static-only) | tsc clean, grep checks green (see `testability_changes_summary.md` § Verification snapshot) |
|
||||
| 7 — Documentation | partial / deferred | `.env.example` documents the new env vars and `src/vite-env.d.ts` declares them. Module-doc updates (e.g. `_docs/02_document/modules/src__api__client.md`) are deferred to autodev Step 13 (Update Docs) on the first Phase B cycle to keep this testability run minimal-surgical. |
|
||||
|
||||
## Baseline vs final metrics
|
||||
|
||||
A behavioral baseline could not be captured (no test suite). The verification axis for this run is the static-check matrix on the testability surface:
|
||||
|
||||
| Check | Before | After |
|
||||
|-------|--------|-------|
|
||||
| Hardcoded OWM API key in `src/` | 1 literal in `flightPlanUtils.ts:60` | 0 |
|
||||
| Hardcoded `unpkg.com` URL in `src/` | 1 in `mapIcons.ts:18` | 0 |
|
||||
| Direct `window.location.href` writes in `src/api/client.ts` | 1 inline write | 1 (only inside default `navigateToLoginImpl`) |
|
||||
| Vite env vars declared | 0 | 5 (`VITE_API_BASE_URL`, `VITE_OWM_API_KEY`, `VITE_OWM_BASE_URL`, `VITE_OSM_TILE_URL`, `VITE_ESRI_TILE_URL`) |
|
||||
| `.env.example` documentation | absent | present |
|
||||
| `bun run tsc --noEmit` | clean | clean |
|
||||
|
||||
## Changes summary
|
||||
|
||||
See `testability_changes_summary.md`. 7 changes applied across 4 files:
|
||||
|
||||
- `src/features/flights/flightPlanUtils.ts` — C01 + C02 (OWM config extraction)
|
||||
- `src/features/flights/types.ts` — C03 (tile URL extraction)
|
||||
- `src/features/flights/mapIcons.ts` — C04 (bundled marker icon)
|
||||
- `src/api/client.ts` — C05 + C06 + C07 (`getApiBase`, `setNavigateToLogin`, JSDoc on `setToken/getToken`)
|
||||
- `src/api/sse.ts` — C05 (consumes `getApiBase`)
|
||||
- `src/vite-env.d.ts`, `.env.example` — new env var declarations / templates
|
||||
|
||||
## Remaining items
|
||||
|
||||
- All 13 deferred items live in `deferred_to_refactor.md` (D01–D13) — candidates for autodev Step 8 (Refactor) or Phase B feature cycles, not this run.
|
||||
- Module-doc updates listed under Phase 7 above (deferred to autodev Step 13).
|
||||
|
||||
## Lessons learned
|
||||
|
||||
- Scope discipline held: every rejected item that drifted into product / UX / parent-suite territory was caught at Phase 1 review and moved to `deferred_to_refactor.md` instead of silently expanding the run.
|
||||
- The accidental staging of `tsconfig.tsbuildinfo` (caught + fixed mid-Batch-1) was a reminder to keep build-cache files out of git — `.gitignore` was updated in the same batch.
|
||||
- Splitting C01/C02 (same file, conceptually one change) into two Jira tickets kept the audit trail per-restriction (O6 vs E2E-determinism) clean but cost a tiny extra commit; acceptable trade-off for tracker hygiene.
|
||||
@@ -0,0 +1,48 @@
|
||||
# Testability Changes Summary (01-testability-refactoring)
|
||||
|
||||
Applied 7 change(s):
|
||||
|
||||
## Config extraction (build-time env vars)
|
||||
|
||||
- **C01 (AZ-448)** — changed `getWeatherData` in `src/features/flights/flightPlanUtils.ts`: the OpenWeatherMap API key is now read from `import.meta.env.VITE_OWM_API_KEY` instead of being a hardcoded literal in source. Production builds inject the key through the build environment; tests can run with the key unset and `getWeatherData` returns `null` gracefully. Unblocks NFT-SEC-09 source-string check (results_report.md row 63). Risk: low.
|
||||
- **C02 (AZ-449)** — changed `getWeatherData` in `src/features/flights/flightPlanUtils.ts`: the OWM REST base URL is now read from `import.meta.env.VITE_OWM_BASE_URL` (default `https://api.openweathermap.org/data/2.5`, trailing slash stripped). The e2e profile sets it to `http://owm-stub:8081/data/2.5` so the stub can serve deterministic responses without source edits. Risk: low.
|
||||
- **C03 (AZ-450)** — changed `TILE_URLS` in `src/features/flights/types.ts`: the classic OSM and Esri satellite Leaflet tile templates are now read from `VITE_OSM_TILE_URL` and `VITE_ESRI_TILE_URL` (defaults preserve today's public endpoints, trailing slash stripped). Lets the e2e `tile-stub` service intercept tile fetches for deterministic map rendering. Risk: low.
|
||||
- **C05 (AZ-452)** — added `getApiBase()` accessor in `src/api/client.ts`; `request()`, `refreshToken()`, and `createSSE()` (`src/api/sse.ts`) now prepend the returned prefix to every API URL. Default is `''` (production: SPA + suite share nginx, paths are relative), `VITE_API_BASE_URL` overrides. Lets the fast-component-test harness point at a stub server without touching call sites. Risk: low.
|
||||
|
||||
## Bundling change (drop external CDN dependency)
|
||||
|
||||
- **C04 (AZ-451)** — changed `defaultIcon` in `src/features/flights/mapIcons.ts`: the Leaflet marker PNG is now imported from the `leaflet` package (`leaflet/dist/images/marker-icon.png`) and bundled into `dist/assets/` by Vite, replacing the hardcoded `https://unpkg.com/leaflet@1.7.1/...` CDN URL. Fixes the air-gap restriction (E1, NFT-RES-03), kills a version-mismatch bug (source pinned 1.7.1, `package.json` pins ^1.9.4), and removes one external dependency for e2e determinism. Risk: low.
|
||||
|
||||
## Singleton wrapping (overridable indirection)
|
||||
|
||||
- **C06 (AZ-453)** — added `navigateToLoginImpl` + `setNavigateToLogin` in `src/api/client.ts`: the failed-refresh redirect now flows through a module-level function whose default writes `'/login'` to `window.location.href`. Tests can install a spy via `setNavigateToLogin(fn)` to assert "redirect invoked" without globally stubbing `window.location`. Production behavior unchanged. Risk: low.
|
||||
|
||||
## Documentation (intent preservation)
|
||||
|
||||
- **C07 (AZ-454)** — added JSDoc on `setToken` and `getToken` in `src/api/client.ts`: documents the AC-02 / O2 design intent (in-memory bearer; survives reload only via the HttpOnly refresh cookie) and the test-override role of these accessors. Prevents a future maintainer from deleting them as "dead code" because their imports look dead at static-grep time. Comment-only — zero behavioral change. Risk: low.
|
||||
|
||||
---
|
||||
|
||||
## Verification snapshot
|
||||
|
||||
- `bun run tsc --noEmit` → 0 errors
|
||||
- `grep -rn '335799082893fad97fa36118b131f919' src/` → 0 hits (C01 AC-2)
|
||||
- `grep -rn 'unpkg.com' src/` → 0 hits (C04 acceptance)
|
||||
- `grep -rn 'api.openweathermap.org' src/` → 1 hit, inside the `DEFAULT_OWM_BASE_URL` constant only (C02 default-fallback contract)
|
||||
- `grep -rn 'window.location.href' src/` → 2 hits, both inside the default `navigateToLoginImpl` (JSDoc reference + the default impl body); no caller writes `window.location` directly (C06 AC-3)
|
||||
|
||||
## Out of scope (carried forward)
|
||||
|
||||
All 13 items rejected from this run are recorded in `deferred_to_refactor.md` (D01–D13). They are candidates for Step 8 (Refactor) or Phase B feature cycles, not for this testability pass.
|
||||
|
||||
## Tracker links
|
||||
|
||||
| Change | Task | Epic |
|
||||
|--------|------|------|
|
||||
| C01 | [AZ-448](https://denyspopov.atlassian.net/browse/AZ-448) | [AZ-447](https://denyspopov.atlassian.net/browse/AZ-447) |
|
||||
| C02 | [AZ-449](https://denyspopov.atlassian.net/browse/AZ-449) | AZ-447 |
|
||||
| C03 | [AZ-450](https://denyspopov.atlassian.net/browse/AZ-450) | AZ-447 |
|
||||
| C04 | [AZ-451](https://denyspopov.atlassian.net/browse/AZ-451) | AZ-447 |
|
||||
| C05 | [AZ-452](https://denyspopov.atlassian.net/browse/AZ-452) | AZ-447 |
|
||||
| C06 | [AZ-453](https://denyspopov.atlassian.net/browse/AZ-453) | AZ-447 |
|
||||
| C07 | [AZ-454](https://denyspopov.atlassian.net/browse/AZ-454) | AZ-447 |
|
||||
Reference in New Issue
Block a user