pdftract/tests/fixtures/profiles/resolution/README.md
jedarden 34c6a3719d feat(bf-2ypn2): add Phase 7 profiles exit gate fixtures
Create test fixture directories and integration tests for Phase 7 profile
validation exit gate:

Invalid profiles (tests/fixtures/profiles/invalid/):
- unknown-key.yaml: unrecognized extraction tuning key
- bad-combinator.yaml: malformed match combinators (scalar not list)
- secret-key.yaml: forbidden api_key (PROFILE_SECRETS_FORBIDDEN)
- malformed.yaml: unclosed bracket (YAML syntax error)

Valid profiles (tests/fixtures/profiles/valid/):
- minimal.yaml: smallest valid profile (name, description, priority only)
- invoice-minimal.yaml: simplified invoice with match and extraction

Resolution fixtures (tests/fixtures/profiles/resolution/):
- custom-invoice.yaml: priority 100 overrides built-in (priority 50)
- README.md: documents resolution priority order

Integration tests (tests/integration/advanced/profiles.rs):
- test_invalid_profiles_rejected: validates all 4 invalid profiles fail
- test_valid_profiles_accepted: validates all 2 valid profiles pass
- test_profile_resolution_order: tests --profile-dir override behavior
- test_invalid_fixture_error_types: validates specific error messages

Acceptance criteria:
✓ pdftract profiles validate rejects all 4 invalid files
✓ pdftract profiles validate accepts all 2 valid files
✓ Profile resolution order test passes

Closes bf-2ypn2
2026-07-04 23:56:32 -04:00

28 lines
1.1 KiB
Markdown

# Profile Resolution Test Fixtures
This directory tests the profile resolution priority order:
**Priority order (lowest to highest):**
1. Built-in profiles (compiled into binary)
2. System profiles (`/etc/pdftract/profiles/`)
3. User profiles (`~/.config/pdftract/profiles/`)
4. Custom profiles (`--profile-dir` flag, repeatable)
**Test scenarios:**
- `custom-invoice.yaml` - A custom invoice profile with priority 100 that overrides the built-in invoice profile (priority 50)
- Expected: When loaded via `--profile-dir`, the custom profile should take precedence over the built-in one
- Verification: Run `pdftract profiles list` with and without `--profile-dir` to see the override annotation
**Test procedure:**
```bash
# List built-in profiles (should show invoice with priority 50)
pdftract profiles list
# List with custom directory (should show invoice with priority 100 and overrides annotation)
pdftract profiles list --profile-dir tests/fixtures/profiles/resolution
# Validate the custom profile
pdftract profiles validate tests/fixtures/profiles/resolution/custom-invoice.yaml
```