Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit f47a448

Browse files
Kerry Changstarpit
authored andcommitted
fixes and tests to prevent dragging on a node to trigger a clicking behavior
1 parent 8fd96f7 commit f47a448

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

app/plugins/modules/wskflow/lib/graph2doms.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function graph2doms(JSONgraph, ifReuseContainer, activations){
8686
.on("zoom", redraw);
8787

8888
let containerElement,
89-
wskflowContainer = $('<div id="wskflowContainer"></div>');
89+
wskflowContainer = $('<div id="wskflowContainer"></div>'),
90+
enterClickMode = false;
9091

9192
if(ifReuseContainer && $(`#${containerId}`).length>0){
9293
containerElement = $(`#${containerId}`);
@@ -727,7 +728,12 @@ function graph2doms(JSONgraph, ifReuseContainer, activations){
727728
$(".link").removeClass("hover");
728729
$("#qtip").removeClass("visible");
729730

731+
}).on('mousedown', () => {
732+
enterClickMode = true;
730733
}).on("click", function(d, i){
734+
if(!enterClickMode) return;
735+
enterClickMode = false;
736+
731737
if(activations){
732738
if(d.visited){
733739
if($("#actList").css("display") != "block"){
@@ -1219,6 +1225,7 @@ function graph2doms(JSONgraph, ifReuseContainer, activations){
12191225
customZoom = true
12201226
notify()
12211227
}
1228+
enterClickMode = false;
12221229
container.attr('transform', `translate(${d3.event.translate}) scale(${d3.event.scale})`);
12231230
$("#qtip").removeClass("visible")
12241231
}

tests/tests/passes/07/wskflow-tests.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe('create a if composition, invoke, verify session flow is shown correctl
133133
.then(sidecar.expectShowing(appName))
134134
.catch(common.oops(this)))
135135

136-
it(`should invoke ${appName} with condition equals true, and get the output {path: true}`, () => cli.do(`app invoke ${appName} -p condition true`, this.app)
136+
it(`should invoke ${appName} with condition equals true`, () => cli.do(`app invoke ${appName} -p condition true`, this.app)
137137
.then(cli.expectOK)
138138
.then(sidecar.expectOpen)
139139
.catch(common.oops(this)))
@@ -148,7 +148,7 @@ describe('create a if composition, invoke, verify session flow is shown correctl
148148
.then(verifyNodeStatusExists('p=>({path:false})', 'not-run'))
149149
.catch(common.oops(this)))
150150

151-
it(`should invoke ${appName} with condition equals false, and get the output {path: false}`, () => cli.do(`app invoke ${appName} -p condition false`, this.app)
151+
it(`should invoke ${appName} with condition equals false`, () => cli.do(`app invoke ${appName} -p condition false`, this.app)
152152
.then(cli.expectOK)
153153
.then(sidecar.expectOpen)
154154
.catch(common.oops(this)))
@@ -165,3 +165,46 @@ describe('create a if composition, invoke, verify session flow is shown correctl
165165
.catch(common.oops(this)))
166166

167167
});
168+
169+
// test if mousedown on a node, drag and release triggers the clicking behavior of the node (it shouldn't)
170+
describe('test if pressing a node, dragging and releasing triggers the clicking behavior of the node (it shouldn not)', function() {
171+
before(common.before(this))
172+
after(common.after(this))
173+
174+
const appName = 'test-if', appFile = 'data/composer-source/if-session.js';
175+
it('should have an active repl', () => this.app.client.waitForText('#openwhisk-api-host', 60000))
176+
177+
it(`should create an app with ${appFile}`, () => cli.do(`app create ${appName} ${appFile}`, this.app)
178+
.then(cli.expectOK)
179+
.then(sidecar.expectOpen)
180+
.then(sidecar.expectShowing(appName))
181+
.catch(common.oops(this)))
182+
183+
it(`should invoke ${appName} with condition equals true`, () => cli.do(`app invoke ${appName} -p condition true`, this.app)
184+
.then(cli.expectOK)
185+
.then(sidecar.expectOpen)
186+
.catch(common.oops(this)))
187+
188+
it(`should be able to click on the mode button to switch to session flow`, () => this.app.client.click(ui.selectors.SIDECAR_MODE_BUTTON('visualization'))
189+
.then(() => this.app)
190+
.then(sidecar.expectOpen)
191+
.then(sidecar.expectShowing(appName))
192+
.then(app => app.client.waitForExist('#wskflowSVG', 5000))
193+
.then(() => this.app)
194+
.then(verifyNodeStatusExists('Exit', 'success'))
195+
.catch(common.oops(this)))
196+
197+
it(`should press, drag and release exist node and still stay at session flow`, () => this.app.client.moveToObject('#Exit')
198+
.then(() => this.app.client.buttonDown())
199+
.then(() => this.app.client.moveToObject('#wskflowSVG'))
200+
.then(() => this.app.client.buttonUp())
201+
.then(() => this.app.client.getText('.sidecar-header-icon'))
202+
.then(text => assert.equal(text, 'SESSION'))
203+
.catch(common.oops(this)))
204+
205+
it(`should click on the exit node and go to the activation`, () => this.app.client.click('#Exit')
206+
.then(() => this.app.client.getText('.sidecar-header-icon'))
207+
.then(text => assert.equal(text, 'ACTIVATION'))
208+
.catch(common.oops(this)))
209+
210+
});

0 commit comments

Comments
 (0)