diablo2-web/TEST_INFRA.md

59 lines
7.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# E2E Test Infrastructure — Diablo II: Lord of Destruction v1.13c Player Skill System (`diablo2-web`)
## 1. Purpose & Opaque-Box Ground Truth Philosophy
This document defines the requirement-driven, 4-tier End-to-End (E2E) test infrastructure for the Diablo II: Lord of Destruction v1.13c player skill system in `diablo2-web`.
Every expected value in `tests/e2e-skills-113c/*.test.ts` is derived from the **authoritative 1.13c ground truth stack** in `/usr/local/google/home/taodao/d2-data`:
1. **MPQ Archive Overlay Stack** (`src/mpq/mount.ts`):
- `d2data.mpq` (`267,642,202` bytes) — Base classic tables & sprites.
- `d2char.mpq` (`269,965,091` bytes) — Base 5-class (`AM`, `SO`, `NE`, `PA`, `BA`) composite character COF/DCC animations.
- `d2exp.mpq` (`250,156,780` bytes) — Lord of Destruction expansion assets (`DZ` Druid, `AI` Assassin, `NE` expansion COFs), `data\global\excel\HitClass.txt`, and `data\global\AnimData.d2` (`570,304` bytes, `256` hash buckets, `3,558` 160-byte records).
- `Patch_D2.mpq` (`3,912,204` bytes) — Highest-priority v1.13c patch override tables (`Skills.txt`, `SkillDesc.txt`, `Missiles.txt`, `States.txt`, `ItemStatCost.txt`, `CharStats.txt`, `MonStats.txt`, `MonStats2.txt`, `Overlay.txt`, `PetType.txt`, `ElemTypes.txt`, `Events.txt`, `SkillCalc.txt`, `MissCalc.txt`).
2. **1.13c Binary Ground Truth Rules (`D2Common.dll`, `D2Game.dll`, `patch.txt`)**:
- Whenever 1.10 (D2MOO) differs from 1.13c, the 1.13c MPQ data and 1.13c binary behavior take absolute precedence (e.g., Blessed Hammer `ID 112` does **not** ignore Magic Resistance of Undead/Demons; Corpse Explosion `ID 74` scales at `70%–120%` base monster HP; Venom `ID 278` clamps poison duration to `10` frames; `blvl` synergy evaluation strictly uses base allocated `STAT_SKILLPTS` only, preventing the 1.10 Marrowwalk charge bug; Conviction `ID 123` and Lower Resist `ID 91` operate at `1/5` efficiency when target resistance $\ge 100\%$).
---
## 2. Test Suite Execution & Directory Layout
### Runner Command
```bash
npx vitest run tests/e2e-skills-113c/
```
### Suite Files (`tests/e2e-skills-113c/`)
| File | Tier | Minimum Required | Implemented Tests | Scope |
|---|---|---:|---:|---|
| `tests/e2e-skills-113c/tier1-feature-coverage.test.ts` | **Tier 1: Feature Coverage** | `>= 55` (`>= 5` / feature) | **60** | Happy-path & 1.13c parity verification across all 11 features in `PROJECT.md § Feature Inventory` and all 221 player skills (`11` universal + `210` class skills across 7 classes + `17` pet/trap sub-skills). |
| `tests/e2e-skills-113c/tier2-boundary-corner.test.ts` | **Tier 2: Boundary & Corner Cases** | `>= 55` (`>= 5` / feature) | **56** | Boundary `slvl` (`0, 1, 8, 9, 16, 17, 20, 22, 23, 28, 29, 60, 99`), division-by-zero, unclosed `(` in `Fire Wall`, undefined `par34` in `Bone Wall`, `*12`/`*16` in `royalstrikechainlightning`, two-dot `sklvl()`, Marrowwalk charge synergy rejection, `STATE_ATTRACT` overwrite immunity, `99%` vs `100%` vs `130%` immunity breaking, Blessed Hammer vs `100%` Magic Immune Undead/Demon, Venom `10f` clamp, trap `5 -> 6` FIFO eviction, golem/wolf group replacement. |
| `tests/e2e-skills-113c/tier3-cross-feature-combinations.test.ts` | **Tier 3: Cross-Feature Combinations** | `>= 15` | **16** | Multi-subsystem pairwise interactions: Aura + Mastery + Synergy + Conviction immunity break + `-Enemy Res`; Assassin 3-charge `Tiger`/`Cobra`/`Phoenix Strike` + `Dragon Talon`/`Dragon Tail` finishers; Necromancer `Corpse Explosion` + `Amplify Damage` + `Lower Resist`; Druid `Werebear` + `Maul` + `Shock Wave` + `Oak Sage`; Sorceress `Energy Shield` + `Telekinesis` synergy + `Frozen Armor` reactive `auraeventfunc`. |
| `tests/e2e-skills-113c/tier4-real-world-scenarios.test.ts` | **Tier 4: Real-World Scenarios** | `>= 10` | **12** | End-to-end multi-tick combat & arena simulations for all 7 classes (Amazon, Sorceress, Necromancer, Paladin, Barbarian, Druid, Assassin), Universal skills, Summon/Trap pet AI loops, `window.__d2webArena` URL harness contract, Gitea Milestone/221-Issue mapping (`src/data/gitea-skill-issues.json`), and repository/worktree cleanliness invariants. |
| **Total** | **Tiers 1–4** | **`>= 135`** | **144** | Complete opaque-box 1.13c E2E verification. |
---
## 3. Feature-to-Test Coverage Matrix (`PROJECT.md § Feature Inventory`)
| Feature # | Feature Name | Milestone | Tier 1 Tests (`tier1-feature-coverage.test.ts`) | Tier 2 Tests (`tier2-boundary-corner.test.ts`) | Tier 3 & Tier 4 Coverage |
|---:|---|---|---:|---:|---|
| **F1** | Worktree & `main` Reconciliation + Ground Truth Stack | M1 | 5 (`F1.1–F1.5`) | 5 (`F1.B1–F1.B5`) | Tier 4 `S11` (Worktree & Repo State) |
| **F2** | 1.13c MPQ Data Registry (`D2DataRegistry`) | M1 | 6 (`F2.1–F2.6`) | 5 (`F2.B1–F2.B5`) | Tier 3 `C1–C16`, Tier 4 `S1–S10` |
| **F3** | `D2Common` `calc` AST Formula Evaluator | M1 | 6 (`F3.1–F3.6`) | 6 (`F3.B1–F3.B6`) | Tier 3 `C1–C16` |
| **F4** | `UnitStatList` & `StateBus` (`HitShift=8`, Curses, Auras) | M1 | 5 (`F4.1–F4.5`) | 5 (`F4.B1–F4.B5`) | Tier 3 `C3, C4, C7, C9, C13` |
| **F5** | 1.13c `RollToHit` & `SUnitDmg` Combat Pipeline | M1 | 6 (`F5.1–F5.6`) | 5 (`F5.B1–F5.B5`) | Tier 3 `C1, C2, C5, C6, C8, C10` |
| **F6** | `AnimData.d2` Dispatcher, `MissileEngine`, `AuraScanner`, `SummonManager` | M1 | 6 (`F6.1–F6.6`) | 5 (`F6.B1–F6.B5`) | Tier 3 `C11, C12, C14, C15` |
| **F7** | 7-Class DCC/COF/Missile/Overlay Renderer & Deterministic Arena (`?arena=1`) | M1 | 5 (`F7.1–F7.5`) | 5 (`F7.B1–F7.B5`) | Tier 4 `S1–S7, S9` |
| **F8** | Gitea Milestone & 221 Per-Skill Tracking Issues | M2 | 5 (`F8.1–F8.5`) | 5 (`F8.B1–F8.B5`) | Tier 4 `S10` |
| **F9** | R3 Cohort A: Universal (11), Amazon (30), Sorceress (30), Necromancer (30) Skills (`101` skills) | M3 | 6 (`F9.1–F9.6`) | 5 (`F9.B1–F9.B5`) | Tier 3 `C1–C5`, Tier 4 `S1–S3, S8` |
| **F10** | R3 Cohort B: Paladin (30), Barbarian (30), Druid (30), Assassin (30) Skills (`120` skills) | M4 | 5 (`F10.1–F10.5`) | 5 (`F10.B1–F10.B5`) | Tier 3 `C6–C16`, Tier 4 `S4–S7` |
| **F11** | Final E2E Test Pass, `SkillModule` Registry & Cleanliness Audit | M5 | 5 (`F11.1–F11.5`) | 5 (`F11.B1–F11.B5`) | Tier 4 `S10–S12` |
---
## 4. Contract Binding & Progressive Verification Architecture
Each E2E test file binds to:
1. **Live 1.13c MPQ Ground Truth (`/usr/local/google/home/taodao/d2-data`)**:
- Directly mounts `d2data.mpq`, `d2char.mpq`, `d2exp.mpq`, and `Patch_D2.mpq` via `MountedArchives` (`src/mpq/mount.ts`) and parses the authoritative 1.13c tables (`Skills.txt`, `SkillDesc.txt`, `Missiles.txt`, `States.txt`, `ItemStatCost.txt`, `CharStats.txt`, `MonStats.txt`, `Overlay.txt`, `PetType.txt`, `ElemTypes.txt`, `HitClass.txt`, `Events.txt`, `SkillCalc.txt`, `MissCalc.txt`, and `AnimData.d2`).
2. **Engine & Skill Module Contracts (`PROJECT.md § Interface Contracts`)**:
- Dynamically loads `src/game/engine/*` (`data-registry.ts`, `calc-ast.ts`, `stat-list.ts`, `state-bus.ts`, `combat-pipeline.ts`, `anim-dispatcher.ts`, `missile-engine.ts`, `aura-scanner.ts`, `summon-manager.ts`, `world-arena.ts`), `src/game/skills/registry.ts`, and `src/data/gitea-skill-issues.json` when available, cross-checking their outputs against the 1.13c MPQ ground-truth oracle.