@umacloud/knowledge 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/00-governance/knowledge-map.md +1 -1
- package/agentic-delivery/01-standards/context-engineering-for-delivery.md +94 -0
- package/agentic-delivery/01-standards/eval-driven-delivery.md +90 -0
- package/agentic-delivery/01-standards/generated-code-failure-modes.md +91 -0
- package/agentic-delivery/01-standards/production-readiness-scorecard.md +79 -0
- package/agentic-delivery/01-standards/self-improving-memory-and-regression-sets.md +80 -0
- package/agentic-delivery/01-standards/spec-as-contract.md +88 -0
- package/agentic-delivery/01-standards/test-discipline-for-generated-code.md +94 -0
- package/agentic-delivery/01-standards/test-integrity-and-anti-gaming.md +92 -0
- package/agentic-delivery/01-standards/verifier-critic-pattern.md +89 -0
- package/ai/agent-evaluation-benchmark.md +1 -1
- package/ai/ai-agent-memory-context-management.md +1 -1
- package/ai/ai-cost-capacity-optimization-playbook.md +1 -1
- package/ai/ai-data-security-and-compliance-playbook.md +1 -1
- package/ai/ai-domain-index-and-checklist.md +1 -1
- package/ai/ai-governance-maturity-model.md +1 -1
- package/ai/ai-model-selection-and-routing-strategy.md +1 -1
- package/ai/ai-observability-and-oncall-runbook.md +1 -1
- package/ai/ai-rag-engineering-playbook.md +1 -1
- package/ai/ai-red-team-and-safety-evaluation.md +1 -1
- package/ai/ai-release-readiness-and-rollback-gate.md +1 -1
- package/ai/llm-agent-engineering-deep-dive.md +1 -1
- package/ai/prompt-and-tool-guardrails.md +1 -1
- package/api/01-standards/api-versioning-and-deprecation-policy.md +100 -0
- package/architecture/01-standards/configuration-and-environment-management.md +104 -0
- package/architecture/01-standards/domain-driven-design-complete.md +105 -0
- package/architecture/02-playbooks/migration-playbook.md +1 -1
- package/architecture/02-playbooks/system-design-playbook.md +1 -1
- package/architecture/adr-template-and-examples.md +1 -1
- package/architecture/configuration-management.md +95 -1158
- package/architecture/resilience-and-disaster-patterns.md +87 -27
- package/architecture/system-architecture-deep-dive.md +1 -1
- package/backend/01-standards/dependency-and-supply-chain-hygiene.md +90 -0
- package/backend/01-standards/error-handling-taxonomy.md +88 -0
- package/backend/01-standards/idempotency-and-safe-retries.md +101 -0
- package/backend/01-standards/message-queue-patterns.md +96 -374
- package/backend/01-standards/queue-and-consumer-reliability.md +98 -0
- package/backend/01-standards/resilience-and-fault-tolerance.md +101 -0
- package/backend/01-standards/transactions-and-concurrency-control.md +92 -0
- package/cicd/cicd-blueprint-deep-dive.md +1 -1
- package/cicd/release-readiness-gate.md +78 -27
- package/cloud-native/01-standards/container-security.md +1 -1
- package/cloud-native/01-standards/kubernetes-complete.md +1 -1
- package/cloud-native/02-playbooks/gitops-with-argocd.md +1 -1
- package/cloud-native/02-playbooks/k8s-troubleshooting-playbook.md +1 -1
- package/cloud-native/02-playbooks/multicloud-governance.md +1 -1
- package/cloud-native/02-playbooks/serverless-patterns.md +1 -1
- package/cloud-native/02-playbooks/service-mesh-playbook.md +1 -1
- package/cloud-native/03-checklists/container-security-checklist.md +1 -1
- package/cloud-native/03-checklists/k8s-production-readiness-checklist.md +1 -1
- package/cloud-native/04-antipatterns/container-antipatterns.md +1 -1
- package/cloud-native/04-antipatterns/k8s-antipatterns.md +1 -1
- package/cloud-native/05-cases/case-k8s-migration.md +1 -1
- package/cloud-native/05-cases/case-k8s-scaling.md +1 -1
- package/cloud-native/05-cases/case-k8s-security-incident.md +1 -1
- package/cloud-native/06-glossary/cloud-native-glossary.md +1 -1
- package/compliance/01-standards/audit-logging-and-evidence.md +111 -0
- package/compliance/01-standards/privacy-and-compliance-readiness.md +119 -0
- package/data/data-governance-and-modeling-deep-dive.md +1 -1
- package/design/ux-system-deep-dive.md +1 -1
- package/development/00-governance/document-template.md +1 -1
- package/development/01-standards/code-review-and-pr-hygiene.md +85 -0
- package/development/03-checklists/production-readiness-checklist.md +6 -6
- package/development/09-maturity/quarterly-audit-template.md +1 -1
- package/development/11-ui-excellence/ui-aesthetic-system.md +1 -1
- package/development/13-implementation-assets/knowledge-gates-execution.md +1 -1
- package/development/api-contract-and-versioning-guide.md +1 -1
- package/development/api-governance-complete.md +1 -1
- package/development/backend-engineering-complete.md +1 -1
- package/development/code-review-quality-complete.md +11 -34
- package/development/concurrency-reliability-complete.md +1 -1
- package/development/database-engineering-complete.md +1 -1
- package/development/engineering-effectiveness-complete.md +1 -1
- package/development/engineering-standards-deep-dive.md +1 -1
- package/development/frontend-engineering-complete.md +1 -1
- package/development/performance-capacity-complete.md +1 -1
- package/development/refactor-migration-complete.md +1 -1
- package/development/refactoring-and-techdebt-playbook.md +1 -1
- package/development/security-in-development-complete.md +1 -1
- package/experts/architect/contract-first-api-design.md +140 -0
- package/experts/product-manager/prd-template-and-structure.md +144 -0
- package/experts/product-manager/requirements-engineering-ears.md +133 -0
- package/experts/qa-lead/test-plan-template.md +127 -0
- package/frontend/01-standards/accessibility-acceptance-gate.md +91 -0
- package/frontend/01-standards/accessibility-complete.md +3 -3
- package/frontend/01-standards/ui-states-and-resilient-data-fetching.md +97 -0
- package/high-quality-engineering-playbook.md +1 -1
- package/incident/02-playbooks/chaos-engineering-playbook.md +1 -1
- package/incident/postmortem-and-response-deep-dive.md +1 -1
- package/mobile/01-standards/flutter-complete.md +5 -5
- package/mobile/01-standards/react-native-complete.md +5 -5
- package/mobile/02-playbooks/mobile-performance.md +6 -6
- package/mobile/03-checklists/mobile-release-checklist.md +2 -2
- package/mobile/04-antipatterns/mobile-antipatterns.md +2 -2
- package/observability/01-standards/observability-and-slo-operations.md +88 -0
- package/observability/01-standards/observability-standards.md +2 -0
- package/operations/01-standards/cost-and-finops-engineering.md +84 -0
- package/operations/01-standards/production-readiness-review.md +103 -0
- package/operations/aiops-anomaly-detection.md +1 -1
- package/operations/capacity-planning.md +1 -1
- package/operations/chaos-engineering.md +1 -1
- package/operations/incident-command-system.md +1 -1
- package/operations/observability-complete.md +1 -1
- package/operations/slo-sli-playbook.md +1 -1
- package/operations/sre-operations-deep-dive.md +1 -1
- package/package.json +1 -1
- package/performance/01-standards/performance-budgets-and-load-testing.md +91 -0
- package/product/feature-prioritization-framework.md +1 -1
- package/product/kpi-and-metric-tree.md +1 -1
- package/product/product-discovery-and-prd-deep-dive.md +1 -1
- package/release-engineering/01-standards/feature-flag-lifecycle.md +92 -0
- package/release-engineering/01-standards/progressive-delivery-and-release.md +92 -0
- package/release-engineering/02-playbooks/release-rollback-and-recovery-playbook.md +99 -0
- package/release-engineering/03-checklists/release-rollback-readiness-checklist.md +61 -0
- package/release-engineering/04-antipatterns/release-antipatterns.md +63 -0
- package/security/01-standards/authorization-and-access-control.md +94 -0
- package/security/02-playbooks/incident-response-security-playbook.md +1 -1
- package/security/02-playbooks/penetration-testing-playbook.md +1 -1
- package/security/security-architecture-deep-dive.md +1 -1
- package/security/threat-modeling-stride-playbook.md +1 -1
- package/testing/01-standards/ci-test-gates-and-coverage.md +93 -0
- package/testing/01-standards/contract-testing-and-api-contracts.md +102 -0
- package/testing/01-standards/test-data-and-ephemeral-environments.md +105 -0
- package/testing/02-playbooks/e2e-testing-playbook.md +1 -1
- package/testing/risk-based-test-matrix.md +1 -1
- package/testing/testing-strategy-deep-dive.md +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: prd-template-and-structure
|
|
3
|
+
title: Product Manager — PRD Template & Structure (EARS-anchored)
|
|
4
|
+
domain: experts
|
|
5
|
+
category: product-manager
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [prd, product-requirements, template, ears, acceptance-criteria, scope, traceability, definition-of-done, writing]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# Product Manager — PRD Template & Structure (EARS-anchored)
|
|
12
|
+
|
|
13
|
+
> A PRD is not a pitch deck and not a wish list. It is the **contract between
|
|
14
|
+
> intent and implementation**: a document an engineer can build from, a QA can
|
|
15
|
+
> test against, and a stakeholder can sign off on — without a meeting to decode
|
|
16
|
+
> it. A commercial-grade PRD anchors every requirement in the structured
|
|
17
|
+
> acceptance syntax (see `experts/product-manager/requirements-engineering-ears`)
|
|
18
|
+
> so that *what we are building* and *how we will know it works* are the same
|
|
19
|
+
> artifact, not two documents that drift apart.
|
|
20
|
+
|
|
21
|
+
## 1. What a PRD must do
|
|
22
|
+
|
|
23
|
+
A PRD earns its place only if it answers five questions unambiguously:
|
|
24
|
+
|
|
25
|
+
- **Why** — the problem, who has it, and why now (the case for building at all).
|
|
26
|
+
- **What** — the requirements, each atomic, triggered, and testable.
|
|
27
|
+
- **What not** — explicit out-of-scope, so scope creep is visible.
|
|
28
|
+
- **How we'll know** — acceptance criteria and success metrics with numbers.
|
|
29
|
+
- **What it touches** — data, contracts, dependencies, and risks.
|
|
30
|
+
|
|
31
|
+
A PRD that reads beautifully but cannot be turned into test cases has failed,
|
|
32
|
+
no matter how polished the prose.
|
|
33
|
+
|
|
34
|
+
## 2. The PRD skeleton
|
|
35
|
+
|
|
36
|
+
Fill every section. "N/A" is an acceptable answer; a blank is not — a blank
|
|
37
|
+
means the question was never asked.
|
|
38
|
+
|
|
39
|
+
| # | Section | Content |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| 1 | **Summary** | One paragraph: what this is, for whom, and the outcome. Readable by someone outside the team. |
|
|
42
|
+
| 2 | **Problem & context** | The user problem, evidence it's real (data/research, not opinion), and why now. |
|
|
43
|
+
| 3 | **Goals & non-goals** | Goals as measurable outcomes; non-goals as explicit exclusions. |
|
|
44
|
+
| 4 | **Success metrics** | The numbers that define success + how each is measured (see §5). |
|
|
45
|
+
| 5 | **Users & scenarios** | Target users/personas and the key scenarios (jobs to be done). |
|
|
46
|
+
| 6 | **Requirements** | The core: structured functional requirements + acceptance criteria (see §3). |
|
|
47
|
+
| 7 | **Non-functional requirements** | Performance, availability, security, accessibility, privacy — each with a number and a method. |
|
|
48
|
+
| 8 | **Scope** | In-scope this release vs out-of-scope / later, stated explicitly. |
|
|
49
|
+
| 9 | **Dependencies & risks** | Upstream/downstream systems, data, teams; risks with mitigation. |
|
|
50
|
+
| 10 | **Data & contract impact** | New/changed data, API/contract changes, migration and privacy implications. |
|
|
51
|
+
| 11 | **Rollout & success gate** | How it ships (flagged/phased), what metric gates each stage, how it rolls back. |
|
|
52
|
+
| 12 | **Open questions** | Unresolved decisions with an owner and a needed-by date. |
|
|
53
|
+
| 13 | **Traceability** | The matrix tying requirement → criteria → design/API → tests (see §6). |
|
|
54
|
+
|
|
55
|
+
## 3. The heart: requirements + acceptance criteria
|
|
56
|
+
|
|
57
|
+
Every functional requirement is written in one of the five structured patterns
|
|
58
|
+
(ubiquitous / event-driven / state-driven / unwanted-behavior / optional-feature)
|
|
59
|
+
and immediately followed by its acceptance criteria in Given–When–Then form.
|
|
60
|
+
The requirement says *what must hold*; the criteria enumerate *the cases that
|
|
61
|
+
prove it*. Use this block, repeated per requirement:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
### FR-012 Checkout creates exactly one order
|
|
65
|
+
|
|
66
|
+
Requirement (event-driven):
|
|
67
|
+
When a signed-in user submits the checkout form with a valid card,
|
|
68
|
+
the system shall create one order, charge the card exactly once,
|
|
69
|
+
and return HTTP 201 with the order id.
|
|
70
|
+
|
|
71
|
+
Acceptance criteria:
|
|
72
|
+
- Given a valid cart and card, when checkout is submitted,
|
|
73
|
+
then an order is created and HTTP 201 with orderId is returned.
|
|
74
|
+
- Given the same idempotency key is replayed, when checkout is submitted twice,
|
|
75
|
+
then exactly one order and one charge exist.
|
|
76
|
+
- Given the card is declined, when checkout is submitted,
|
|
77
|
+
then no order is created and the decline reason is shown (HTTP 402).
|
|
78
|
+
- Given the network drops after charge but before response, when the client retries,
|
|
79
|
+
then no second charge occurs.
|
|
80
|
+
|
|
81
|
+
Out of scope: saved-card management; partial refunds.
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Mandatory case coverage per requirement — enumerate criteria across:
|
|
85
|
+
**happy path · boundary values · error/unwanted · permission · concurrency ·
|
|
86
|
+
state (empty/loading/partial/stale) · idempotency**. A requirement with only a
|
|
87
|
+
happy path is not ready.
|
|
88
|
+
|
|
89
|
+
## 4. Goals and non-goals (kill scope creep early)
|
|
90
|
+
|
|
91
|
+
| Goal (measurable outcome) | Non-goal (explicit exclusion) |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Reduce checkout abandonment by 15% in 90 days | Redesigning the cart UI |
|
|
94
|
+
| Support guest checkout end to end | Loyalty/points integration (next release) |
|
|
95
|
+
|
|
96
|
+
Rules: goals are **outcomes** (a metric moves), not outputs ("build a button");
|
|
97
|
+
every non-goal prevents a future "but I assumed…" argument.
|
|
98
|
+
|
|
99
|
+
## 5. Success metrics (numbers, not adjectives)
|
|
100
|
+
|
|
101
|
+
| Metric | Target | How measured | Guardrail |
|
|
102
|
+
|---|---|---|---|
|
|
103
|
+
| Checkout completion rate | +15% vs baseline | Funnel analytics, 90-day window | No drop in payment success rate |
|
|
104
|
+
| Checkout p95 latency | < 800ms | Server metrics | — |
|
|
105
|
+
|
|
106
|
+
Every product metric needs a **guardrail metric** — a thing that must *not*
|
|
107
|
+
get worse while you optimize the target (e.g., don't raise conversion by
|
|
108
|
+
hiding fees). State the baseline; "improve" without a baseline is unfalsifiable.
|
|
109
|
+
|
|
110
|
+
## 6. Traceability matrix
|
|
111
|
+
|
|
112
|
+
The PRD ships (or generates) a matrix so coverage gaps are visible at a glance:
|
|
113
|
+
|
|
114
|
+
| Req ID | Requirement (structured) | Acceptance criteria | Design/API | Tests | Status |
|
|
115
|
+
|---|---|---|---|---|---|
|
|
116
|
+
| FR-012 | When … shall create one order … | AC-012a..d | `POST /orders` | T-101..104 | Ready |
|
|
117
|
+
|
|
118
|
+
Rules: every requirement has ≥1 criterion and ≥1 planned test; every screen and
|
|
119
|
+
endpoint traces back to a requirement (no orphan features); a requirement with
|
|
120
|
+
no test is not shippable, a test with no requirement is scope creep — resolve, don't ignore.
|
|
121
|
+
|
|
122
|
+
## 7. Definition of Ready (the PRD may enter build only if)
|
|
123
|
+
|
|
124
|
+
- [ ] Problem stated with evidence; goals are measurable outcomes; non-goals explicit.
|
|
125
|
+
- [ ] Every functional requirement in a structured pattern (atomic, triggered, observable).
|
|
126
|
+
- [ ] Acceptance criteria enumerated across happy/boundary/error/permission/concurrency/state/idempotency.
|
|
127
|
+
- [ ] NFRs carry numbers and a measurement method (no "fast", "secure", "intuitive").
|
|
128
|
+
- [ ] Scope: in-scope vs out-of-scope stated; dependencies and risks identified.
|
|
129
|
+
- [ ] Data/contract/migration/privacy impact described.
|
|
130
|
+
- [ ] Rollout + rollback + success-gate metrics defined.
|
|
131
|
+
- [ ] Open questions each have an owner and a needed-by date.
|
|
132
|
+
- [ ] Traceability matrix present; no orphan features, no untested requirements.
|
|
133
|
+
|
|
134
|
+
## 8. Anti-patterns (reject in review)
|
|
135
|
+
|
|
136
|
+
1. **Solution-as-requirement** — "use a modal / use React" in a requirement; that's design, decided later.
|
|
137
|
+
2. **Adjective acceptance** — "should be fast/intuitive" with no observable, measurable outcome.
|
|
138
|
+
3. **Happy-path-only** — no error, boundary, permission, or concurrency criteria.
|
|
139
|
+
4. **No non-goals** — everything is implicitly in scope, so scope creep is invisible.
|
|
140
|
+
5. **Output goals** — "ship a settings page" instead of the outcome it should produce.
|
|
141
|
+
6. **Vanity metric, no guardrail** — optimize one number while quietly degrading another.
|
|
142
|
+
7. **Orphan feature** — a screen/endpoint with no requirement behind it.
|
|
143
|
+
8. **Drift** — acceptance criteria live in a separate doc and fall out of sync with the requirement.
|
|
144
|
+
9. **Blank ≠ N/A** — sections silently skipped, so unasked questions surface mid-build.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: requirements-engineering-ears
|
|
3
|
+
title: Product Manager — Structured Acceptance Syntax (EARS Patterns)
|
|
4
|
+
domain: experts
|
|
5
|
+
category: product-manager
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [acceptance, criteria, ears, product, requirements, specification, traceability, writing]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# Product Manager — Structured Acceptance Syntax (EARS Patterns)
|
|
12
|
+
|
|
13
|
+
> Free-text requirements ("the system should be fast and user-friendly") cannot
|
|
14
|
+
> be tested, estimated, or signed off. A commercial-grade PRD writes every
|
|
15
|
+
> requirement in a **constrained sentence syntax** so it is unambiguous,
|
|
16
|
+
> singular, and verifiable. This is the bridge between a product idea and a
|
|
17
|
+
> test case.
|
|
18
|
+
|
|
19
|
+
## 1. Why a constrained syntax
|
|
20
|
+
|
|
21
|
+
Natural-language requirements fail in four predictable ways: they are
|
|
22
|
+
**ambiguous** (multiple readings), **compound** (several requirements in one
|
|
23
|
+
sentence), **untestable** (no observable outcome), or **silent on triggers and
|
|
24
|
+
preconditions** (when does this apply?). A structured syntax removes all four by
|
|
25
|
+
forcing every requirement into one of five fixed shapes, each with an explicit
|
|
26
|
+
trigger, an explicit subject (the system), and an explicit, observable response.
|
|
27
|
+
|
|
28
|
+
A requirement is well-formed only if it is:
|
|
29
|
+
- **Atomic** — exactly one testable behavior (no "and"/"also" hiding a second requirement).
|
|
30
|
+
- **Triggered** — states the precondition or event under which it applies.
|
|
31
|
+
- **Observable** — the response is something a test can assert (status code, value, state, screen).
|
|
32
|
+
- **Unconditionally testable** — no vague adjectives ("fast", "intuitive", "robust").
|
|
33
|
+
|
|
34
|
+
## 2. The five sentence patterns
|
|
35
|
+
|
|
36
|
+
Use exactly one keyword per pattern. The subject is always the system (or a named component).
|
|
37
|
+
|
|
38
|
+
| Pattern | Shape | Use when |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| **Ubiquitous** | `The <system> shall <response>.` | An always-true invariant, no trigger. |
|
|
41
|
+
| **Event-driven** | `When <trigger>, the <system> shall <response>.` | A discrete event causes a response. |
|
|
42
|
+
| **State-driven** | `While <state>, the <system> shall <response>.` | A behavior holds for the duration of a state. |
|
|
43
|
+
| **Unwanted-behavior** | `If <unwanted condition>, then the <system> shall <response>.` | Error, abuse, or failure handling. |
|
|
44
|
+
| **Optional-feature** | `Where <feature is present>, the <system> shall <response>.` | Behavior only when a feature/config is enabled. |
|
|
45
|
+
| **Complex** | Combine keywords: `While <state>, when <trigger>, the <system> shall <response>.` | A trigger that only applies in a state. |
|
|
46
|
+
|
|
47
|
+
### Examples (vague → structured)
|
|
48
|
+
|
|
49
|
+
| Vague | Structured |
|
|
50
|
+
|---|---|
|
|
51
|
+
| "Login should be secure." | **If** 5 failed login attempts occur from one account within 10 minutes, **then** the system **shall** lock the account for 15 minutes and return HTTP 429. |
|
|
52
|
+
| "The dashboard should load fast." | **When** a signed-in user requests `/dashboard`, the system **shall** return First Contentful Paint under 1.5s on a 4G connection at the 75th percentile. |
|
|
53
|
+
| "Handle payment failures gracefully." | **If** the payment provider returns a decline, **then** the system **shall** preserve the cart, display the provider's decline reason, and **shall not** charge the card. |
|
|
54
|
+
| "Show notifications." | **Where** browser push is enabled, **when** an order ships, the system **shall** deliver a push notification within 60 seconds. |
|
|
55
|
+
| "Search should work." | **When** a user submits a query of 1–256 characters, the system **shall** return matching results ranked by relevance within 300ms p95. |
|
|
56
|
+
|
|
57
|
+
## 3. From requirement to acceptance criteria
|
|
58
|
+
|
|
59
|
+
Each structured requirement expands into concrete acceptance criteria in
|
|
60
|
+
**Given–When–Then** form — the executable companion of the requirement. The
|
|
61
|
+
requirement says *what must hold*; the criteria enumerate the *cases that prove it*.
|
|
62
|
+
|
|
63
|
+
**Requirement (event-driven):**
|
|
64
|
+
> When a user submits the checkout form with a valid card, the system shall create the order, charge the card exactly once, and return HTTP 201 with the order id.
|
|
65
|
+
|
|
66
|
+
**Acceptance criteria:**
|
|
67
|
+
- Given a valid cart and card, when checkout is submitted, then an order is created and HTTP 201 with `orderId` is returned.
|
|
68
|
+
- Given the same idempotency key is replayed, when checkout is submitted twice, then exactly one order and one charge exist.
|
|
69
|
+
- Given the card is declined, when checkout is submitted, then no order is created and the decline reason is shown (HTTP 402).
|
|
70
|
+
- Given the network drops after charge but before response, when the client retries, then no second charge occurs.
|
|
71
|
+
|
|
72
|
+
Every criterion must be **independently verifiable** and map to at least one
|
|
73
|
+
automated test. A requirement with zero acceptance criteria is not done; it is a wish.
|
|
74
|
+
|
|
75
|
+
## 4. Mandatory case coverage per requirement
|
|
76
|
+
|
|
77
|
+
For every requirement, the PRD must enumerate criteria across these axes (the
|
|
78
|
+
same edge-case discipline applied to specification, not just QA):
|
|
79
|
+
|
|
80
|
+
- **Happy path** — the normal success case.
|
|
81
|
+
- **Boundary values** — 0, 1, max, max+1, empty, negative, oversize.
|
|
82
|
+
- **Error / unwanted** — invalid input, missing fields, downstream failure, timeout.
|
|
83
|
+
- **Permission** — unauthenticated, authenticated-but-forbidden, owner vs non-owner.
|
|
84
|
+
- **Concurrency** — duplicate submit, race, stale read, double-click.
|
|
85
|
+
- **State** — empty (no data yet), loading, partial, deleted/stale.
|
|
86
|
+
- **Idempotency** — safe to retry; replays produce one effect.
|
|
87
|
+
|
|
88
|
+
## 5. Non-functional requirements are requirements too
|
|
89
|
+
|
|
90
|
+
NFRs use the same syntax and must carry a number and a measurement method —
|
|
91
|
+
never an adjective.
|
|
92
|
+
|
|
93
|
+
| Category | Structured NFR | How to verify |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| Performance | When a list endpoint is called, the system shall respond within 200ms p95. | Load test + server metrics |
|
|
96
|
+
| Availability | The system shall sustain 99.9% monthly uptime. | Uptime monitor + error budget |
|
|
97
|
+
| Capacity | While under 1000 concurrent users, the system shall keep error rate below 0.1%. | Load test |
|
|
98
|
+
| Security | The system shall reject any request without a valid token with HTTP 401. | Automated auth test |
|
|
99
|
+
| Accessibility | The system shall meet AA contrast and full keyboard operability on all interactive elements. | Automated a11y scan + manual keyboard pass |
|
|
100
|
+
| Privacy | The system shall encrypt personal data at rest and in transit. | Config audit + scan |
|
|
101
|
+
|
|
102
|
+
## 6. Traceability matrix
|
|
103
|
+
|
|
104
|
+
Every requirement is traceable end to end. A commercial PRD ships (or generates)
|
|
105
|
+
a matrix so coverage gaps are visible:
|
|
106
|
+
|
|
107
|
+
| Req ID | Requirement (structured) | Acceptance criteria | Design/API | Test cases | Status |
|
|
108
|
+
|---|---|---|---|---|---|
|
|
109
|
+
| FR-012 | When … shall create the order … | AC-012a..d | `POST /orders` | T-101..104 | Done |
|
|
110
|
+
|
|
111
|
+
Rules:
|
|
112
|
+
- Every requirement ID has ≥1 acceptance criterion and ≥1 test case.
|
|
113
|
+
- Every API endpoint and screen traces back to a requirement (no orphan features).
|
|
114
|
+
- A requirement with no test is **not** shippable; a test with no requirement is **scope creep** — resolve, don't ignore.
|
|
115
|
+
|
|
116
|
+
## 7. Definition of Ready (a requirement may enter a sprint only if)
|
|
117
|
+
|
|
118
|
+
- [ ] Written in one of the five structured patterns (atomic, triggered, observable).
|
|
119
|
+
- [ ] Acceptance criteria enumerated across happy / boundary / error / permission / concurrency.
|
|
120
|
+
- [ ] Non-functional targets stated with numbers and a measurement method.
|
|
121
|
+
- [ ] Out-of-scope explicitly listed (what this requirement does **not** cover).
|
|
122
|
+
- [ ] Dependencies and data/contract impacts identified.
|
|
123
|
+
- [ ] No vague adjectives remain ("fast", "easy", "nice", "secure", "robust").
|
|
124
|
+
|
|
125
|
+
## 8. Anti-patterns (reject in review)
|
|
126
|
+
|
|
127
|
+
1. **Compound requirement** — one sentence hiding two behaviors joined by "and".
|
|
128
|
+
2. **Solutioning** — "use a dropdown" / "use React" in a requirement (that's design, not requirement).
|
|
129
|
+
3. **Adjective acceptance** — "should be intuitive" with no observable outcome.
|
|
130
|
+
4. **Happy-path only** — no error, boundary, or permission criteria.
|
|
131
|
+
5. **Untriggered** — no precondition, so the reader can't tell when it applies.
|
|
132
|
+
6. **Unmeasurable NFR** — "should be fast" with no number, percentile, or method.
|
|
133
|
+
7. **Orphan feature** — a screen or endpoint with no requirement behind it.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: test-plan-template
|
|
3
|
+
title: QA Lead — Risk-Based Test Plan Template
|
|
4
|
+
domain: experts
|
|
5
|
+
category: qa-lead
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [acceptance, criteria, defect, experts, qa, risk, test-plan, traceability]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# QA Lead — Risk-Based Test Plan Template
|
|
12
|
+
|
|
13
|
+
> A test plan is not "we will test everything." It is a **risk-prioritized,
|
|
14
|
+
> traceable contract** stating what will be tested, to what depth, in which
|
|
15
|
+
> environment, and the explicit criteria for declaring a release ready. Effort
|
|
16
|
+
> follows risk: the highest-risk flows get the deepest coverage.
|
|
17
|
+
|
|
18
|
+
## 1. Scope
|
|
19
|
+
|
|
20
|
+
State precisely, in two lists:
|
|
21
|
+
- **In scope** — features, flows, endpoints, platforms, and quality attributes (functional, performance, security, accessibility, compatibility) this plan covers.
|
|
22
|
+
- **Out of scope** — what this plan deliberately does **not** cover, and why (covered elsewhere, accepted risk, future iteration). An unstated exclusion is a coverage gap waiting to surprise you.
|
|
23
|
+
|
|
24
|
+
## 2. Risk-based prioritization
|
|
25
|
+
|
|
26
|
+
Rank every feature/flow by **risk = likelihood of failure × impact of failure**.
|
|
27
|
+
Allocate test depth by risk tier, not uniformly.
|
|
28
|
+
|
|
29
|
+
| Risk tier | Examples | Depth |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| Critical | Auth, payments, data integrity, anything irreversible or money-moving | Exhaustive: happy + all boundaries + all error/abuse paths + concurrency + E2E |
|
|
32
|
+
| High | Core user journeys, permission boundaries, data export/import | Happy + key boundaries + main error paths + E2E smoke |
|
|
33
|
+
| Medium | Secondary features, admin tools | Happy + obvious errors |
|
|
34
|
+
| Low | Cosmetic, rarely used, low blast radius | Smoke / spot check |
|
|
35
|
+
|
|
36
|
+
Impact axes to weigh: money loss, data loss/corruption, security/privacy breach,
|
|
37
|
+
legal/compliance, number of users affected, reversibility, brand/trust.
|
|
38
|
+
|
|
39
|
+
## 3. Test approach per layer
|
|
40
|
+
|
|
41
|
+
Map each area to the right test layer (test each layer at the right altitude — see `testing/01-standards/test-strategy-and-layering`):
|
|
42
|
+
|
|
43
|
+
| Layer | What is verified here | Type |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Domain logic | Business rules, invariants, state machines, calculations | Unit (no IO) |
|
|
46
|
+
| Application/service | Use-case orchestration, transactions, error paths (deps mocked) | Unit / integration |
|
|
47
|
+
| Persistence | Real reads/writes, mapping, query correctness | Integration (real DB) |
|
|
48
|
+
| API/interface | Routing, validation, status codes, error envelope, authz | Integration / contract |
|
|
49
|
+
| Cross-cutting | Performance, security, accessibility, compatibility | Specialized suites |
|
|
50
|
+
| Critical journeys | Signup → core action → checkout, with key failures | E2E |
|
|
51
|
+
|
|
52
|
+
## 4. Entry and exit criteria
|
|
53
|
+
|
|
54
|
+
Make "ready to test" and "ready to ship" objective, not a feeling.
|
|
55
|
+
|
|
56
|
+
**Entry criteria (testing may begin when):**
|
|
57
|
+
- [ ] Requirements have structured, testable acceptance criteria.
|
|
58
|
+
- [ ] Build deploys to a test environment and boots cleanly.
|
|
59
|
+
- [ ] Test data and accounts are available; dependencies/stubs are up.
|
|
60
|
+
- [ ] Smoke test of the critical path passes (no point deep-testing a dead build).
|
|
61
|
+
|
|
62
|
+
**Exit criteria (release is ready when):**
|
|
63
|
+
- [ ] 100% of critical and high acceptance criteria pass.
|
|
64
|
+
- [ ] No open critical/blocker defects; high defects triaged with a decision.
|
|
65
|
+
- [ ] Coverage thresholds met (variance and diff coverage — see `testing/01-standards/ci-test-gates-and-coverage`).
|
|
66
|
+
- [ ] Performance, security, and accessibility checks pass their budgets.
|
|
67
|
+
- [ ] No unexplained flaky tests in the required suite.
|
|
68
|
+
- [ ] Rollback procedure documented and verified.
|
|
69
|
+
|
|
70
|
+
## 5. Traceability matrix
|
|
71
|
+
|
|
72
|
+
Prove coverage end to end — every requirement maps to acceptance criteria to test cases, with no orphans either way.
|
|
73
|
+
|
|
74
|
+
| Req ID | Acceptance criteria | Test case IDs | Layer | Risk | Status |
|
|
75
|
+
|---|---|---|---|---|---|
|
|
76
|
+
| FR-012 | AC-012a..d | T-101..104 | API + E2E | Critical | Pass |
|
|
77
|
+
|
|
78
|
+
Rules:
|
|
79
|
+
- Every acceptance criterion has ≥1 test case (no untested requirement).
|
|
80
|
+
- Every test case traces to a requirement (no test for a feature nobody asked for).
|
|
81
|
+
- Coverage gaps (a requirement with no test) are visible and block exit.
|
|
82
|
+
|
|
83
|
+
## 6. From acceptance criteria to test cases
|
|
84
|
+
|
|
85
|
+
Each criterion expands into multiple cases across the standard axes — happy,
|
|
86
|
+
boundary, error, permission, concurrency, state. Example for a login criterion:
|
|
87
|
+
|
|
88
|
+
1. Valid credentials → success + redirect.
|
|
89
|
+
2. Wrong password → generic error (no user enumeration).
|
|
90
|
+
3. Non-existent user → same generic error.
|
|
91
|
+
4. Empty/invalid-format fields → field validation.
|
|
92
|
+
5. N failed attempts → lockout + 429.
|
|
93
|
+
6. Injection / script in fields → sanitized, no execution.
|
|
94
|
+
7. Concurrent duplicate submit → one session, no double effect.
|
|
95
|
+
8. Redirect back to originally requested page after login.
|
|
96
|
+
|
|
97
|
+
## 7. Defect severity and triage
|
|
98
|
+
|
|
99
|
+
Classify every defect; severity drives whether it blocks release.
|
|
100
|
+
|
|
101
|
+
| Severity | Definition | Release impact |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| Blocker | Core flow unusable, data loss, security hole, money error | Must fix before ship |
|
|
104
|
+
| Critical | Major feature broken, no acceptable workaround | Must fix or formally accept |
|
|
105
|
+
| Major | Feature impaired, workaround exists | Fix soon; may ship with sign-off |
|
|
106
|
+
| Minor | Cosmetic, edge inconvenience | Backlog |
|
|
107
|
+
|
|
108
|
+
A defect report must be reproducible: steps, expected vs actual, environment,
|
|
109
|
+
build/version, evidence (logs/screenshot), and severity. "It doesn't work" is not a defect report.
|
|
110
|
+
|
|
111
|
+
## 8. Environments and test data
|
|
112
|
+
|
|
113
|
+
- Test in an environment that mirrors production (config, dependencies, data shape).
|
|
114
|
+
- Use isolated, disposable test data per case; never depend on shared mutable state or execution order.
|
|
115
|
+
- Anonymize any production-derived data; never test against real personal data.
|
|
116
|
+
- Make non-determinism controllable: injectable clock, fixed seeds, stable ordering.
|
|
117
|
+
|
|
118
|
+
## 9. Test plan checklist (the plan is ready when)
|
|
119
|
+
|
|
120
|
+
- [ ] In-scope and out-of-scope explicitly listed.
|
|
121
|
+
- [ ] Every feature risk-tiered; depth allocated by risk.
|
|
122
|
+
- [ ] Each area mapped to the correct test layer.
|
|
123
|
+
- [ ] Entry and exit criteria defined and objective.
|
|
124
|
+
- [ ] Traceability matrix links requirements ↔ acceptance ↔ tests.
|
|
125
|
+
- [ ] Non-functional coverage (perf/security/a11y/compat) planned with budgets.
|
|
126
|
+
- [ ] Defect severity scale and triage path agreed.
|
|
127
|
+
- [ ] Environments, test data, and rollback verification covered.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: accessibility-acceptance-gate
|
|
3
|
+
title: 无障碍验收门禁规范(WCAG 作为可阻断的上线门,商业级必读)
|
|
4
|
+
domain: frontend
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: advanced
|
|
7
|
+
tags: [accessibility, a11y, wcag, acceptance-gate, ship-blocker, keyboard, screen-reader, contrast, focus, acceptance-criteria, audit, 无障碍, 验收门禁, 上线阻断, 可达性, 键盘, 屏幕阅读器, 商业级]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# 无障碍验收门禁规范(商业级必读)
|
|
12
|
+
|
|
13
|
+
> 无障碍不是上线后"有空再补"的优化项,而是和"功能能不能用、安全过不过"同级的**验收门**。"我们关注无障碍"这种软承诺没有意义——AI 生成与赶工的 UI 几乎必然漏掉键盘、焦点、对比度和标签。
|
|
14
|
+
> 这份规范把无障碍从"指南"升级成**可阻断上线的门禁**:每条要求都给出**可判定的验收标准 + 验证方法 + 严重度 + 是否阻断发布**。怎么写无障碍代码见 `frontend/01-standards/accessibility-standard` 与 `frontend/02-playbooks/accessibility-a11y-playbook`;本规范回答的是"做到什么程度才允许发版"。
|
|
15
|
+
|
|
16
|
+
## 1. 门禁目标与适用
|
|
17
|
+
|
|
18
|
+
- **目标等级**:交互式 Web 产品对齐 **WCAG 2.x AA**。这是商业产品的合规基线(多地法规要求)与用户覆盖问题,不是加分项。
|
|
19
|
+
- **适用范围**:所有面向用户的页面与组件——尤其是注册/登录、表单、结算/支付、核心任务流。后台/内部系统同样适用(员工里也有依赖辅助技术的人)。
|
|
20
|
+
- **门禁含义**:存在**阻断级(Blocker)**问题 → 不允许上线,必须修复后重验;**严重级(Critical)**问题需带期限的整改承诺方可放行;其余记入待办。
|
|
21
|
+
|
|
22
|
+
## 2. 验收维度与可判定标准
|
|
23
|
+
|
|
24
|
+
每条都必须是**可判定的**(能明确判通过/不通过),而不是"尽量做到"。
|
|
25
|
+
|
|
26
|
+
| 维度 | 验收标准(通过条件) | 验证方法 | 严重度 |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| 键盘可达 | 所有交互能力纯键盘完成,无鼠标依赖;无键盘陷阱 | 拔鼠标走查全流程 | Blocker |
|
|
29
|
+
| 焦点可见 | 每个可聚焦元素有清晰可见焦点指示;焦点顺序符合视觉/逻辑顺序 | 键盘 Tab 走查 | Blocker |
|
|
30
|
+
| 焦点管理 | 弹窗/抽屉打开聚焦其内、关闭归还触发元素、有焦点陷阱;动态内容焦点不丢 | 键盘 + 屏幕阅读器 | Critical |
|
|
31
|
+
| 文本替代 | 有意义图片有 alt,装饰图片 alt 为空/隐藏;图标按钮有可访问名 | 自动扫描 + 人工核 | Critical |
|
|
32
|
+
| 表单可达 | 每个输入有关联 `<label>`;错误以文本+程序化方式提示并指向出错字段 | 屏幕阅读器走查表单 | Blocker |
|
|
33
|
+
| 对比度 | 正文文本 ≥ 4.5:1,大字 ≥ 3:1,UI 组件/状态边界 ≥ 3:1 | 对比度工具量测 | Critical |
|
|
34
|
+
| 语义结构 | 正确标题层级(单 h1、不跳级)、地标区域、列表/表格用语义元素 | 自动扫描 + 人工核 | Critical |
|
|
35
|
+
| 屏幕阅读器可用 | 核心任务流用屏幕阅读器能独立完成,朗读内容准确、无"未标记按钮" | 屏幕阅读器端到端走查 | Blocker |
|
|
36
|
+
| 动态更新可感知 | 异步结果/错误/提示通过 live region 播报,不只视觉变化 | 屏幕阅读器走查 | Critical |
|
|
37
|
+
| 不只靠颜色 | 状态/错误/必填不仅用颜色区分,另有文本/图标/形状 | 人工核 + 灰度模拟 | Critical |
|
|
38
|
+
| 触控目标 | 触控目标足够大且有间距,避免误触 | 人工核 / 量测 | Minor |
|
|
39
|
+
| 缩放与回流 | 放大到 200% 文本不截断、不重叠、不丢功能 | 浏览器缩放走查 | Critical |
|
|
40
|
+
| 动效安全 | 尊重"减少动态效果"偏好;无强闪烁内容 | 人工核 + 偏好设置 | Critical |
|
|
41
|
+
|
|
42
|
+
## 3. 验证方法(自动 + 人工,缺一不可)
|
|
43
|
+
|
|
44
|
+
自动化只能覆盖一部分问题,**键盘、焦点、屏读语义、对比语境这些必须人工**:
|
|
45
|
+
|
|
46
|
+
- **自动扫描进 CI**:把无障碍静态/运行时扫描接入构建,对关键页面跑无障碍断言。自动扫描**0 阻断违规**作为流水线门禁的一道。
|
|
47
|
+
- **键盘走查**:拔掉鼠标,纯键盘完成每条核心任务流——这一关挡掉的问题最多。
|
|
48
|
+
- **屏幕阅读器走查**:用真实屏幕阅读器端到端走核心任务流,听朗读是否准确、是否出现"未命名按钮/图片"。
|
|
49
|
+
- **对比度量测**:对文本与 UI 组件量测对比度,不靠肉眼。
|
|
50
|
+
- **缩放/回流走查**:200% 缩放与窄视口下验证不丢功能、不重叠。
|
|
51
|
+
- **纳入设计验收**:组件态(hover/focus/error/disabled)的可达性在设计评审就锁定,不留到实现后返工。
|
|
52
|
+
|
|
53
|
+
## 4. 严重度与发布判定
|
|
54
|
+
|
|
55
|
+
| 严重度 | 定义 | 发布判定 |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Blocker | 整类用户**完全无法**完成核心任务(如纯键盘无法下单、屏读无法填表) | 阻断上线,修复后重验 |
|
|
58
|
+
| Critical | 严重妨碍但有勉强可行路径(对比不足、焦点丢失、错误未播报) | 需带期限整改承诺方可放行 |
|
|
59
|
+
| Minor | 体验受损但不阻断完成 | 记入待办,排期处理 |
|
|
60
|
+
|
|
61
|
+
判定原则:**核心任务流(注册/登录/支付/关键转化)的 Blocker 与 Critical 一律不放过**;门禁结果与证据(走查记录、扫描报告)随发布留痕,可审计。
|
|
62
|
+
|
|
63
|
+
## 5. 落地到交付流程
|
|
64
|
+
|
|
65
|
+
- **设计阶段**:在 UIUX 文档里就规定对比度、焦点态、键盘交互、错误提示方式,作为设计验收项。
|
|
66
|
+
- **实现阶段**:组件默认带语义与焦点态;CI 跑自动无障碍断言,阻断违规即红。
|
|
67
|
+
- **测试阶段**:核心流的键盘 + 屏读人工走查列入测试用例,不是"有空看看"。
|
|
68
|
+
- **发布门**:把"无障碍门禁通过"列入生产就绪审查(见 `operations/01-standards/production-readiness-review`)的必过项之一。
|
|
69
|
+
- **回归保护**:核心交互的无障碍断言进自动化回归,防止后续改动悄悄破坏。
|
|
70
|
+
|
|
71
|
+
## 6. 反模式(出现即不合格)
|
|
72
|
+
|
|
73
|
+
1. **把无障碍当上线后再补**:没有门、没有判定,"关注一下"等于不做。
|
|
74
|
+
2. **只跑自动扫描就签字**:忽略键盘/焦点/屏读语义——这些自动化测不全。
|
|
75
|
+
3. **`div` 当按钮 + `outline:none`**:丢失原生键盘/焦点/角色,又不补替代。
|
|
76
|
+
4. **只用颜色表达状态**:错误/必填/状态仅靠红绿,色觉障碍用户无法分辨。
|
|
77
|
+
5. **图标按钮无可访问名**:屏读只念"按钮",用户不知道是干嘛的。
|
|
78
|
+
6. **弹窗不管焦点**:打开焦点不进、关闭不归还、无焦点陷阱,键盘用户迷路。
|
|
79
|
+
7. **动态结果只改视觉**:异步成功/失败不播报,屏读用户毫无感知。
|
|
80
|
+
8. **门禁可绕过**:定了门禁却不强制,开发学会跳过,等于没有。
|
|
81
|
+
|
|
82
|
+
## 7. 最低交付 checklist
|
|
83
|
+
|
|
84
|
+
- [ ] 明确目标等级(AA)与适用范围,门禁判定规则(Blocker 阻断/Critical 带期限/Minor 排期)写清。
|
|
85
|
+
- [ ] 每个验收维度有可判定标准、验证方法与严重度,不用"尽量"措辞。
|
|
86
|
+
- [ ] 自动无障碍扫描进 CI,关键页 0 阻断违规作为门禁一道。
|
|
87
|
+
- [ ] 核心任务流完成纯键盘走查与屏幕阅读器端到端走查并留证。
|
|
88
|
+
- [ ] 文本对比度量测达标;200% 缩放不丢功能;状态不只靠颜色。
|
|
89
|
+
- [ ] 弹窗/动态内容焦点管理与 live region 播报验证通过。
|
|
90
|
+
- [ ] 无障碍门禁通过列入生产就绪审查必过项;核心交互断言进回归。
|
|
91
|
+
- [ ] 设计阶段即锁定对比度/焦点态/键盘交互/错误提示方式。
|
|
@@ -5,8 +5,8 @@ domain: frontend
|
|
|
5
5
|
category: 01-standards
|
|
6
6
|
difficulty: intermediate
|
|
7
7
|
tags: [accessibility, aria, complete, frontend, html, 屏幕阅读器优化, 属性, 概述]
|
|
8
|
-
quality_score:
|
|
9
|
-
last_updated: 2026-06-
|
|
8
|
+
quality_score: 90
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
10
|
---
|
|
11
11
|
# Web 无障碍完整指南
|
|
12
12
|
|
|
@@ -402,7 +402,7 @@ function DropdownMenu({ items }: { items: MenuItem[] }) {
|
|
|
402
402
|
padding-left: 12px;
|
|
403
403
|
}
|
|
404
404
|
.error::before {
|
|
405
|
-
content: "
|
|
405
|
+
content: "! ";
|
|
406
406
|
}
|
|
407
407
|
```
|
|
408
408
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ui-states-and-resilient-data-fetching
|
|
3
|
+
title: UI 状态与健壮数据获取规范(商业级前端必读)
|
|
4
|
+
domain: frontend
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [ui-states, loading, empty, error, optimistic-update, data-fetching, retry, resilience, 状态, 商业级]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# UI 状态与健壮数据获取规范(商业级前端必读)
|
|
12
|
+
|
|
13
|
+
> 区分"demo 级"和"商业级"前端的,不是动效,而是**对每一种状态的处理**:加载、空、错误、部分、离线、并发。
|
|
14
|
+
> 只画 happy path(有数据、网络好、不点重复)的界面,一上真实网络就白屏、转圈卡死、数据错乱。
|
|
15
|
+
> 每个会取数或提交的界面,都必须显式设计完整的状态矩阵。
|
|
16
|
+
|
|
17
|
+
## 1. 状态矩阵(每个数据视图都要覆盖)
|
|
18
|
+
|
|
19
|
+
任何"从后端取数据"的视图,至少要显式处理这些状态——缺一即不合格:
|
|
20
|
+
|
|
21
|
+
| 状态 | 含义 | UI 要求 |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| Loading(首次)| 还没有数据 | 骨架屏/占位,**不要**只放一个居中转圈占满屏 |
|
|
24
|
+
| Loading(刷新)| 已有旧数据、在拉新 | 保留旧内容 + 局部加载指示(不闪白) |
|
|
25
|
+
| Empty | 请求成功但无数据 | 友好空态:说明 + 引导操作("还没有订单,去下单"),区分"无数据"与"加载中" |
|
|
26
|
+
| Partial | 部分成功/分页中 | 显示已有 + "加载更多"/继续指示 |
|
|
27
|
+
| Error | 请求失败 | 明确错误信息 + **重试按钮**,不要白屏或一直转 |
|
|
28
|
+
| Success | 正常有数据 | 正常渲染 |
|
|
29
|
+
| Forbidden | 无权限 | 明确"无权限"而非空态或报错 |
|
|
30
|
+
| Offline | 无网络 | 离线提示 + 恢复后自动/手动重试 |
|
|
31
|
+
|
|
32
|
+
**反模式**:把 Empty 当 Loading(无数据时永远转圈)、把 Error 当 Empty(失败却显示"暂无数据"误导用户)、加载时整屏白屏闪烁。
|
|
33
|
+
|
|
34
|
+
## 2. 加载体验
|
|
35
|
+
|
|
36
|
+
- **骨架屏优先**:列表/卡片/详情用与最终布局一致的骨架占位,避免布局跳动(CLS)。
|
|
37
|
+
- **保留旧数据刷新**:翻页/筛选/轮询时保留当前内容做局部 loading,别清空成白屏(stale-while-revalidate 思路)。
|
|
38
|
+
- **延迟显示 loading**:极快的请求(<300ms)可不显示 spinner,避免"闪一下"的抖动;超过阈值才显示。
|
|
39
|
+
- **防止布局跳动**:为图片/异步内容预留尺寸,占位与真实内容同尺寸。
|
|
40
|
+
|
|
41
|
+
## 3. 错误处理
|
|
42
|
+
|
|
43
|
+
- **永远有出路**:任何错误态都要给"重试"或"返回",绝不留死界面。
|
|
44
|
+
- **可理解的信息**:把后端错误信封(`code/message`)映射成用户能懂的话;不要把原始 500 堆栈/技术错误码甩给用户。
|
|
45
|
+
- **就近显示**:表单字段错误显示在字段旁,全局错误用 toast/横幅;区分"可重试的系统错误"和"用户需修正的输入错误"。
|
|
46
|
+
- **错误边界(error boundary)**:组件级渲染异常要被边界捕获,降级为局部错误块,**不要整页崩白**。
|
|
47
|
+
- **超时也是错误**:请求设超时,超时给明确反馈与重试,不要无限转圈。
|
|
48
|
+
|
|
49
|
+
## 4. 健壮的数据获取
|
|
50
|
+
|
|
51
|
+
- **客户端重试**:对幂等的 GET 失败做有限次指数退避+抖动重试;非幂等提交不自动重试(需幂等键,见 `backend/01-standards/idempotency-and-safe-retries`)。
|
|
52
|
+
- **请求竞态(latest-wins)**:快速切换筛选/搜索时,旧请求的响应可能后到并覆盖新结果——必须取消过期请求或丢弃过期响应(按发起序号/AbortController),保证"显示的是最后一次请求的结果"。
|
|
53
|
+
- **缓存与重验证**:列表数据可缓存并在后台重验证(stale-while-revalidate),先给旧值再悄悄刷新,提升感知速度。
|
|
54
|
+
- **去抖/节流**:搜索框输入去抖(debounce),滚动/resize 节流,避免请求风暴。
|
|
55
|
+
- **分页/无限滚动**:明确"加载更多/到底了/加载失败可重试"三态,别静默停住。
|
|
56
|
+
|
|
57
|
+
## 5. 提交与乐观更新
|
|
58
|
+
|
|
59
|
+
- **防重复提交**:提交中禁用按钮 + 显示进行态;双击/回车连发只触发一次。配合服务端幂等。
|
|
60
|
+
- **乐观更新要可回滚**:先更新 UI 再发请求时,必须保存前值,**失败回滚**并提示,绝不让界面停留在"假成功"。
|
|
61
|
+
- **明确的提交结果**:成功给确认(toast/跳转),失败保留用户输入(别清空表单)+ 显示原因。
|
|
62
|
+
- **长操作**:耗时操作给进度/可取消,而不是冻结界面。
|
|
63
|
+
|
|
64
|
+
## 6. 表单状态
|
|
65
|
+
|
|
66
|
+
- 校验分层:即时(失焦校验单字段)+ 提交时整体校验;错误就近显示。
|
|
67
|
+
- 提交中:禁用提交、显示 loading、阻止重复提交。
|
|
68
|
+
- 失败:保留已填数据,定位到第一个错误字段。
|
|
69
|
+
- 离开未保存:脏表单离开前提示,避免误丢输入。
|
|
70
|
+
|
|
71
|
+
## 7. 可访问性与状态
|
|
72
|
+
|
|
73
|
+
- 加载/错误/成功要对辅助技术可感知:用 `aria-live` 通知动态变化,loading 用 `aria-busy`,错误关联到字段(`aria-describedby`)。
|
|
74
|
+
- 焦点管理:错误后把焦点移到错误区/首个错误字段;模态打开/关闭正确收发焦点。
|
|
75
|
+
- 不要只用颜色传达状态(红=错),要有文字/图标兜底。
|
|
76
|
+
|
|
77
|
+
## 8. 反模式(出现即不合格)
|
|
78
|
+
|
|
79
|
+
1. **只做 happy path**:无 empty/error/loading 处理,真实网络下白屏或转圈不止。
|
|
80
|
+
2. **空态当加载**:无数据时永远 spinner。
|
|
81
|
+
3. **错误吞掉**:catch 后什么都不显示,用户面对死界面。
|
|
82
|
+
4. **整页崩白**:单个组件抛错拖垮整页(无 error boundary)。
|
|
83
|
+
5. **请求竞态覆盖**:快速切换后显示的是旧请求的结果。
|
|
84
|
+
6. **乐观更新不回滚**:失败后界面停在假成功。
|
|
85
|
+
7. **可重复提交**:双击下单两次、扣两次款。
|
|
86
|
+
8. **加载闪白/布局跳动**:刷新清空内容、异步内容撑开布局。
|
|
87
|
+
|
|
88
|
+
## 9. 最低交付 checklist
|
|
89
|
+
|
|
90
|
+
- [ ] 每个取数视图覆盖 loading/empty/error/partial/forbidden/offline 全状态。
|
|
91
|
+
- [ ] 错误态都有重试出口,错误信息对用户可理解。
|
|
92
|
+
- [ ] 首次加载用骨架屏,刷新保留旧数据不闪白。
|
|
93
|
+
- [ ] 组件级 error boundary 防整页崩。
|
|
94
|
+
- [ ] 取数处理请求竞态(latest-wins / 取消过期请求)。
|
|
95
|
+
- [ ] 提交防重复 + 乐观更新可回滚 + 失败保留输入。
|
|
96
|
+
- [ ] 幂等的失败有限重试(退避+抖动),非幂等不自动重试。
|
|
97
|
+
- [ ] 状态变化对辅助技术可感知(aria-live/focus 管理)。
|