@@ -156,56 +156,34 @@ type ListTargetPreparation = {
156156 target : Record < string , unknown > ;
157157} ;
158158
159+ /**
160+ * Load a pre-separated list fixture (two adjacent lists that share the same
161+ * abstractNumId) and resolve the second list item as the target.
162+ *
163+ * This avoids a runtime `lists separate` → DOCX export → re-import round-trip
164+ * which can lose numbering definition compatibility on some platforms.
165+ */
159166async function prepareSeparatedSecondListTarget (
160167 harness : ConformanceHarness ,
161168 stateDir : string ,
162169 label : string ,
163170) : Promise < ListTargetPreparation > {
164- const sourceDoc = await harness . copyListFixtureDoc ( `${ label } -source` ) ;
171+ const docPath = await harness . copyPreSeparatedListDoc ( label ) ;
172+ const items = await listDiscoveryItems ( harness , stateDir , docPath , 10 ) ;
165173
166- // Discover source items for diagnostics.
167- const sourceItems = await listDiscoveryItems ( harness , stateDir , sourceDoc , 10 ) ;
168- if ( sourceItems . length < 2 ) {
174+ if ( items . length < 2 ) {
169175 throw new Error (
170- `[${ label } ] Source fixture has fewer than 2 list items (found ${ sourceItems . length } ). ` +
171- `Items: ${ JSON . stringify ( sourceItems ) } ` ,
176+ `[${ label } ] Pre-separated fixture has fewer than 2 list items (found ${ items . length } ). ` +
177+ `Items: ${ JSON . stringify ( items ) } ` ,
172178 ) ;
173179 }
174180
175- const secondItem = sourceItems [ 1 ] ?. address ;
176- if ( ! secondItem || typeof secondItem !== 'object' ) {
177- throw new Error ( `[${ label } ] Second list item has no address. Items: ${ JSON . stringify ( sourceItems ) } ` ) ;
181+ const target = items [ 1 ] ?. address ;
182+ if ( ! target || typeof target !== 'object' ) {
183+ throw new Error ( `[${ label } ] Second list item has no address. Items: ${ JSON . stringify ( items ) } ` ) ;
178184 }
179185
180- const separatedDoc = harness . createOutputPath ( `${ label } -separated` ) ;
181- const separated = await harness . runCli (
182- [ 'lists' , 'separate' , sourceDoc , '--target-json' , JSON . stringify ( secondItem ) , '--out' , separatedDoc ] ,
183- stateDir ,
184- ) ;
185- if ( separated . result . code !== 0 || separated . envelope . ok !== true ) {
186- throw new Error (
187- `[${ label } ] lists separate failed. code=${ separated . result . code } ` +
188- `envelope=${ JSON . stringify ( separated . envelope ) } ` +
189- `target=${ JSON . stringify ( secondItem ) } ` +
190- `stderr=${ separated . result . stderr . trim ( ) || '<empty>' } ` ,
191- ) ;
192- }
193-
194- // Re-resolve from the output document (node IDs may change across write/reload).
195- const postItems = await listDiscoveryItems ( harness , stateDir , separatedDoc , 10 ) ;
196- if ( postItems . length < 2 ) {
197- throw new Error (
198- `[${ label } ] Post-separation doc has fewer than 2 list items (found ${ postItems . length } ). ` +
199- `Items: ${ JSON . stringify ( postItems ) } ` ,
200- ) ;
201- }
202-
203- const separatedSecondItem = postItems [ 1 ] ?. address ;
204- if ( ! separatedSecondItem || typeof separatedSecondItem !== 'object' ) {
205- throw new Error ( `[${ label } ] Post-separation second item has no address. Items: ${ JSON . stringify ( postItems ) } ` ) ;
206- }
207-
208- return { docPath : separatedDoc , target : separatedSecondItem } ;
186+ return { docPath, target } ;
209187}
210188
211189function sectionMutationScenario (
0 commit comments