@@ -456,8 +456,11 @@ class TutorialBase {
456456 }
457457 }
458458
459- async waitAndClick ( osparcTestId ) {
460- await utils . waitAndClick ( this . __page , `[osparc-test-id=${ osparcTestId } ]` ) ;
459+ async waitAndClick ( osparcTestId , page ) {
460+ if ( page === undefined ) {
461+ page = this . __page ;
462+ }
463+ await utils . waitAndClick ( page , `[osparc-test-id=${ osparcTestId } ]` ) ;
461464 }
462465
463466 async closeNodeFiles ( ) {
@@ -607,8 +610,8 @@ class TutorialBase {
607610
608611 // do some basic interaction
609612 const s4lIframe = await this . getIframe ( s4lNodeId ) ;
610- const modelTree = await s4lIframe . $ ( '.model- tree' ) ;
611- const modelItems = await modelTree . $$ ( '.MuiTreeItem-label' ) ;
613+ await this . waitAndClick ( ' tree-model' , s4lIframe ) ;
614+ const modelItems = await s4lIframe . $$ ( '.MuiTreeItem-label' ) ;
612615 const nLabels = modelItems . length ;
613616 if ( nLabels > 1 ) {
614617 modelItems [ 0 ] . click ( ) ;
@@ -620,6 +623,53 @@ class TutorialBase {
620623 }
621624 }
622625
626+ async testS4LDipole ( s4lNodeId ) {
627+ await this . waitFor ( 20000 , 'Wait for the splash screen to disappear' ) ;
628+
629+ const s4lIframe = await this . getIframe ( s4lNodeId ) ;
630+ await this . waitAndClick ( 'mode-button-modeling' , s4lIframe ) ;
631+ await this . waitAndClick ( 'tree-model' , s4lIframe ) ;
632+ await this . waitFor ( 2000 , 'Model Mode clicked' ) ;
633+ await this . takeScreenshot ( "Model" ) ;
634+ const modelItems = await s4lIframe . $$ ( '.MuiTreeItem-label' ) ;
635+ console . log ( "N items in model tree:" , modelItems . length / 2 ) ; // there are 2 trees
636+
637+ await this . waitAndClick ( 'mode-button-simulation' , s4lIframe ) ;
638+ await this . waitFor ( 2000 , 'Simulation Mode clicked' ) ;
639+ await this . takeScreenshot ( "Simulation" ) ;
640+
641+ // click on simulation root element
642+ const simulationsItems = await s4lIframe . $$ ( '.MuiTreeItem-label' ) ;
643+ simulationsItems [ 0 ] . click ( ) ;
644+ await this . waitFor ( 2000 , '1st item in Simulation Tree clicked' ) ;
645+ await this . waitAndClick ( 'toolbar-tool-UpdateGrid' , s4lIframe ) ;
646+ await this . waitFor ( 2000 , 'Updating grid...' ) ;
647+ await this . waitAndClick ( 'toolbar-tool-CreateVoxels' , s4lIframe ) ;
648+ await this . waitFor ( 2000 , 'Creating voxels...' ) ;
649+ await this . takeScreenshot ( "Creating voxels" ) ;
650+ const runButtons1 = await s4lIframe . $$ ( '[osparc-test-id="toolbar-tool-Run"' ) ;
651+ await runButtons1 [ 0 ] . click ( ) ;
652+ const runButtons2 = await s4lIframe . $$ ( '[osparc-test-id="toolbar-tool-Run"' ) ;
653+ await runButtons2 [ 1 ] . click ( ) ;
654+ await this . waitFor ( 2000 , 'Running simulation...' ) ;
655+ await this . takeScreenshot ( "Running simulation" ) ;
656+
657+ // HACK: we need to switch modes to trigger the load of the postpro tree item
658+ const simulationPostproSwitchTries = 100 ;
659+ for ( let i = 0 ; i < simulationPostproSwitchTries ; i ++ ) {
660+ await this . waitFor ( 2000 , 'Waiting for results' ) ;
661+ await this . waitAndClick ( 'mode-button-postro' , s4lIframe ) ;
662+ await this . takeScreenshot ( "Postpro" ) ;
663+ const treeAlgItems = await utils . getVisibleChildrenIDs ( s4lIframe , '[osparc-test-id="tree-algorithm' ) ;
664+ if ( treeAlgItems . length ) {
665+ await this . waitFor ( 2000 , 'Results found' ) ;
666+ await this . takeScreenshot ( "Results found" ) ;
667+ break ;
668+ }
669+ await this . waitAndClick ( 'mode-button-simulation' , s4lIframe ) ;
670+ }
671+ }
672+
623673 async takeScreenshot ( screenshotTitle ) {
624674 // Generates an URL that points to the backend logs at this time
625675 const snapshotUrl = utils . getGrayLogSnapshotUrl ( this . __url , 30 ) ;
@@ -638,8 +688,8 @@ class TutorialBase {
638688 return this . __failed ;
639689 }
640690
641- async setTutorialFailed ( failed ) {
642- if ( failed ) {
691+ async setTutorialFailed ( failed , loggerScreenshot = true ) {
692+ if ( failed && loggerScreenshot ) {
643693 await this . takeLoggerScreenshot ( ) ;
644694 }
645695 this . __failed = failed ;
0 commit comments