@@ -201,3 +201,82 @@ describe("Workflow UUIDs", () => {
201201 expect ( workflow1 . _id ) . to . equal ( workflow2 . _id ) ;
202202 } ) ;
203203} ) ;
204+
205+ describe ( "subworkflow uniqueFlowchartIds" , ( ) => {
206+ it ( "should append suffix to flowchart IDs when uniqueFlowchartIds is true" , ( ) => {
207+ const workflowData = {
208+ name : "Test Workflow" ,
209+ units : [
210+ {
211+ name : "average_electrostatic_potential_via_band_structure" ,
212+ type : "subworkflow" ,
213+ uniqueFlowchartIds : true ,
214+ } ,
215+ ] ,
216+ } ;
217+
218+ const workflow = createWorkflow ( {
219+ appName : "espresso" ,
220+ workflowData,
221+ workflowSubworkflowMapByApplication,
222+ workflowCls : Workflow ,
223+ SubworkflowCls : Subworkflow ,
224+ UnitFactoryCls : UnitFactory ,
225+ unitBuilders : builders ,
226+ } ) ;
227+
228+ const subworkflowUnit = workflow . subworkflows [ 0 ] ;
229+
230+ // Check that explicit flowchart IDs have suffix (units at index 2 and 7)
231+ expect ( subworkflowUnit . units [ 2 ] . flowchartId ) . to . equal (
232+ "pw-bands-calculate-band-gap-right-1" ,
233+ ) ;
234+ expect ( subworkflowUnit . units [ 7 ] . flowchartId ) . to . equal (
235+ "average-electrostatic-potential-right-1" ,
236+ ) ;
237+ } ) ;
238+
239+ it ( "should use different suffixes for multiple subworkflow instances" , ( ) => {
240+ const workflowData = {
241+ name : "Test Workflow" ,
242+ units : [
243+ {
244+ name : "average_electrostatic_potential_via_band_structure" ,
245+ type : "subworkflow" ,
246+ uniqueFlowchartIds : true ,
247+ } ,
248+ {
249+ name : "average_electrostatic_potential_via_band_structure" ,
250+ type : "subworkflow" ,
251+ uniqueFlowchartIds : true ,
252+ } ,
253+ ] ,
254+ } ;
255+
256+ const workflow = createWorkflow ( {
257+ appName : "espresso" ,
258+ workflowData,
259+ workflowSubworkflowMapByApplication,
260+ workflowCls : Workflow ,
261+ SubworkflowCls : Subworkflow ,
262+ UnitFactoryCls : UnitFactory ,
263+ unitBuilders : builders ,
264+ } ) ;
265+
266+ // First subworkflow should have -1 suffix
267+ expect ( workflow . subworkflows [ 0 ] . units [ 2 ] . flowchartId ) . to . equal (
268+ "pw-bands-calculate-band-gap-right-1" ,
269+ ) ;
270+ expect ( workflow . subworkflows [ 0 ] . units [ 7 ] . flowchartId ) . to . equal (
271+ "average-electrostatic-potential-right-1" ,
272+ ) ;
273+
274+ // Second subworkflow should have -2 suffix
275+ expect ( workflow . subworkflows [ 1 ] . units [ 2 ] . flowchartId ) . to . equal (
276+ "pw-bands-calculate-band-gap-right-2" ,
277+ ) ;
278+ expect ( workflow . subworkflows [ 1 ] . units [ 7 ] . flowchartId ) . to . equal (
279+ "average-electrostatic-potential-right-2" ,
280+ ) ;
281+ } ) ;
282+ } ) ;
0 commit comments