|
| 1 | +import { describe, it, expect } from "vitest"; |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { fileURLToPath } from "node:url"; |
| 4 | +import { dirname, resolve } from "node:path"; |
| 5 | +import { probeMovement } from "../src/index.js"; |
| 6 | + |
| 7 | +const examplesDir = resolve( |
| 8 | + dirname(fileURLToPath(import.meta.url)), |
| 9 | + "../../../spec/examples", |
| 10 | +); |
| 11 | +const load = (name: string): string => |
| 12 | + readFileSync(resolve(examplesDir, `${name}.posecode`), "utf8"); |
| 13 | + |
| 14 | +const footWarnings = (name: string) => |
| 15 | + probeMovement(load(name)).diagnostics.warnings.filter((w) => |
| 16 | + ["heel-height", "toe-height", "sole-angle", "grounding-rom-conflict"].includes(w.kind), |
| 17 | + ); |
| 18 | + |
| 19 | +/** |
| 20 | + * A stance foot in a traveling clip rolls onto its ball as the body passes |
| 21 | + * (push-off) and is briefly airborne at each step transition — correct gait, |
| 22 | + * not a grounding artifact, so it is exempt from the static flat-foot checks. |
| 23 | + * A static clip keeps the strict bar, so genuine heel-lift must still surface. |
| 24 | + */ |
| 25 | +describe("locomotion grounding exemption", () => { |
| 26 | + it("exempts a locomotion stance foot's airborne swing (no large float at a step transition)", () => { |
| 27 | + // Before the fix, box-step's stance pin was measured while it was still |
| 28 | + // descending from the previous phase's swing — a ~0.12m heel float and a |
| 29 | + // ~33° sole tilt mid-transition. The airborne-swing exemption removes those |
| 30 | + // large phase-transition floats (a smaller settling roll may remain). |
| 31 | + const large = footWarnings("box-step").filter( |
| 32 | + (w) => |
| 33 | + (w.kind === "heel-height" && w.value > 0.1) || |
| 34 | + (w.kind === "sole-angle" && w.value > 30), |
| 35 | + ); |
| 36 | + expect(large, large.map((w) => w.detail).join("\n")).toHaveLength(0); |
| 37 | + }); |
| 38 | + |
| 39 | + it("still flags genuine heel-lift in a static deep pose (no over-suppression)", () => { |
| 40 | + // superhero-landing holds a deep static landing whose shin exceeds the ankle |
| 41 | + // dorsiflexion ROM; that heel-lift is a real artifact and must stay flagged. |
| 42 | + const warns = footWarnings("superhero-landing"); |
| 43 | + expect(warns.some((w) => w.kind === "grounding-rom-conflict" || w.kind === "heel-height")).toBe( |
| 44 | + true, |
| 45 | + ); |
| 46 | + }); |
| 47 | +}); |
0 commit comments