@@ -232,6 +232,56 @@ const FORMAT_INLINE_ALIAS_SUCCESS_SCENARIOS: Record<
232232 return [ operationId , formatInlineAliasSuccessScenario ( operationId ) ] ;
233233 } ) ,
234234) as Record < FormatInlineAliasCliOperationId , ( harness : ConformanceHarness ) => Promise < ScenarioInvocation > > ;
235+
236+ function paragraphMutationScenario (
237+ operationId : CliOperationId ,
238+ label : string ,
239+ extraArgs : string [ ] ,
240+ prepare : Array < { operationId : CliOperationId ; extraArgs : string [ ] } > = [ ] ,
241+ ) : ( harness : ConformanceHarness ) => Promise < ScenarioInvocation > {
242+ return async ( harness ) => {
243+ const stateDir = await harness . createStateDir ( `${ label } -success` ) ;
244+ let docPath = await harness . copyFixtureDoc ( `${ label } -source` ) ;
245+ let block = await harness . firstBlockMatch ( docPath , stateDir ) ;
246+
247+ for ( let index = 0 ; index < prepare . length ; index += 1 ) {
248+ const step = prepare [ index ] ;
249+ const preparedOut = harness . createOutputPath ( `${ label } -prepare-${ index + 1 } ` ) ;
250+ const prepared = await harness . runCli (
251+ [
252+ ...commandTokens ( step . operationId ) ,
253+ docPath ,
254+ '--target-json' ,
255+ JSON . stringify ( { kind : 'block' , nodeType : 'paragraph' , nodeId : block . nodeId } ) ,
256+ ...step . extraArgs ,
257+ '--out' ,
258+ preparedOut ,
259+ ] ,
260+ stateDir ,
261+ ) ;
262+
263+ if ( prepared . result . code !== 0 || prepared . envelope . ok !== true ) {
264+ throw new Error ( `Failed to prepare paragraph scenario ${ label } with ${ step . operationId } .` ) ;
265+ }
266+
267+ docPath = preparedOut ;
268+ block = await harness . firstBlockMatch ( docPath , stateDir ) ;
269+ }
270+
271+ return {
272+ stateDir,
273+ args : [
274+ ...commandTokens ( operationId ) ,
275+ docPath ,
276+ '--target-json' ,
277+ JSON . stringify ( { kind : 'block' , nodeType : 'paragraph' , nodeId : block . nodeId } ) ,
278+ ...extraArgs ,
279+ '--out' ,
280+ harness . createOutputPath ( `${ label } -output` ) ,
281+ ] ,
282+ } ;
283+ } ;
284+ }
235285// ---------------------------------------------------------------------------
236286// Table scenario helpers (DRY builders for the 40 table operations)
237287// ---------------------------------------------------------------------------
@@ -1143,25 +1193,113 @@ export const SUCCESS_SCENARIOS = {
11431193 } ;
11441194 } ,
11451195 ...FORMAT_INLINE_ALIAS_SUCCESS_SCENARIOS ,
1146- 'doc.format.align' : async ( harness : ConformanceHarness ) : Promise < ScenarioInvocation > => {
1147- const stateDir = await harness . createStateDir ( 'doc-format-align-success' ) ;
1148- const docPath = await harness . copyFixtureDoc ( 'doc-format-align' ) ;
1149- const target = await harness . firstTextRange ( docPath , stateDir ) ;
1150- return {
1151- stateDir,
1152- args : [
1153- 'format' ,
1154- 'align' ,
1155- docPath ,
1156- '--target-json' ,
1157- JSON . stringify ( target ) ,
1158- '--alignment-json' ,
1159- JSON . stringify ( 'center' ) ,
1160- '--out' ,
1161- harness . createOutputPath ( 'doc-format-align-output' ) ,
1162- ] ,
1163- } ;
1164- } ,
1196+ 'doc.styles.paragraph.setStyle' : paragraphMutationScenario ( 'doc.styles.paragraph.setStyle' , 'styles-paragraph-set' , [
1197+ '--style-id' ,
1198+ 'Normal' ,
1199+ ] ) ,
1200+ 'doc.styles.paragraph.clearStyle' : paragraphMutationScenario (
1201+ 'doc.styles.paragraph.clearStyle' ,
1202+ 'styles-paragraph-clear' ,
1203+ [ ] ,
1204+ [ { operationId : 'doc.styles.paragraph.setStyle' , extraArgs : [ '--style-id' , '__ConformanceTmpStyle__' ] } ] ,
1205+ ) ,
1206+ 'doc.format.paragraph.resetDirectFormatting' : paragraphMutationScenario (
1207+ 'doc.format.paragraph.resetDirectFormatting' ,
1208+ 'format-paragraph-reset' ,
1209+ [ ] ,
1210+ ) ,
1211+ 'doc.format.paragraph.setAlignment' : paragraphMutationScenario (
1212+ 'doc.format.paragraph.setAlignment' ,
1213+ 'format-paragraph-set-alignment' ,
1214+ [ '--alignment' , 'center' ] ,
1215+ [ { operationId : 'doc.format.paragraph.setAlignment' , extraArgs : [ '--alignment' , 'left' ] } ] ,
1216+ ) ,
1217+ 'doc.format.paragraph.clearAlignment' : paragraphMutationScenario (
1218+ 'doc.format.paragraph.clearAlignment' ,
1219+ 'format-paragraph-clear-alignment' ,
1220+ [ ] ,
1221+ ) ,
1222+ 'doc.format.paragraph.setIndentation' : paragraphMutationScenario (
1223+ 'doc.format.paragraph.setIndentation' ,
1224+ 'format-paragraph-set-indentation' ,
1225+ [ '--left' , '720' ] ,
1226+ ) ,
1227+ 'doc.format.paragraph.clearIndentation' : paragraphMutationScenario (
1228+ 'doc.format.paragraph.clearIndentation' ,
1229+ 'format-paragraph-clear-indentation' ,
1230+ [ ] ,
1231+ [ { operationId : 'doc.format.paragraph.setIndentation' , extraArgs : [ '--left' , '720' ] } ] ,
1232+ ) ,
1233+ 'doc.format.paragraph.setSpacing' : paragraphMutationScenario (
1234+ 'doc.format.paragraph.setSpacing' ,
1235+ 'format-paragraph-set-spacing' ,
1236+ [ '--before' , '120' , '--after' , '120' ] ,
1237+ ) ,
1238+ 'doc.format.paragraph.clearSpacing' : paragraphMutationScenario (
1239+ 'doc.format.paragraph.clearSpacing' ,
1240+ 'format-paragraph-clear-spacing' ,
1241+ [ ] ,
1242+ [ { operationId : 'doc.format.paragraph.setSpacing' , extraArgs : [ '--before' , '120' , '--after' , '120' ] } ] ,
1243+ ) ,
1244+ 'doc.format.paragraph.setKeepOptions' : paragraphMutationScenario (
1245+ 'doc.format.paragraph.setKeepOptions' ,
1246+ 'format-paragraph-set-keep-options' ,
1247+ [ '--keep-next' , 'true' ] ,
1248+ ) ,
1249+ 'doc.format.paragraph.setOutlineLevel' : paragraphMutationScenario (
1250+ 'doc.format.paragraph.setOutlineLevel' ,
1251+ 'format-paragraph-set-outline' ,
1252+ [ '--outline-level-json' , '1' ] ,
1253+ ) ,
1254+ 'doc.format.paragraph.setFlowOptions' : paragraphMutationScenario (
1255+ 'doc.format.paragraph.setFlowOptions' ,
1256+ 'format-paragraph-set-flow' ,
1257+ [ '--contextual-spacing' , 'true' ] ,
1258+ ) ,
1259+ 'doc.format.paragraph.setTabStop' : paragraphMutationScenario (
1260+ 'doc.format.paragraph.setTabStop' ,
1261+ 'format-paragraph-set-tab-stop' ,
1262+ [ '--position' , '720' , '--alignment' , 'left' ] ,
1263+ ) ,
1264+ 'doc.format.paragraph.clearTabStop' : paragraphMutationScenario (
1265+ 'doc.format.paragraph.clearTabStop' ,
1266+ 'format-paragraph-clear-tab-stop' ,
1267+ [ '--position' , '720' ] ,
1268+ [ { operationId : 'doc.format.paragraph.setTabStop' , extraArgs : [ '--position' , '720' , '--alignment' , 'left' ] } ] ,
1269+ ) ,
1270+ 'doc.format.paragraph.clearAllTabStops' : paragraphMutationScenario (
1271+ 'doc.format.paragraph.clearAllTabStops' ,
1272+ 'format-paragraph-clear-all-tab-stops' ,
1273+ [ ] ,
1274+ [ { operationId : 'doc.format.paragraph.setTabStop' , extraArgs : [ '--position' , '720' , '--alignment' , 'left' ] } ] ,
1275+ ) ,
1276+ 'doc.format.paragraph.setBorder' : paragraphMutationScenario (
1277+ 'doc.format.paragraph.setBorder' ,
1278+ 'format-paragraph-set-border' ,
1279+ [ '--side' , 'top' , '--style' , 'single' , '--color' , '000000' ] ,
1280+ ) ,
1281+ 'doc.format.paragraph.clearBorder' : paragraphMutationScenario (
1282+ 'doc.format.paragraph.clearBorder' ,
1283+ 'format-paragraph-clear-border' ,
1284+ [ '--side' , 'top' ] ,
1285+ [
1286+ {
1287+ operationId : 'doc.format.paragraph.setBorder' ,
1288+ extraArgs : [ '--side' , 'top' , '--style' , 'single' , '--color' , '000000' ] ,
1289+ } ,
1290+ ] ,
1291+ ) ,
1292+ 'doc.format.paragraph.setShading' : paragraphMutationScenario (
1293+ 'doc.format.paragraph.setShading' ,
1294+ 'format-paragraph-set-shading' ,
1295+ [ '--fill' , 'FFFF00' ] ,
1296+ ) ,
1297+ 'doc.format.paragraph.clearShading' : paragraphMutationScenario (
1298+ 'doc.format.paragraph.clearShading' ,
1299+ 'format-paragraph-clear-shading' ,
1300+ [ ] ,
1301+ [ { operationId : 'doc.format.paragraph.setShading' , extraArgs : [ '--fill' , 'FFFF00' ] } ] ,
1302+ ) ,
11651303 'doc.styles.apply' : async ( harness : ConformanceHarness ) : Promise < ScenarioInvocation > => {
11661304 const stateDir = await harness . createStateDir ( 'doc-styles-apply-success' ) ;
11671305 const docPath = await harness . copyFixtureDoc ( 'doc-styles-apply' ) ;
0 commit comments