@suffolklitlab/alkiln 5.10.1 → 5.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/scope.js +28 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/scope.js
CHANGED
|
@@ -1796,6 +1796,7 @@ module.exports = {
|
|
|
1796
1796
|
await scope.setText( scope, { handle, answer: answer_date });
|
|
1797
1797
|
await handle.press(`Tab`);
|
|
1798
1798
|
await scope.afterStep(scope, { waitForShowIf: true });
|
|
1799
|
+
|
|
1799
1800
|
} else if (type == `time`) {
|
|
1800
1801
|
// Authors should enter the time like 12:34 PM, but we shouldn't type ":", space, or M.
|
|
1801
1802
|
let answer_time = answer.replace(":", "").replace(" ", "").replace("M", "");
|
|
@@ -1864,7 +1865,6 @@ module.exports = {
|
|
|
1864
1865
|
valid_date.getDate().toString().padStart(2, 0) + '/' +
|
|
1865
1866
|
valid_date.getFullYear().toString());
|
|
1866
1867
|
}
|
|
1867
|
-
|
|
1868
1868
|
return valid_date;
|
|
1869
1869
|
}, // Ends scope.today_to_date()
|
|
1870
1870
|
|
|
@@ -1975,17 +1975,34 @@ module.exports = {
|
|
|
1975
1975
|
}, // Ends scope.setCheckbox()
|
|
1976
1976
|
|
|
1977
1977
|
setText: async function ( scope, { handle, answer }) {
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
await handle.evaluate(( elem, text ) => {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1978
|
+
/** Set text in some kind of field (input text, input date, textarea, etc.) */
|
|
1979
|
+
const typing_cutoff = 300;
|
|
1980
|
+
const slice_value = -3;
|
|
1981
|
+
|
|
1982
|
+
let is_ajax = await handle.evaluate(( elem, text, typing_cutoff, slice_value ) => {
|
|
1983
|
+
// For long strings or ajax comboboxes, set the value of the field to
|
|
1984
|
+
// most of the text. This will be faster in those cases.
|
|
1985
|
+
is_ajax = elem.className.includes(`da-ajax-combobox`);
|
|
1986
|
+
|
|
1987
|
+
if ( is_ajax || text.length > typing_cutoff ) {
|
|
1988
|
+
elem.value = answer.slice(0, slice_value); // .slice(0, -3)
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
return is_ajax;
|
|
1992
|
+
}, answer, typing_cutoff, slice_value );
|
|
1993
|
+
|
|
1994
|
+
// Interact like a "human" in all cases.
|
|
1987
1995
|
await handle.focus();
|
|
1988
|
-
|
|
1996
|
+
|
|
1997
|
+
// For long strings or ajax comboboxes, where we have set most of the text
|
|
1998
|
+
// already, add a good pause for the field to detect the interaction.
|
|
1999
|
+
if ( is_ajax || answer.length > typing_cutoff ) {
|
|
2000
|
+
const to_type = answer.slice( slice_value ); // .slice(-3)
|
|
2001
|
+
await handle.type( to_type, { delay: 100 });
|
|
2002
|
+
} else {
|
|
2003
|
+
// Otherwise type the whole string with 0 delay
|
|
2004
|
+
await handle.type( answer );
|
|
2005
|
+
}
|
|
1989
2006
|
},
|
|
1990
2007
|
|
|
1991
2008
|
draw_signature: async function ( scope, name ) {
|