Test Strategy
The master test and verification strategy for the Sindh IT Portal — Facilitation Desk (SITP): the testing pyramid, tools, coverage targets, CI/CD gates, test-data strategy, representative test cases (TC-<EPIC>-<nnn>-<nn>), Gherkin-as-spec, localization/RTL, accessibility, security, performance/load, UAT, regression, defect management, and bidirectional traceability from Functional Requirement → User Story → Acceptance Criterion → Test Case.
| Field | Value |
|---|---|
| Doc ID | 13 |
| Status | Draft |
| Owner | S&ITD / MAAHIR |
| Languages | EN (master) · UR · SD |
| ID scheme | TC-<EPIC>-<nnn>-<nn> per _conventions.md §4 |
| Source of truth | _context.md · /specs/en/01-prd/ · /specs/en/03-non-functional-reqs/ |
| Verifies | /specs/en/02-functional-reqs/ · /specs/en/06-ticket-workflow/ · /specs/en/11-security-compliance/ |
1. Purpose & How to Read This Document
This document is the authoritative verification contract for SITP. It tells engineering, QA, MAAHIR operations, and S&ITD acceptance stakeholders what is tested, at which layer, with which tools, to which targets, and how every Test Case ties back to a User Story, its Acceptance Criteria, and the originating Functional Requirement. It is written to be RFP- and tender-ready, and to satisfy the PPP accountability bar that every shipped capability is demonstrably verified.
1.1 Reading order for a single verification
Functional Requirement (
FR-...) → User Story (US-...) → Acceptance Criterion (GherkinScenario) → Test Case (TC-<EPIC>-<nnn>-<nn>) → Test Layer (unit / integration / e2e / manual) → CI Gate / NFR target.
Every TC listed in this document exists to make one or more Gherkin scenarios in /specs/en/01-prd/ executable and repeatable. IDs are stable, language-neutral, and never translated.
1.2 Quality bar (one-line statement)
The Portal is shippable when (a) every
[M]Acceptance Criterion in the PRD has at least one passing automated Test Case, (b) coverage targets in §5 are met, (c) every CI/CD gate in §6 is green, and (d) the UAT exit criteria in §13 are signed off by the pilot departments.
1.3 Scope
| In scope | Out of scope (this doc) |
|---|---|
| Automated unit, integration, end-to-end, contract, performance, security, accessibility, i18n tests | Detailed manual test scripts (live in the QA test-management tool, e.g., TestRail / Zephyr) |
Coverage targets, CI gates, test-data strategy, representative TC catalogue |
Per-adapter mock specifications (live in /specs/en/08-integrations-spec/) |
| UAT plan, regression strategy, defect management, traceability | Runbooks for DR drills, restore drills (live in /specs/en/15-tech-architecture/) |
2. Testing Principles
- Shift left. Defects are cheapest to fix at the unit layer. Every PR carries its own tests; nothing reaches
mainunverified (NFR-MAINT-003). - Test behaviour, not implementation. Tests assert observable outcomes from the Gherkin scenarios; they do not assert private method signatures or DB column names. This keeps the modular-monolith refactorable (NFR-MAINT-001).
- Gherkin is the contract. A
Scenario:in the PRD is a single source of truth: it documents intent for stakeholders and drives automation via Cucumber/Playwright step bindings (see §8). There is no parallel, divergent "test spec". - Defense in depth. Security, privacy, accessibility, and i18n are not single-gate checks; each is verified by an automated layer (CI) plus a manual/expert layer (per-release audit). See §10–§12.
- Determinism first. Flaky tests are treated as P1 defects; a test that cannot be made deterministic is quarantined and rewritten within one sprint (NFR-RELY-004 mindset applied to QA).
- Production realism. Performance, localization, and graceful-degradation tests run against a staging environment that mirrors production topology (NFR-PORT-001, NFR-SCAL-001) at realistic cardinality (§7).
3. Testing Pyramid
SITP follows the classic testing pyramid: a broad, fast unit base; a narrower integration band; a small, slow end-to-end (e2e) peak; and a thin manual / UAT layer reserved for exploratory testing, accessibility audit, security pen-test, and stakeholder acceptance. The shape is deliberate — the vast majority of assertions live at the cheapest, fastest layer.
Written description. The pyramid reads bottom-up: the broadest layer (Unit) holds the most assertions and runs in milliseconds on every pull request. Each successive layer holds fewer assertions, costs more to run, and runs less frequently. The base verifies that each module's pure logic — SLA calculators, the proof-of-resolution gate, the escalation-ladder scheduler, PII-redaction mappers, RBAC resolution, locale-catalog completeness — behaves correctly in isolation. The integration band verifies that modules cooperate through their published interfaces and against real MariaDB/Redis/MinIO via Testcontainers. The e2e peak exercises the few journeys that are only meaningful when the whole stack (portal + API + workers + AI service + adapters) is live — file a ticket, track by ID, resolve with proof, escalate, publish a MoM, verify a QR-signed letter. The manual layer is reserved for what cannot be automated: exploratory testing, the WCAG screen-reader audit, the independent pen-test, and the pilot departments' UAT sign-off.
3.1 Layer-by-layer contract
| Layer | What it proves | Tools | Runs on | Target share |
|---|---|---|---|---|
| Unit | Pure logic, single-module correctness, no I/O | Vitest / Jest, ts-jest, PyTest (AI service) |
every PR (CI) | ~70% of assertions |
| Integration | Module cooperation, real infra (DB, cache, storage, queue), adapter mocks | NestJS Test.createTestingModule, Testcontainers, Supertest |
every PR (CI) | ~20% |
| Contract | API/Webhook contracts honored by both sides | OpenAPI schema-diff, Pact (consumer-driven for webhooks) | every PR (CI) | subset of integration |
| End-to-end | Full critical journeys through the live stack | Playwright (web), Playwright APIRequestContext | nightly + pre-release smoke | ~7% |
| Performance / Load | Throughput, latency p95, AI/OCR timeouts, concurrency | k6 (primary) / Artillery (alternate) | pre-release + on-demand | — |
| Security | OWASP ASVS L2, authz matrix, ABAC, pen-test | OWASP ZAP, Burp Suite, gitleaks, Trivy, Snyk |
nightly ZAP + per-release manual | — |
| Accessibility | WCAG 2.1 AA automated + manual screen-reader | axe-core, Pa11y, Lighthouse CI, NVDA/VoiceOver | every PR (automated) + per-release (manual) | — |
| i18n / l10n | Three-locale parity, RTL mirroring, glossary conformance | custom locale-catalog diff, Playwright visual (LTR+RTL), Lighthouse | every PR + pre-release | — |
| Manual / UAT | Exploratory, audit-grade a11y, pen-test, pilot acceptance | human testers, screen readers, pilot dept staff | per-release / per-phase | ~3% |
4. Tools & Stack
Tools are chosen to match the technology stack locked in _context.md §3 and the maintainability gates in /specs/en/03-non-functional-reqs/ §3.9. No tool is introduced that cannot run in CI on every pull request.
| Concern | Primary tool | Alternate / note |
|---|---|---|
| Unit tests (NestJS / TypeScript) | Vitest (fast, ESM-native) | Jest acceptable where a module already standardizes on it |
| Unit tests (FastAPI AI service) | PyTest + pytest-asyncio + pytest-cov |
Coverage feeds the same gate as the TS side |
| Integration tests (NestJS) | NestJS DI (Test.createTestingModule) + Testcontainers (MariaDB 10.11, Redis, MinIO, Keycloak test realm) |
Each spec gets a fresh schema/namespace; no shared mutable state |
| HTTP/API assertions | Supertest against the NestJS app | Pact for consumer-driven webhook contracts |
| End-to-end (browser) | Playwright (Chromium, Firefox, WebKit) | One suite, parameterized over EN/UR/SD and LTR/RTL |
| End-to-end (mobile) | Playwright device emulation (Moto G Power, iPhone SE) | React Native (Expo) Detox deferred to Phase 4 |
| Contract / API diff | OpenAPI 3 generated from code; oasdiff for breaking-change detection | Spec-diff is a hard gate (NFR-INTER-004) |
| Performance / load | k6 (primary) | Artillery as alternate for soak/scenario scripting |
| Accessibility (automated) | axe-core (via @axe-core/playwright) + Pa11y + Lighthouse CI |
All three run; Pa11y also scans the Docusaurus docs site |
| Accessibility (manual) | NVDA + Firefox, JAWS + Edge, VoiceOver + Safari/iOS, TalkBack + Android | Per-release audit on critical journeys (NFR-A11Y-002) |
| Security (DAST) | OWASP ZAP (nightly baseline + per-release active scan) | Burp Suite Professional for the independent pen-test |
| Security (SAST/SCA/secrets) | gitleaks/trufflehog (secrets), Snyk or Trivy (SCA), ESLint security plugin (SAST) |
Critical CVE gate per NFR-SEC-011 |
| i18n / l10n | custom locale-diff (EN↔UR↔SD key parity), eslint-plugin-react-intl (no hardcoded strings), Playwright visual + screenshot diff in LTR and RTL |
Glossary-conformance check from _glossary.md |
| Visual regression | Playwright screenshot diff (per page, per locale, per direction) | Baselines reviewed each release; drift → manual approval |
| Test data | Factory functions + Faker.js (synthetic), masked PII corpus (see §7) | Fixtures versioned in-repo under tests/fixtures/ |
| Test management | TestRail (or Zephyr Scale) for manual/UAT scripts and traceability | Test Cases in this doc are the spec; the tool holds execution evidence |
| Coverage | c8 / istanbul (TS), coverage.py (Py) | Reported to CI; trend tracked per build |
| Mutation (optional, [C]) | Stryker (TS) | Phase-2+ to harden the critical-path suite |
5. Coverage Targets
Coverage targets align with NFR-MAINT-002 and add a stricter bar for the highest-risk decision gates. Coverage is a floor, not a ceiling; it is necessary but not sufficient (a high score with shallow assertions is a known anti-pattern, countered by the mutation-testing option in §4).
| Scope | Line coverage | Branch coverage | Gate |
|---|---|---|---|
| NestJS API (overall) | ≥ 70 % | ≥ 60 % | Hard, per NFR-MAINT-002 |
| FastAPI AI service (overall) | ≥ 70 % | ≥ 60 % | Hard, per NFR-MAINT-002 |
| Critical-path modules (auth, ticket lifecycle, audit, files) | ≥ 80 % line | ≥ 70 % branch | Hard, per NFR-MAINT-002 |
| Highest-risk decision gates (see §5.1) | 100 % line & branch | — | Hard |
| Public-site / Next.js components | ≥ 60 % line | ≥ 50 % branch | Soft (warn) at V1; harden in Phase 2 |
A PR that lowers overall coverage below the floor fails the build. The coverage gate runs on the delta (changed lines) in addition to the whole-project total, so legacy code is not penalised but new code is held to the bar.
5.1 The 100 % decision gates
These are the narrow, high-blast-radius code paths where a missed branch is a compliance or trust failure. They must reach 100 % line and branch coverage with explicitly named test cases, regardless of the module-wide floor:
| Decision gate | Why 100 % | Owning module(s) |
|---|---|---|
Proof-of-resolution gate — block Resolved without evidence + note |
Closure integrity; ties to escalation & CSAT | TKT (FR-TKT-013/014) |
Audit append — every state change writes an immutable aud_event with trace_id |
Government accountability (NFR-AUD-001) | XCU / all modules |
| Authorization allow/deny — RBAC template + override resolution | Cross-tenant & cross-department isolation | ORG (FR-ORG-005) |
| ABAC confidential/VIP check — attribute-based access on sensitive tickets | Privacy + trust-and-safety (NFR-AUD-004, NFR-PRIV-003) | ORG (FR-ORG-010) |
| PII redaction before cloud AI — mask/tokenize before any cloud call | Data residency + sovereignty (NFR-PRIV-006) | AI (FR-AI-010) |
| Idempotency-key dedup — same key + payload ⇒ one write | Retry safety (NFR-RELY-004) | XCU / all state-changing endpoints |
| Step-up auth challenge — stale session ⇒ step-up on sensitive routes | Limits session-hijack blast radius (NFR-SEC-005) | ORG / INT |
| Feature-flag fail-safe default — flag-service unreachable ⇒ safe default | Operational safety (US-FFG-002) | FFG |
6. CI/CD Gates & Pipeline
Every gate below is a hard block on the path to main and to a production deploy, enforced by branch protection (NFR-MAINT-003). A deploy that skips a gate is an incident.
Written description. A pull request enters the pipeline at the left and must pass every gate left-to-right before it can merge. Lint and typecheck are the cheapest catches and run first. Unit tests with the coverage gate follow, then integration tests that spin up real MariaDB/Redis/MinIO via Testcontainers. Contract tests (OpenAPI diff against the published spec, Pact for webhooks) catch breaking changes before they reach partners. Build produces the containers and bundles. SCA + secrets scans dependencies and source for known vulnerabilities and leaked credentials (NFR-SEC-006, NFR-SEC-011). Accessibility (axe-core, Pa11y, Lighthouse) and i18n/RTL (locale parity, visual diff) run next. An e2e smoke suite covers the top critical journeys. License + SBOM generation closes the per-PR block. After human review and merge, the nightly full suite runs the slower, deeper checks — ZAP DAST, k6 load, full e2e across all three locales, and (optionally) mutation testing. A release gate adds the human-in-the-loop checks: the independent pen-test, the manual accessibility audit, and pilot-department UAT sign-off. Only then does a zero-downtime deploy proceed (NFR-AVAIL-006).
6.1 Gate catalogue
| Gate | Tool | Blocks | Tied NFR |
|---|---|---|---|
| Lint | ESLint, Prettier, Ruff | PR merge | MAINT-003 |
| Typecheck | tsc --noEmit, mypy |
PR merge | MAINT-003 |
| Unit + coverage | Vitest/Jest, PyTest + c8/coverage.py | PR merge (delta + total) | MAINT-002 |
| Integration | NestJS DI + Testcontainers | PR merge | RELY-004, RELY-005 |
| Contract | OpenAPI diff, Pact | PR merge | INTER-001, INTER-004 |
| Build | Docker, Next.js build | PR merge | PORT-001 |
| SCA / secrets | Snyk/Trivy, gitleaks | PR merge (critical/high CVE) | SEC-006, SEC-011 |
| Accessibility (auto) | axe-core, Pa11y, Lighthouse CI | PR merge (zero critical violations) | A11Y-001 |
| i18n / RTL | locale-diff, eslint-plugin-react-intl, visual | PR merge | I18N-001, I18N-002, I18N-003 |
| e2e smoke | Playwright | PR merge (top journeys, EN) | — |
| License / SBOM | Syft, license-check | PR merge (no copyleft in prod deps) | MAINT-001 |
| DAST (full) | OWASP ZAP | nightly + pre-release | SEC-001, SEC-008 |
| Load (full) | k6 | pre-release + on-demand | PERF-001..011 |
| Pen-test | Burp Suite (independent) | pre-go-live + annual | SEC-007 |
| Manual a11y audit | NVDA/JAWS/VoiceOver/TalkBack | per-release | A11Y-002, A11Y-003 |
| UAT sign-off | Pilot departments | per-phase gate | see §13 |
7. Test Data Strategy
Test data is synthetic by default; real PII never leaves production, and the few corpora that mimic PII are masked and access-controlled. Data strategy is governed by NFR-PRIV-001 (minimization) and NFR-PRIV-003 (PII vaulting).
7.1 Data sources
| Source | Use | Notes |
|---|---|---|
| Synthetic factories (Faker.js + custom builders) | Unit, integration, e2e | Deterministic seeds; one factory per entity type |
| Masked PII corpus | Privacy-redaction tests, pen-test | Real shapes with substituted values; access-restricted |
| Fixtures per entity type | Contract + e2e | Versioned JSON in tests/fixtures/ (company, ticket, MoM, letter, user×role) |
| Multilingual corpus | i18n, OCR, search | 3 locales × representative content; see §7.3 |
| Anonymized production sample | Performance/load (optional) | Only after approved anonymization pipeline; Phase-2+ |
7.2 Entity fixture coverage
Each entity type has at least one canonical fixture and one edge-case fixture, so that conditional logic (entity-type-specific registration, category-specific ticket fields, role-template overrides) is exercised:
- Company — one per entity type: SECP company, sole proprietor/partnership, freelancer, foreign branch, early startup (provisional) (per
US-ORG-001). - Representative — one per role template: Primary, Admin, Filer, Viewer, Notify; plus a granular-override case (per
US-ORG-004). - Department — a nested fixture: Department → Section → Staff, with DG + Secretary oversight assigned (per
US-ORG-005). - Ticket — happy-path, conditional-form (per category), draft, sub-task parent/child, merged primary/secondary, confidential/VIP, RTI-category (statutory deadline).
- MoM — scanned-image (forces OCR), text-PDF, Word; with and without action items; sensitive/VIP variant.
- Letter / certificate — trilingual, signed/unsigned, tampered-hash variant for QR verification.
- Notification — per channel (email, SMS, WhatsApp, in-app) and per event (created, assigned, escalated, resolved, closed, MoM-published).
7.3 Multilingual corpus (3 locales)
Every text-bearing fixture exists in EN, UR, and SD so that OCR, search, AI translation, notification rendering, and RTL layout are all exercised against realistic script content:
- Latin (EN) — baseline.
- Urdu (UR) — Nastaliq, RTL.
- Sindhi (SD) — Naskh Arabic script, RTL.
- A mixed-script fixture (EN body + UR attachment) for translation and PII-redaction edge cases.
7.4 Data hygiene rules
- No real CNIC, real phone number, or real email appears in any fixture or committed seed. Faker locale set to
en_PKfor plausible shapes. - The masked PII corpus lives in an access-controlled store; CI pulls it via short-lived token only for the redaction/pen-test jobs.
- Test databases are ephemeral (Testcontainers) and torn down per spec run; no cross-spec leakage.
- Production-like cardinality for performance tests is generated by a seeder that respects
NFR-SCAL-004/005(up to 100 k tickets, 100 k reps, 10 k staff).
8. Gherkin Scenarios Reused as Automated Specs
A Scenario: block in /specs/en/01-prd/ is not documentation that is then re-translated into a separate test script. It is the executable specification. The Gherkin text is bound to automation through two mechanisms:
- Cucumber (Behave for PyTest /
@cucumber/cucumberfor TS) — the literal GherkinGiven/When/Thensteps are bound to step-definition functions. The scenario text and the test are one artefact; changing the scenario changes the test. - Playwright + data-testid binding — for e2e, the same Gherkin scenario is annotated with stable
data-testidselectors so the assertion is portable across UI refactors.
Worked example — the proof-of-resolution gate scenario (US-TKT-006) becomes TC-TKT-006-01:
# Reused verbatim from /specs/en/01-prd/ (US-TKT-006, Scenario: Resolution requires evidence and a note)
Scenario: Resolution requires evidence and a note
Given a staff member attempts to move a ticket to "Resolved"
When no evidence attachment and resolution note are present
Then the transition is blocked
And the system states which required items are missing
Bound automation (illustrative):
// tests/integration/ticket/proof-gate.steps.ts
Given('a staff member attempts to move a ticket to {string}', async (status) => {
this.ticket = await ticketFactory.create({ status: 'InProgress' });
this.attempt = () => ticketsApi.transition(this.ticket.id, status);
});
When('no evidence attachment and resolution note are present', async () => {
// factory created the ticket without attachments and without a note — nothing to do
});
Then('the transition is blocked', async () => {
await expect(this.attempt()).rejects.toMatchObject({ status: 409, code: 'PROOF_GATE_MISSING' });
});
Then('the system states which required items are missing', async () => {
const err = await this.attempt().catch(e => e);
expect(err.details.missing).toEqual(expect.arrayContaining(['evidence_attachment', 'resolution_note']));
});
Authoring rule: if a Test Case cannot be traced to a Gherkin scenario, either the scenario is missing (add it to the PRD) or the Test Case is testing implementation detail (refactor or delete it). This rule keeps the spec and the suite from drifting apart.
9. Sample Test Cases (TC-<EPIC>-<nnn>-<nn>)
The table below lists representative Test Cases that exercise the locked behavioural decisions in _context.md §5 and the [M]/[S] user stories in the PRD. It is not the exhaustive suite — the full catalogue (one or more TCs per Acceptance Criterion across E1–E17) lives in the QA test-management tool. Each TC here maps to its originating User Story, the Functional Requirement(s) it satisfies, the primary test layer, and the priority that drives regression inclusion (see §14).
| TC ID | Title (one-line behaviour) | Traces to (US · FR) | Layer | Pri. |
|---|---|---|---|---|
TC-PUB-001-01 |
Every public page renders fully in EN, UR, and SD with RTL for UR/SD and no fallback strings | US-PUB-001 · FR-PUB-001/002 |
e2e + i18n | P0 |
TC-ORG-001-01 |
Conditional registration form shows only the fields/ documents for the selected entity type (5 types) | US-ORG-001 · FR-ORG-001 |
integration + e2e | P0 |
TC-ORG-002-01 |
Complete registration grants instant Provisional badge; ticket filing enabled while verification runs in parallel | US-ORG-002 · FR-ORG-002/003 |
integration | P0 |
TC-ORG-003-01 |
Transferring Primary Authorized Rep leaves exactly one Primary; prior demotes; change audit-logged | US-ORG-003 · FR-ORG-004 |
integration | P0 |
TC-ORG-004-01 |
A denied granular override is enforced even when the role template would grant the permission | US-ORG-004 · FR-ORG-005 |
unit + integration | P0 |
TC-ORG-005-01 |
Escalation ladder fires at 2/5/10 days: DG added as watcher at 2d, Secretary at 7d, SACM at 17d; notifications sent; SLA pauses on await/weekend/holiday | US-ORG-005 · FR-ORG-006/007 + _context.md §5 |
unit + integration | P0 |
TC-ORG-007-01 |
Confidential/VIP ticket is invisible (list + search) to staff lacking the matching attribute; access attempt logged | US-ORG-007 · FR-ORG-010 |
integration + e2e | P0 |
TC-TKT-001-01 |
File-ticket happy path: complete dynamic form ⇒ status "New", tracking ID SITP-YYYY-<DEPT>-<NNNNNN>, confirmation in rep's preferred language |
US-TKT-001 · FR-TKT-001/002/004/007 |
integration + e2e | P0 |
TC-TKT-002-01 |
AI auto-route suggests department/section/urgency with a confidence score; officer accept/modify/reject; override audit-logged with original suggestion | US-TKT-002 · US-AI-002 · FR-AI-002/003, FR-TKT-005 |
integration (mocked engine) | P0 |
TC-TKT-004-01 |
Saved draft persists across sessions/devices and restores attachments; smart assistant surfaces similar resolved tickets and records deflection on discard | US-TKT-004 · FR-TKT-003, FR-AI-007 |
integration + e2e | P1 |
TC-TKT-006-01 |
Proof-of-resolution gate blocks transition to "Resolved" when evidence attachment or resolution note is missing; states what is missing | US-TKT-006 · FR-TKT-013/014 |
unit + integration | P0 |
TC-TKT-006-02 |
Resolved ticket auto-closes after CSAT window elapses with no company action; closure event/timestamp/trigger recorded | US-TKT-006 · FR-TKT-015 |
integration (time-travel) | P0 |
TC-TKT-006-03 |
Company rejects resolution within CSAT window ⇒ ticket reopens to prior working state, SLA resumes, staff/watchers notified; closed ticket ⇒ appeal record created and routed to next escalation tier | US-TKT-006 · FR-TKT-015/016 |
integration + e2e | P0 |
TC-NOT-003-01 |
Two-way inbound: replying to a ticket notification email appends body + attachments as a comment and notifies staff/watchers; unmatched inbound held for review, not discarded | US-NOT-003 · FR-NOT-003 |
integration | P1 |
TC-AI-001-01 |
Multilingual OCR extracts searchable text for Latin/Urdu/Sindhi scripts with a confidence score; low-confidence flagged for manual review | US-AI-001 · FR-AI-001 |
integration (fixture corpus) | P1 |
TC-AI-006-01 |
MoM upload: OCR + AI extract structured action items (owner + due date) + summary for officer confirmation; on confirm, each action item becomes a sub-task on the source ticket | US-AI-006 · US-MTG-003/004 · FR-AI-012, FR-MTG-009/012 |
integration + e2e | P1 |
TC-MTG-005-01 |
Sensitive/VIP MoM publish routes to Chair/DG for approval and blocks auto-share until approved; on approval, auto-share to all participants with acknowledgment tracking | US-MTG-005 · FR-MTG-015/018 |
integration | P0 |
TC-FILE-002-01 |
ClamAV-flagged upload is quarantined, never downloadable, rejected with a safe message, and raises a security alert + audit event | US-FILE-002 · FR-FILE-003, NFR-SEC-012 |
integration (seeded EICAR) | P0 |
TC-INT-001-01 |
NADRA outage: circuit breaker opens after configured failures, registration moves to "verification pending", retries resume on recovery, zero unhandled exceptions | US-INT-001 · FR-INT-001, NFR-RELY-001/003 |
integration (fault injection) | P0 |
TC-INT-004-01 |
OIDC SSO staff sign-in applies group/role claims; sensitive-area access requires step-up 2FA and marks the session step-up-authenticated | US-INT-004 · FR-INT-004, NFR-SEC-005 |
integration + e2e | P0 |
TC-DOC-003-01 |
QR verification of a signed letter confirms issuance + matching file hash; tampered-hash or unknown code ⇒ "Could not verify" + logged attempt | US-DOC-003 · FR-DOC-011 |
integration + e2e | P0 |
TC-TRN-002-01 |
Exam-gate blocks live-ticket assignment for an uncertified officer; passing the exam unlocks assignment on next attempt | US-TRN-002 · FR-TRN-006, US-ORG-007 |
integration | P1 |
TC-FFG-001-01 |
Feature flag disabled per department hides the capability for that dept and leaves others enabled; flag-service unreachable yields the configured fail-safe default | US-FFG-001/002 · FR-FFG-001/002 |
integration (fault injection) | P0 |
Priority key. P0 — launch-blocking; runs in every CI pipeline and in regression. P1 — V1 must-have behaviour but lower blast radius; runs in CI and in pre-release regression.
Suite completeness note. The 22 cases above are the representative spine. The full test-management catalogue derives at least one
TC-<EPIC>-<nnn>-<nn>per Acceptance Criterion across E1–E17 (per the PRD's per-epic AC counts), giving an estimated 200+ automated cases at V1 launch, grown incrementally per phase. Coverage of[M]ACs is the launch-readiness exit criterion (§1.2).
10. Localization & RTL Testing
Localization is a first-class test concern, not a final-pass check, because SITP serves three statutory-provincial languages with two of them right-to-left. This section operationalizes NFR-I18N-001…006.
10.1 Automated (every PR)
| Check | Tool | Gate |
|---|---|---|
| Locale-catalog key parity (EN ↔ UR ↔ SD) | locale-diff |
Build fails on any missing key in UR or SD |
| No hardcoded user-facing strings | eslint-plugin-react-intl |
Build fails on a hardcoded string in a user-facing component (NFR-I18N-003) |
| Glossary conformance | custom check against _glossary.md |
Warn → fail on second consecutive release if drift unresolved (NFR-I18N-006) |
| Dual calendar (Gregorian + Hijri) rendering | unit test on the date formatter | Fail if a date-bearing screen renders only one calendar (NFR-I18N-005) |
10.2 Visual (per release)
- Playwright screenshot diff for the top 20 pages, captured in all three locales and in both directions (LTR for EN, RTL for UR/SD). Pixel drift beyond tolerance requires reviewer approval.
- Mirror checks for RTL: navigation, iconography, breadcrumb order, table column order, modal close-button placement, and chart axis direction all mirror correctly. Logical CSS properties (
padding-inline-start, etc.) are used exclusively — inline direction hacks are linted out (NFR-I18N-002). - Font rendering verified for Noto Nastaliq Urdu and Noto Naskh Arabic at the brand type sizes.
10.3 Manual (per release)
- Linguistic review by an approved Urdu reviewer and an approved Sindhi reviewer for the changed screens, logged against the glossary.
- Search-quality spot check in UR and SD (Meilisearch script handling) against the multilingual corpus.
11. Accessibility Testing
Accessibility is statutory-adjacent for a government service and is locked at WCAG 2.1 Level AA across all three languages (_context.md §2). This section operationalizes NFR-A11Y-001…004.
11.1 Automated (every PR)
- axe-core (via
@axe-core/playwright) on the top 20 pages — zero critical violations is a hard gate. - Pa11y additionally scans the Docusaurus docs site.
- Lighthouse CI accessibility category ≥ 90 on the top 10 pages; trend tracked per build.
- Colour-contrast unit test on the brand-token palette (Ajrak indigo/maroon) at all text sizes —
4.5:1normal,3:1large (NFR-A11Y-004).
11.2 Manual (per release)
- Keyboard-only walkthrough of every critical journey: visible focus indicator, logical tab order, no keyboard traps, skip-to-content link present (
NFR-A11Y-003). - Screen-reader pass with NVDA + Firefox, JAWS + Edge, VoiceOver + Safari/iOS, TalkBack + Android on the critical journeys; ARIA semantics verified on dynamic regions (ticket threads, dashboards, chat) (
NFR-A11Y-002). - Defects triaged by severity; WCAG-failures block release.
11.3 Phase-2 (deferred, tracked)
Pakistan Sign Language sign-video guides (NFR-A11Y-005) and the dyslexia-friendly + voice-navigation mode (NFR-A11Y-006) are Phase-2 and have their own release gate; they are not V1 blockers.
12. Security Testing
Security testing verifies NFR-SEC-001…013 and the control catalogue in /specs/en/11-security-compliance/. It combines continuous automation with independent expert review.
12.1 Continuous (CI/nightly)
| Check | Tool | Cadence | Gate |
|---|---|---|---|
| SCA (dependencies, base images) | Snyk / Trivy | every build + nightly | critical (CVSS ≥ 9) blocks; high within 30 d (NFR-SEC-011) |
| Secrets in repo/images | gitleaks / trufflehog | every PR | any finding blocks (NFR-SEC-006) |
| DAST baseline | OWASP ZAP | nightly | critical/high findings block release (NFR-SEC-001/008) |
| Secure HTTP headers | Mozilla Observatory / header check | every release | target grade A (NFR-SEC-010) |
| TLS configuration | SSL Labs monitor | continuous | A or A+ (NFR-SEC-002) |
| Upload anti-malware | ClamAV worker metrics; seeded EICAR test | quarterly | zero infected files released (NFR-SEC-012) |
12.2 Authorization matrix tests (automated)
A parameterized test matrix exercises every role × every sensitive action, asserting allow/deny matches the permission matrix in /specs/en/04-roles-permissions/. Roles: company Primary/Admin/Filer/Viewer/Notify; government Section Staff/Officer/Dept Admin/DG/Secretary/Super Admin; public visitor. Actions: read ticket, write comment, transition status, close VIP, export PII, change Primary Rep, toggle feature flag, read audit log, etc. Any mismatch blocks the build.
12.3 ABAC confidential/VIP tests (automated, 100 % gate)
The confidential/VIP access check (§5.1) is exercised with a dedicated case matrix: every staff role with and without the matching attribute, in list view, search results, direct URL access, and API call. The expected outcome is deny + log for the non-matching case; visibility must be zero (no leakage via counts, search suggestions, or audit reads by the denied party).
12.4 Independent pen-test (per-release gate)
An independent external penetration test (NFR-SEC-007) is required before public go-live, annually thereafter, and after any security-sensitive change. Scope:
- The portal, the API, the WebSocket gateway, the AI service, and the docs site.
- Authentication, session, and step-up flows (Keycloak).
- File upload/download (ClamAV bypass attempts, path traversal).
- PII redaction boundary (attempt to force a cloud AI call on a Restricted class).
- Webhook signing and replay.
- IDOR / horizontal privilege escalation across companies and departments.
- Rate-limiting and brute-force resistance on login/OTP/tracking-ID lookup.
Critical findings remediated within 30 days, high within 60; closure evidence reviewed at the phase gate. The pen-test report is the primary evidence for ASVS L2 conformance (NFR-SEC-001).
13. Performance & Load Testing
Performance targets are quantified in NFR-PERF-001…011; this section states how they are verified. All performance tests run against the staging environment that mirrors production topology (NFR-PORT-001) at realistic cardinality (§7.4).
13.1 Target summary (from doc 03)
| Concern | Target | NFR |
|---|---|---|
| API read p95 | ≤ 300 ms | PERF-001 |
| API write p95 | ≤ 800 ms (excl. async AI/OCR) | PERF-002 |
| LCP (top 10 pages, 4G mobile) | ≤ 2.5 s | PERF-003 |
| AI summary p95 | ≤ 15 s | PERF-004 |
| OCR per page p95 | ≤ 30 s cloud / ≤ 60 s on-prem | PERF-005 |
| Chat message e2e p95 | ≤ 500 ms single-instance / ≤ 800 ms cross-instance | PERF-006 |
| DB query p95 | ≤ 100 ms; slow-query threshold 500 ms | PERF-007 |
| Concurrent users | 5,000 authenticated, ≤ 1 % 5xx [TBD/confirm] |
PERF-008 |
| Search p95 (top 10 shapes, 3 scripts) | ≤ 250 ms | PERF-010 |
| Notification fan-out p95 | ≤ 30 s immediate / ≤ 5 min digest | PERF-011 |
13.2 k6 scenarios
- Smoke — per release; 50 virtual users, 5 min; top read/write paths; sanity.
- Load — per release; ramp to the V1 concurrency target (
PERF-008) and hold 30 min; assert p95 latency targets and ≤ 1 % 5xx. - Soak — per release + on-demand; 110 % of target for 60 min; detect memory leaks, connection-pool exhaustion, queue backlog growth (
PERF-008measurement method). - Spike — on-demand; 2× target in < 30 s; verify circuit breakers and graceful degradation hold (
NFR-AVAIL-003). - Multilingual search — quarterly; the 100-query EN/UR/SD suite against Meilisearch (
PERF-010).
13.3 AI/OCR timeout and graceful degradation
- AI summary and OCR jobs are asserted to respect their p95 ceilings (
PERF-004/005) and to time out cleanly — a stalled engine must not block the request path (the queue-leveled architecture,NFR-SCAL-002). - Fault-injection suite (per release): each external dependency (AI provider, OCR engine, NADRA/SECP/FBR/SRB/PSEB/e-Office, Mailjet/SMS/WhatsApp) is killed in turn; the critical user journeys (file, track, comment, resolve, close) must still pass, with the dependent capability visibly marked "temporarily unavailable" (
NFR-AVAIL-003,NFR-RELY-001).
14. Regression Strategy
Regression protects the behaviours that already work while new code ships. SITP regression is risk-weighted, not "run everything always".
| Suite | Trigger | Contents |
|---|---|---|
| Per-PR regression | every pull request | Unit + integration + e2e smoke (EN, top journeys) + the P0 TCs from §9 |
| Nightly regression | nightly on main |
Full e2e across all three locales + LTR/RTL, ZAP DAST, contract tests |
| Pre-release regression | each release candidate | Nightly suite + k6 load + accessibility audit + the full §9 catalogue (P0 + P1) |
| Impact-based subset | selected automatically by changed-module analysis | Tests tagged to the touched module(s) and their dependents run first; full suite runs as backstop |
Tagging. Every test is tagged with: module code (e.g., TKT, ORG), priority (P0/P1/P2), locale (EN/UR/SD), direction (LTR/RTL), and the originating US-/FR- IDs. This enables fast, targeted regression on hotfix branches.
Bisection. A regression that lands in main is bisectable because the nightly suite gives a per-commit green/red signal; the offending commit is reverted within the same business day for P0 regressions.
15. UAT Plan
User Acceptance Testing is where the pilot departments and a cohort of IT companies confirm the system works for real work, not just for the test suite. UAT is the human gate before each phase goes live (per /specs/en/14-roadmap-release/).
15.1 Pilot structure
| Pilot | Participants | Scope | Duration | Exit owner |
|---|---|---|---|---|
| Pilot 1 — S&ITD internal | S&ITD facilitation desk staff (5–10) | Ticket lifecycle end-to-end on internal-only tickets | 2 weeks | S&ITD Secretary |
| Pilot 2 — Single department | One line department (e.g., Labour or SRB) + 5 IT companies | Real tickets from real companies against a real department | 4 weeks | Concerned Dept Secretary + S&ITD |
| Pilot 3 — Multi-department | 3–5 departments + 20 IT companies | Full tripartite flow incl. TRI meeting + MoM | 4 weeks | S&ITD Secretary |
| Pilot 4 — Public launch ramp | Open beta to all registered companies | Volume, channel mix, AI features under real load | 2 weeks | S&ITD Secretary + MAAHIR |
15.2 UAT entry criteria
- Pre-release regression (§14) green.
- Pilot data seeded; pilot users trained (per Epic E15 training).
- Known defects at or below the threshold in §16 (no open P0; ≤ 5 open P1).
- UAT scripts (per pilot) reviewed by the pilot lead.
15.3 UAT exit criteria (sign-off)
- 100 % of in-scope
[M]Acceptance Criteria demonstrated passing to the pilot. - System Usability Scale (SUS) ≥ 70 per pilot cohort, per language (
NFR-USA-006). - CSAT on pilot tickets collected and reviewed.
- No open P0 defects; open P1 defects have an accepted remediation plan with a date.
- Signed UAT report from the pilot department Secretary and S&ITD.
15.4 Feedback loop
Pilot findings flow into the defect tracker (§16) with a uat- label; patterns (e.g., recurring confusion in a flow) feed back into /specs/en/10-ux-sitemap-flows/ and the KB/SOPs (Epic E10).
16. Defect Management
| Severity | Definition | Target resolution | Release impact |
|---|---|---|---|
| P0 — Critical | Core journey blocked; data loss; security/privacy breach; money/SLA exposure | Same business day; hotfix | Blocks release |
| P1 — High | Major feature broken with no workaround, or wrong behaviour on a [M] AC |
Within 1 sprint | Blocks release unless accepted with a plan |
| P2 — Medium | Feature broken with a workaround, or wrong behaviour on a [S]/[C] AC |
Within 2 sprints | Release at lead's discretion |
| P3 — Low | Cosmetic, minor UX, documentation | Backlog | No release impact |
Workflow. Every defect is logged with: reproducible steps, expected vs actual, environment, locale, the failing TC- (or "no TC" → triggers a new TC), severity, and the trace_id from the staging/production log. Defects are triaged daily during UAT and weekly otherwise. A defect that required a code change must add or update a Test Case that would have caught it — closing the loop and growing the regression suite (NFR-RELY-004 mindset).
Flakiness policy. A flaky test is a defect. It is quarantined within one occurrence and either fixed (deterministic) or rewritten within one sprint; it does not linger as a known-unstable gate.
17. Traceability
Traceability is bidirectional and is the audit evidence that every shipped capability is verified and every test exists for a documented reason. The chain is:
FR (
FR-<MOD>-<nnn>) → US (US-<EPIC>-<nnn>) → AC (GherkinScenario) → TC (TC-<EPIC>-<nnn>-<nn>) → Test layer + NFR target.
17.1 Representative traceability extract
| FR | US | AC (Scenario) | TC | Layer | NFR |
|---|---|---|---|---|---|
FR-TKT-001/002/004 |
US-TKT-001 |
Successful submission generates a meaningful tracking ID | TC-TKT-001-01 |
integration + e2e | PERF-002 |
FR-TKT-013/014 |
US-TKT-006 |
Resolution requires evidence and a note | TC-TKT-006-01 |
unit + integration | AUD-001 |
FR-TKT-015 |
US-TKT-006 |
Auto-close after CSAT window | TC-TKT-006-02 |
integration | PERF-011 |
FR-TKT-015/016 |
US-TKT-006 |
Company rejects / appeals | TC-TKT-006-03 |
integration + e2e | — |
FR-ORG-006/007 |
US-ORG-005 |
Oversight roles notified per escalation tier | TC-ORG-005-01 |
unit + integration | PERF-011 |
FR-ORG-010 |
US-ORG-007 |
Confidential/VIP enforces attribute-based access | TC-ORG-007-01 |
integration + e2e | AUD-004, PRIV-003 |
FR-NOT-003 |
US-NOT-003 |
Email reply appends to ticket | TC-NOT-003-01 |
integration | SEC-009 |
FR-AI-002/003 |
US-TKT-002/US-AI-002 |
AI suggests routing with confidence; override logged | TC-TKT-002-01 |
integration | OBS-007 |
FR-AI-001 |
US-AI-001 |
OCR extracts text in each script | TC-AI-001-01 |
integration | PERF-005 |
FR-AI-012 |
US-AI-006/US-MTG-003/004 |
MoM upload yields structured action items | TC-AI-006-01 |
integration + e2e | PERF-004/005 |
FR-MTG-015/018 |
US-MTG-005 |
Sensitive MoM requires approval | TC-MTG-005-01 |
integration | AUD-004 |
FR-FILE-003 |
US-FILE-002 |
Infected file quarantined | TC-FILE-002-01 |
integration | SEC-012 |
FR-INT-001 |
US-INT-001 |
NADRA outage degrades gracefully | TC-INT-001-01 |
integration | RELY-001/003 |
FR-INT-004 |
US-INT-004 |
OIDC SSO + step-up 2FA | TC-INT-004-01 |
integration + e2e | SEC-004/005 |
FR-DOC-011 |
US-DOC-003 |
QR verification rejects tampered letter | TC-DOC-003-01 |
integration + e2e | — |
FR-TRN-006 |
US-TRN-002 |
Exam-gate blocks live assignment | TC-TRN-002-01 |
integration | — |
FR-FFG-001/002 |
US-FFG-001/002 |
Flag disable + fail-safe default | TC-FFG-001-01 |
integration | AVAIL-003 |
FR-PUB-001/002 |
US-PUB-001 |
All public pages in 3 locales + RTL | TC-PUB-001-01 |
e2e + i18n | I18N-001/002 |
17.2 Coverage of acceptance criteria
Launch-readiness requires that every [M] Acceptance Criterion in /specs/en/01-prd/ has at least one passing automated Test Case (§1.2). The QA test-management tool produces a per-release traceability matrix report showing, for each Epic, the ratio of ACs-with-passing-TCs to total ACs; a value below 100 % for [M] ACs blocks the release gate.
17.3 Cross-document references
- Functional requirements:
/specs/en/02-functional-reqs/. - Non-functional targets verified by performance/security/a11y suites:
/specs/en/03-non-functional-reqs/. - Ticket workflow and state transitions under test:
/specs/en/06-ticket-workflow/. - Security control catalogue verified by §12:
/specs/en/11-security-compliance/. - Adapter mocks for integration tests:
/specs/en/08-integrations-spec/. - API/Webhook contracts for contract tests:
/specs/en/12-api-contract/.
18. RACI Summary
| Activity | Responsible | Accountable | Consulted | Informed |
|---|---|---|---|---|
| Unit & integration suites | MAAHIR engineering | MAAHIR QA lead | S&ITD product | S&ITD Secretary |
| e2e + performance + a11y automation | MAAHIR QA | MAAHIR QA lead | Engineering, UX | S&ITD |
| Independent pen-test | External security firm | S&ITD Secretary | MAAHIR, Server4Sale | CII/CERT-PK liaison |
| Manual a11y / screen-reader audit | MAAHIR QA + a11y consultant | MAAHIR QA lead | UX | S&ITD |
| Linguistic review (UR/SD) | Approved reviewers | S&ITD product | MAAHIR | — |
| UAT execution | Pilot dept staff + IT companies | Pilot dept Secretary | MAAHIR QA | S&ITD Secretary |
| Defect triage | MAAHIR QA lead | MAAHIR delivery lead | Engineering | S&ITD product |
| Release sign-off | MAAHIR delivery lead | S&ITD Secretary | All above | Public (status page) |
19. Phase Alignment
This strategy is applied incrementally per the roadmap in /specs/en/14-roadmap-release/:
| Phase | Test focus |
|---|---|
| Phase 0 — discovery | Wire the foundations: unit/integration harness, coverage gate, CI gates, locale-diff, axe/Pa11y, SCA/secrets |
| Phase 1 — MVP core | Full unit + integration + e2e for E1–E4 + E7; accessibility; i18n (EN+UR+SD); security automation; Pilot 1–2 |
| Phase 2 — AI + Sindhi + SLA | AI/OCR suite, performance (PERF-004/005/006), reliability/fault-injection, mutation testing, Pilot 3 |
| Phase 3 — appeal, integrations, security | Adapter integration tests, full pen-test, contract tests, Pilot 4 / public ramp |
| Phase 4 — mobile, advanced | PWA offline tests, mobile device matrix, Compose→K8s tabletop |
20. Open Items [TBD/confirm]
| Item | Owner | Decision needed by |
|---|---|---|
| Test-management tool selection (TestRail vs Zephyr Scale) | MAAHIR QA lead | Phase-0 gate |
| Mutation testing (Stryker) inclusion scope | MAAHIR engineering | Phase-2 gate |
| Anonymized-production-sample pipeline for performance tests | MAAHIR ops + S&ITD | Phase-2 gate |
| Independent pen-test vendor selection | S&ITD Secretary | Phase-1 gate |
| UAT pilot department identities (Pilot 2–4) | S&ITD product | Phase-1 gate |
These items are tracked to closure in /specs/en/14-roadmap-release/ and reflected back into this document as the decisions land.
End of document.