Repository navigation
Commit 999c651
easonLiangWorldedtech
test(types): cover the persisted view-state record at the schema boundary
The pre-merge review asked for focused coverage of the new runtime schema
behaviour: viewStateSchema and the viewStates record on globalSettingsSchema
were only exercised through the webview layer.
Six tests, one per behaviour the record has to guarantee:
- a valid record preserves mode, currentApiConfigName and updatedAt for every
instance, because a selection the schema drops is written back as absent and
the next window opens in the default mode;
- the record is parsed standalone through the exported schema as well;
- a numeric mode, a non-string config name and a non-numeric timestamp are each
rejected, and each negative test parses the same record without the bad field
first, so a failure can only mean the schema rejected that value - not that
the record shape is unsupported or the assertion never ran;
- a view state that is not an object is rejected, which is what a half-migrated
store looks like.
Negative controls, mutant restored from a byte snapshot (sha256 869345626629):
mode accepts anything -> 1 red; config name accepts anything -> 1 red;
timestamp accepts anything -> 1 red; record value becomes any -> 4 red;
the viewStates key removed -> 5 red; the view state gains a required field ->
6 red. The single-test controls are the three "accepts anything" mutants.
Verification: vitest on this spec 12 passed; tsc --noEmit -p packages/types run as
an A/B on the same tree (with the file and at HEAD) - both 0 errors, error sets
identical by name. Prettier was checked through --stdin-filepath with LF
normalisation because this worktree has core.autocrlf=true, where a direct local
prettier verdict is unreliable in both directions; the added lines are clean and
the diff is purely additive (67 added, 0 deleted, no end-of-line flip).1 parent 0861907 commit 999c651
1 file changed
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 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 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
0 commit comments