Commit b943735
authored
test(desktop): validate release arguments against the Electron Builder schema (#168)
## Related Issue
No issue — follow-up hardening for the release failure fixed in #167.
## Problem
The `desktop-v0.2.1` build died at Electron Builder's schema validation
on `--config.win.publisherName`, an option removed in v26. The suite was
green throughout, because `package-win.spec.ts` compared the generated
argument array to a hand-written expected array. Both copies carried the
same mistake, so the test only detected *change*, never *invalidity* —
Google's "change-detector test".
The consequence is structural, not incidental: these arguments are only
emitted when signing secrets are present, so a tag build is the first
time they ever execute. A test that cannot judge them means the release
is the first judge.
## What changed
`package-win.spec.ts` now merges the generated `--config.*` arguments
onto the packaged `build` configuration and validates the result with
Ajv against the installed `app-builder-lib/scheme.json`, using the same
Ajv options `app-builder-lib` itself validates with (`allErrors`,
`verbose`, `coerceTypes`, `strict: false`).
- **No new dependency.** Both `scheme.json` and `ajv` resolve through
the existing `electron-builder` dependency (pnpm hides them from a
direct resolve out of `apps/desktop`, so resolution is anchored at
`require.resolve('electron-builder')`).
- **Follows the installed version.** It reads whatever schema the pinned
Electron Builder ships, so a future major that relocates these options
fails here rather than at a tag.
- Failure output is trimmed to the actionable errors instead of Ajv's
verbose dump.
Three cases: the packaged configuration alone, the configuration each
signing method produces, and a negative case pinning the exact
regression.
## Verification
Mutation-tested, both caught:
| Mutation | Result |
|---|---|
| Reintroduce `--config.win.publisherName` | 3 failed — `Electron
Builder rejects unknown options: /win.publisherName` |
| Drop required `azureSignOptions.certificateProfileName` | 3 failed —
`must have required property 'certificateProfileName'` |
| Restored | 17 passed |
The second case is a class the previous test could not detect at all.
- `pnpm exec vitest run tests/package-win.spec.ts` — 17 passed
- `pnpm run typecheck` (apps/desktop) — clean, both tsconfigs
- `oxlint --type-aware` — 0 warnings, 0 errors
- `scripts/check-no-comments.mjs` — OK
## Checklist
- [x] I have read the CONTRIBUTING document.
- [ ] I have linked a related issue — none; follow-up to #167.
- [x] I have added tests that prove my feature works.
- [x] Ran `gen-changesets` skill, or this PR needs no changeset — no
changeset: test-only, nothing users can perceive.
- [x] Ran `gen-docs` skill, or this PR needs no doc update.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Improved validation of desktop package configurations against the
Electron Builder schema.
* Added coverage for base configurations, signing modes, invalid
options, and removed settings.
* Enhanced error reporting for unknown or invalid configuration values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 78462b0 commit b943735
1 file changed
Lines changed: 71 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 9 | + | |
14 | 10 | | |
15 | 11 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
25 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
52 | 75 | | |
53 | 76 | | |
54 | 77 | | |
| |||
101 | 124 | | |
102 | 125 | | |
103 | 126 | | |
104 | | - | |
| 127 | + | |
105 | 128 | | |
106 | 129 | | |
107 | 130 | | |
108 | 131 | | |
109 | 132 | | |
110 | 133 | | |
111 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
112 | 139 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
116 | 143 | | |
117 | 144 | | |
118 | 145 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
122 | 149 | | |
123 | 150 | | |
124 | 151 | | |
| |||
0 commit comments