File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ class HTMLIngredient {
166166 id="${ this . id } "
167167 tabindex="${ this . tabIndex } "
168168 arg-name="${ this . name } "
169+ data-target="${ this . target } "
169170 ${ this . disabled ? "disabled" : "" } >` ;
170171 for ( i = 0 ; i < this . value . length ; i ++ ) {
171172 if ( ( m = this . value [ i ] . name . match ( / \[ ( [ a - z 0 - 9 - ( ) ^ ] + ) \] / i) ) ) {
Original file line number Diff line number Diff line change @@ -487,11 +487,19 @@ class RecipeWaiter {
487487 * @param {HTMLElement } op
488488 */
489489 triggerArgEvents ( op ) {
490- // Trigger populateOption and argSelector events
490+ // Trigger argSelector events and populateOption events only where the target is empty.
491+ // When loading a saved recipe, arguments are populated before this method is called, so
492+ // re-triggering populateOption events would overwrite saved custom values with defaults.
493+ const args = op . querySelectorAll ( ".arg" ) ;
491494 const triggerableOptions = op . querySelectorAll ( ".populate-option, .arg-selector" ) ;
492495 const evt = new Event ( "change" , { bubbles : true } ) ;
496+
493497 if ( triggerableOptions . length ) {
494498 for ( const el of triggerableOptions ) {
499+ if ( el . classList . contains ( "populate-option" ) ) {
500+ const target = args [ el . getAttribute ( "data-target" ) ] ;
501+ if ( target && target . value !== "" ) continue ;
502+ }
495503 el . dispatchEvent ( evt ) ;
496504 }
497505 }
Original file line number Diff line number Diff line change 1+ /**
2+ * Regression tests for recipe loading behaviour.
3+ *
4+ * @author CyberChef contributors
5+ * @copyright Crown Copyright
6+ * @license Apache-2.0
7+ */
8+
9+ const utils = require ( "./browserUtils.js" ) ;
10+
11+ module . exports = {
12+ before : browser => {
13+ browser
14+ . resizeWindow ( 1280 , 800 )
15+ . url ( browser . launchUrl )
16+ . useCss ( )
17+ . waitForElementNotPresent ( "#preloader" , 10000 ) ;
18+ } ,
19+
20+ "Recipe load preserves populated arguments" : browser => {
21+ const inputFormat = "HH:mm:ss a MMM DD, YYYY " ;
22+ const input = "10:20:30 pm Sep 26, 2019 " ;
23+
24+ utils . loadRecipe (
25+ browser ,
26+ "Translate DateTime Format" ,
27+ input ,
28+ [
29+ "Standard date and time" ,
30+ inputFormat ,
31+ "UTC" ,
32+ "DD/MM/YYYY HH:mm:ss" ,
33+ "UTC"
34+ ]
35+ ) ;
36+
37+ browser . execute ( ( ) => {
38+ return Array . from ( document . querySelectorAll ( "#rec-list li.operation .arg" ) )
39+ . map ( arg => arg . value ) ;
40+ } , [ ] , function ( { value} ) {
41+ browser . expect ( value [ 1 ] ) . to . equal ( inputFormat ) ;
42+ } ) ;
43+ } ,
44+
45+ after : browser => {
46+ browser . end ( ) ;
47+ }
48+ } ;
You can’t perform that action at this time.
0 commit comments