# Test — Settings Save Resilience & 2 s Error Budget **Task**: AZ-477_test_settings_resilience **Name**: Settings save 500 + network drop — `saving` flag reset + error surfaces ≤ 2 s **Description**: Implement the 5 blackbox tests covering Settings save resilience: upstream 500, network drop, the 2-second error-surface deadline, and the try/finally state reset that prevents a stuck "saving…" indicator. **Complexity**: 3 points **Dependencies**: AZ-456_test_infrastructure **Component**: 09_settings (Blackbox Tests) **Tracker**: AZ-477 **Epic**: AZ-455 ## Problem Settings save has been observed to leave the `saving` flag set after an upstream failure (annotated in `src__features__settings__SettingsPage.md`). The user sees a forever-spinning button and the page becomes unusable. The contract: on ANY failure (HTTP error or network error), state resets within 2 s AND a user-visible error appears. ## Outcome - 5 scenarios pass. ## Scope ### Included | Scenario | Profile | Source file | |----------|---------|-------------| | FT-N-13 — Settings save with 500 response — `saving` flag reset; error surfaced | fast | blackbox-tests.md | | FT-N-14 — Settings save with network failure — try/finally state reset | fast | blackbox-tests.md | | NFT-PERF-09 — Settings save error surfaces within 2 s | fast | performance-tests.md | | NFT-RES-05 — Settings save with upstream 500 — UI state recovers | fast | resilience-tests.md | | NFT-RES-06 — Settings save with network drop — try/finally state reset | fast | resilience-tests.md | ### Excluded - Settings happy path (covered by per-feature tests in Phase B). - Settings RBAC redirect (covered in 12_test_protected_route_rbac). ## Acceptance Criteria **AC-1: 500 recovery** FT-N-13 / NFT-RES-05 — MSW returns 500 on settings PUT; assert: (a) `saving` flag is off (Save button no longer disabled / spinner not shown) within 2 s, (b) an error region is present in DOM. **AC-2: Network drop** FT-N-14 / NFT-RES-06 — MSW returns a network error; assert the same two conditions as AC-1. **AC-3: Deadline** NFT-PERF-09 — measure wall-clock from response receipt (or network failure) to DOM error visibility; assert ≤ 2 s. ## System Under Test Boundary - System under test: `` + its save handler + `src/api/client.ts`. - Allowed stubs: MSW for the settings PUT endpoint (returns 500 / network error per scenario). - Disallowed: reading React state — test asserts DOM affordances (disabled button, error region). - Expected observables per `results_report.md` rows 68-70 + the rows for NFT-RES-05/06.