|
| 1 | +# Palette Contract Tests Validation |
| 2 | + |
| 3 | +PR: PR_26152_070-palette-contract-tests |
| 4 | +Date: 2026-06-02 |
| 5 | + |
| 6 | +## Scope |
| 7 | + |
| 8 | +- Added reusable Palette contract data under `src/shared/contracts/paletteContract.js`. |
| 9 | +- Added Palette fixtures under `tests/fixtures/palettes/palette-scenarios.json`. |
| 10 | +- Added targeted contract tests under `tests/shared/PaletteContract.test.mjs`. |
| 11 | +- No database implementation was added. |
| 12 | +- No authentication implementation was added. |
| 13 | +- No UI/page/runtime behavior was changed. |
| 14 | +- No CSS or HTML files were changed. |
| 15 | +- No dependencies were added. |
| 16 | + |
| 17 | +## Contract Coverage |
| 18 | + |
| 19 | +Targeted tests prove: |
| 20 | + |
| 21 | +- palette records require owner |
| 22 | +- palette records require project |
| 23 | +- palette records require valid swatches |
| 24 | +- palette records may link to source tool state |
| 25 | +- visibility rules are enforced |
| 26 | +- exported palettes remain portable |
| 27 | +- archived palettes are immutable unless policy allows edits |
| 28 | +- version must be valid |
| 29 | + |
| 30 | +The Palette contract defines: |
| 31 | + |
| 32 | +- `paletteId` |
| 33 | +- `ownerId` |
| 34 | +- `projectId` |
| 35 | +- `sourceToolState` |
| 36 | +- `visibility` |
| 37 | +- `version` |
| 38 | +- `status` |
| 39 | +- `swatches` |
| 40 | +- `exportFormats` |
| 41 | + |
| 42 | +## Validation Lanes |
| 43 | + |
| 44 | +- lanes executed: contract - Palette contract tests plus existing Vector Asset, Tool State, Project, and Identity/Permissions contract tests were required by the PR. |
| 45 | +- lanes skipped: runtime, integration, engine, recovery/UAT - no runtime, handoff, engine, or recovery behavior changed. |
| 46 | +- samples decision: SKIP because samples were explicitly out of scope and no sample contracts or runtime paths changed. |
| 47 | +- Playwright impacted: No. This PR changes contract data and targeted Node tests only. |
| 48 | +- blocker scope: targeted contract lane only. |
| 49 | + |
| 50 | +## Commands |
| 51 | + |
| 52 | +```powershell |
| 53 | +node ./scripts/run-node-test-files.mjs tests/shared/PaletteContract.test.mjs tests/shared/VectorAssetContract.test.mjs tests/shared/ToolStateContract.test.mjs tests/shared/ProjectContract.test.mjs tests/shared/IdentityPermissionsContract.test.mjs |
| 54 | +``` |
| 55 | + |
| 56 | +Result: PASS |
| 57 | + |
| 58 | +```text |
| 59 | +PASS tests/shared/PaletteContract.test.mjs |
| 60 | +PASS tests/shared/VectorAssetContract.test.mjs |
| 61 | +PASS tests/shared/ToolStateContract.test.mjs |
| 62 | +PASS tests/shared/ProjectContract.test.mjs |
| 63 | +PASS tests/shared/IdentityPermissionsContract.test.mjs |
| 64 | +
|
| 65 | +5/5 targeted node test file(s) passed. |
| 66 | +``` |
| 67 | + |
| 68 | +```powershell |
| 69 | +git diff --check -- src/shared/contracts/paletteContract.js tests/shared/PaletteContract.test.mjs tests/fixtures/palettes/palette-scenarios.json |
| 70 | +``` |
| 71 | + |
| 72 | +Result: PASS with no output. |
| 73 | + |
| 74 | +## Expected PASS Behavior |
| 75 | + |
| 76 | +- Valid palette fixtures pass without errors. |
| 77 | +- Invalid palette fixtures return the exact expected contract error codes. |
| 78 | +- Owner/project/visibility/version/export format requirements are enforced. |
| 79 | +- Swatches are required as an array, and provided swatches require valid `hex` and `name` fields. |
| 80 | +- Empty swatch arrays remain valid for current Workspace palette baseline compatibility. |
| 81 | +- Source tool state links are allowed when they identify tool state, tool type, and matching project. |
| 82 | +- Private palettes deny ungranted viewers and allow granted project viewers. |
| 83 | +- Collaborators can edit granted active project palettes. |
| 84 | +- Viewers cannot edit palettes. |
| 85 | +- Marketplace palettes are visible. |
| 86 | +- Archived palettes reject edits unless policy explicitly allows archived edits. |
| 87 | +- Portable palette exports preserve portable fields and remove owner/project/database identifiers. |
| 88 | + |
| 89 | +## Expected WARN Behavior |
| 90 | + |
| 91 | +- No WARN findings for the targeted contract lane. |
| 92 | +- Repo-wide, samples, UI, CSS, HTML, database, and authentication validation were intentionally not run because they are outside this PR scope. |
0 commit comments