Commit 1515843
authored
test(behavior): document-api locked SDT mutations (SD-3144) (#3291)
* fix(content-controls): mutate locked SDTs via AttrSteps and inner-range writes (SD-3123)
Per ECMA-376, sdtLocked protects the SDT wrapper from removal but the content
stays editable. Before this fix, programmatic mutations flowed through
editor.commands.updateStructuredContentById, which dispatches
tr.replaceWith(pos, pos + node.nodeSize, ...) spanning the entire SDT. The
structured-content lock plugin's filterTransaction reads that as wrapper
damage and silently filters the transaction on sdtLocked controls -
producing false-success no-ops on operations the API allows (text.setValue,
replaceContent, appendContent, prependContent, setLockMode).
Two engine changes:
- applyAttrsUpdate (sdt-properties-write.ts) - switch from
editor.commands.updateStructuredContentById to per-key tr.setNodeAttribute.
AttrSteps have no from/to range and are explicitly skipped by the lock
plugin's filterTransaction. This is the path that patch, setLockMode,
patchRawProperties, setType, and the date/binding/multiline family use.
- replaceSdtTextContent (content-controls-wrappers.ts) - replace the SDT's
inner content range (pos+1 to pos+nodeSize-1) instead of rewriting the
whole wrapper. The lock plugin classifies inner-range steps as
wouldModifyContent: allowed on sdtLocked, still blocked on contentLocked
/ sdtContentLocked (both per spec).
The search in applyAttrsUpdate uses SDT_NODE_NAMES (imported from
target-resolution.ts) so it resolves the same nodes the upstream
resolveSdtByTarget would resolve. documentSection / documentPartObject are
intentionally excluded - they have their own write paths and could collide
on id.
No changes to API-level lock guards (assertNotSdtLocked on patch, setType,
setBinding, etc.) - relaxing those is a separate behavior decision and out
of scope here.
Tests:
- 4 new regression tests for sdtLocked (setLockMode, text.setValue,
text.clearValue, replaceContent) that assert the actual inner-range
positions (pos+1, pos+nodeSize-1), not just call counts.
- 11 existing tests migrated from "expect updateStructuredContentById
called" to "expect tr.setNodeAttribute / tr.replaceWith / tr.delete".
- 19 metadata-mutation operations added to CC_DIRECT_DISPATCH_OPS in
conformance (no synthetic-failure mode after this refactor, matching the
existing precedent for wrap/unwrap/etc.).
All pass: 46 wrappers + 1170 conformance + 104 SDT-adjacent + 1398
document-api. Zero new TypeScript errors.
Related: SD-3131, SD-3139, IT-1046.
* test(content-controls): add clearContent sdtLocked regression test (SD-3123)
* test(behavior): document-api locked SDT mutations (SD-3144)
Real-editor regression coverage for SD-3123 (#3287). The engine fix was
verified at the unit-test level (mock transaction shapes: AttrSteps for
metadata, inner-range ReplaceSteps for content), but mocks don't run the
real structured-content lock plugin's filterTransaction. This spec closes
that gap by exercising the customer surface (editor.doc.contentControls.*)
in a real browser with the real lock plugin loaded.
Five tests:
- text.setValue updates an sdtLocked inline plain-text control
- replaceContent updates an sdtLocked block rich-text control
- clearContent empties an sdtLocked block control (wrapper preserved)
- round-trip sdtLocked → unlocked → text.setValue (lockMode AttrStep writes)
- contentLocked + text.setValue returns LOCK_VIOLATION (API guard fires)
Lives in tests/behavior/tests/sdt/document-api-locked-mutations.spec.ts.
Does NOT un-fixme the older sdt-lock-modes.spec.ts (different concern —
that one exercises editor.commands.*, SD-3123 is about the Document API).
5/5 pass on chromium. Stacked on SD-3123 (#3287).1 parent cf75357 commit 1515843
1 file changed
Lines changed: 235 additions & 0 deletions
Lines changed: 235 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 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 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
0 commit comments