-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Conditional Clicking in Broker Protection (#1141)
* First pass at conditional clicking * Add additional tests * Fix linting issues, remove unneeded operators * Fix types for BuildUrl * Minor refactor, add unit tests * Clean-up error reporting and add test * Refactor subactions to run from routing * Refactor click action error workflow * Flip bit back on integration test * Missed conflict resolution * Add collector to integration tests * Missed one * Adopt additional API changes * Lint fixes
- Loading branch information
Showing
17 changed files
with
592 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...tion-test/test-pages/broker-protection/actions/conditional-clicks-hard-coded-default.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "40", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": { | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='No']" } | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
...test/test-pages/broker-protection/actions/conditional-clicks-hard-coded-null-default.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "40", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": null | ||
} | ||
} | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
...tion-test/test-pages/broker-protection/actions/conditional-clicks-hard-coded-success.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "50", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": { | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='No']" } | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
...test-pages/broker-protection/actions/conditional-clicks-hard-coded-undefined-default.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"retry": { | ||
"environment": "web", | ||
"interval": { "ms": 1000 }, | ||
"maxAttempts": 1 | ||
}, | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "40", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
...on-test/test-pages/broker-protection/actions/conditional-clicks-interpolated-default.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "${age}", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": { | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='No']" } | ||
] | ||
} | ||
}, | ||
"data": { | ||
"userProfile": { | ||
"age": "40" | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
33 changes: 33 additions & 0 deletions
33
...on-test/test-pages/broker-protection/actions/conditional-clicks-interpolated-success.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "${age}", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": { | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='No']" } | ||
] | ||
} | ||
}, | ||
"data": { | ||
"userProfile": { | ||
"age": "50" | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
43 changes: 43 additions & 0 deletions
43
...-test/test-pages/broker-protection/actions/expectation-actions-conditional-subaction.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"state": { | ||
"action": { | ||
"actionType": "expectation", | ||
"id": "2", | ||
"expectations": [ | ||
{ | ||
"type": "text", | ||
"selector": "body", | ||
"expect": "How old is John Doe?" | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"actionType": "click", | ||
"id": "1", | ||
"choices": [ | ||
{ | ||
"condition": { | ||
"left": "${age}", | ||
"operation": ">=", | ||
"right": "45" | ||
}, | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='Yes']" } | ||
] | ||
} | ||
], | ||
"default": { | ||
"elements": [ | ||
{ "type": "button", "selector": ".//a[text()='No']" } | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"data": { | ||
"userProfile": { | ||
"age": "40" | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
injected/integration-test/test-pages/broker-protection/pages/conditional-clicks.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Broker Protection</title> | ||
</head> | ||
<body> | ||
<div class="result"> | ||
<h3>Is John Doe over the age of 45?</h3> | ||
<a href="#" class="answer" data-id="yes">Yes</a> | ||
<a href="#" class="answer" data-id="no">No</a> | ||
</div> | ||
<script> | ||
document.querySelectorAll('.answer').forEach(answer => | ||
answer.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
const id = this.getAttribute('data-id'); | ||
|
||
window.location.hash = id; | ||
this.removeEventListener('click', arguments.callee); | ||
}) | ||
); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.