1. Inside your harness, in any section add a button control and give any Test ID (like I have used "ScreenLoadModalButton"). Then add an event as Click and action as Launch Action. Mention the flow action which will be shown as modal popup on the screen. Make Visibility of the button as Never and Reserve space when hidden as checked. Else you can use visibility:hidden; to make it not visible on screen.
2. Create a js file with the following piece of code:
For me it is working perfectly. Can you share the screenshot of your section where you have configured the modal and also the area in the harness where you have placed this section.
Also, are you testing the output from the Developer id? or any id other than Developer. With Developer id I meant id having SysAdm4 role in it. If you test from id having SysAdm4 role in it this should work. Operator ids not having SysAdm4 role will not give the desired output since they don't have pxTestID privilege in their ARO. To make this functionality work in ids other than developer add the pxTestID privilege to the ARO in their role. Then this should start working.
I have exactly the same configuration and no issue for me. I would suggest you to check few things:
1. Make the button visible always. Afterwards you can hide the layout in which it is present by giving the container format of the layout as Hidden. But, first check with visibility as Always.
2. After launching the portal, check the console if there is an error in executing the script. If there is no error and the script got executed successfully then check if the DOM element button is present with data-test-id attribute. Screenshot attached. Make sure this attribute value is same as that present in the script.
I am also sharing the screenshot of my configuration. Hope that helps.