# ScaleGraphics — manual acceptance (DOM-touching code)

ExtendScript cannot be unit-tested in a host. The pure logic
(namematch / worklist filter / scale math / manifest) is covered by the Node
mirror harness (`node jsx/ScalaTools/tests/run-node.js`) and the in-host
`tests/inhost/*.assert.jsx` parity scripts. Everything that touches the live
InDesign DOM — pool selection by scope, the `transform()`/`fit()` calls, the
`doScript`/`scriptPreferences` wrapping, and the ScriptUI dialog — is verified by
the **numbered procedures below**, run against the fixture `.indd`.

> These procedures have NOT been executed by the implementer (no InDesign in CI).
> They are the executable spec for whoever runs the acceptance pass on real hosts.

## Fixture: `scalegraphics-fixture.indd` (build once, commit the `.indd`)

Page 1 contains:
- `equ001.eps`, `equ002.eps` — MathType EPS, normal links.
- `fig001.tif` — a non-`equ` **Image**-type link.
- one **embedded/pasted** image (`itemLink == null`).
- `equ003.eps` on a **LOCKED LAYER**.
- `equ004.eps` in a **LOCKED FRAME**.
- `equ005.eps` with a **MISSING** link (delete the relink target after placing).

## Acceptance matrix (target: identical observed behavior in every row)

| Host (version)      | OS       | Preview=2? | Scale+undo atomic? | prefs.version restored? | Tester | Date |
|---------------------|----------|------------|--------------------|-------------------------|--------|------|
| InDesign CS6 (8.0)  | macOS    |            |                    |                         |        |      |
| InDesign CS6 (8.0)  | Windows  |            |                    |                         |        |      |
| InDesign 2020 (15)  | macOS    |            |                    |                         |        |      |
| InDesign 2020 (15)  | Windows  |            |                    |                         |        |      |
| InDesign 2025 (20)  | macOS    |            |                    |                         |        |      |
| InDesign 2025 (20)  | Windows  |            |                    |                         |        |      |

---

## Procedure A — Worklist scope + guards (Task 1.2)

1. Open the fixture in the target InDesign (run on **each** of: CS6, the oldest
   available CC, and the latest — Win and Mac).
2. Scripts panel → run `01_ScaleGraphics.jsx`. Set Scope = Whole document,
   Pattern = `equ`, Mode = Prefix, Ignore case ON, Limit-to-Images OFF,
   click **Preview count**.
3. **Expected:** count = **2** (equ001, equ002). The locked-layer, locked-frame,
   missing-link, embedded, and `fig` items are excluded; the skip line shows
   `name 1, no-link 1, unavailable 1, locked 2, type 0`.
4. Repeat with Scope = Selection after selecting only `equ001.eps` → count = **1**.
5. Repeat with Pattern = `` (empty) and Limit-to-Images ON → only the
   embedded/`fig` **Image**-type items count; every EPS is excluded
   (verifies the type filter).
6. Record host version + OS + observed counts in the matrix above.

## Procedure B — Scaling transform + atomic undo (Task 1.3)

1. Run `01_ScaleGraphics.jsx`. Scope = document, Pattern = `equ`, Scale H = 50,
   V = 50, Lock ON, Offset 0/0, Relative to = Center, Location = Page,
   Fitting = None, Apply to = Frame. OK → confirm → Yes.
2. **Expected:** equ001 + equ002 each shrink to 50% about their own centers (the
   formula center stays put); `fig001` and the locked/missing items are untouched.
   A single Cmd/Ctrl-Z reverts **both** in one undo step (proves `ENTIRE_SCRIPT`
   atomicity).
3. Re-run with Apply to = Content only, Fitting = Frame to content → the placed
   art scales inside the frame, then the frame fits to the art.
4. Force an error mid-run (e.g. lock a matched frame *after* Preview, or point a
   matched link at a read-only path): the run must abort with a single message and
   leave the document **unchanged** (no half-scaled set) — confirm the undo
   history shows no committed "Scale Graphics" step.
5. After any run, confirm `app.scriptPreferences.version` is back to its pre-run
   value (the script logs the saved/restored value via `$.writeln`; check the
   ExtendScript Toolkit / Console).

## Procedure C — Dialog + entry point end to end (Task 1.4)

1. Scripts panel → double-click `01_ScaleGraphics.jsx` → the dialog appears with
   all panels; the window title reads **`Scale Graphics — ScalaTools 0.1.0`**;
   Vertical % is disabled and mirrors Horizontal (Lock ON by default).
2. **Preview count** with defaults (Pattern `equ`, Prefix, Whole document) →
   `Match count: 2  (skipped: name 1, no-link 1, unavailable 1, locked 2, type 0)`.
3. Set H = 80, OK → confirm dialog shows
   `2 link(s) match 'equ'. Scale by 80% / 80%?` → Yes → `Scaled 2 graphic(s).`
   equ001/equ002 are at 80%; one Cmd/Ctrl-Z reverts both.
4. Uncheck Lock, set H = 120, V = 60 → the V field enables; OK applies the
   non-uniform scale.
5. Mode = Glob, Pattern `equ*.eps` → Preview still 2. Mode = Regex, Pattern `([`
   → Preview 0 (invalid regex safely matches nothing; no crash).
6. Empty pattern + Limit-to-Images ON → only Image-type items are counted.
7. Cancel button → no changes, no error.
8. After every run, the ExtendScript console shows the pin/restore log lines and
   `app.scriptPreferences.version` equals its original value.

Record results per host/OS in the matrix above. Expected: identical behavior on
all six host/OS combinations.
