@suffolklitlab/alkiln 5.10.1 → 5.10.3

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 CHANGED
@@ -45,6 +45,22 @@ Format:
45
45
 
46
46
  <!-- ## [Unreleased] -->
47
47
 
48
+ ## [5.10.3] - 2024-03-23
49
+
50
+ ### Fixed
51
+
52
+ - Fixes undefined var name when setting long text or ajax combobox value
53
+
54
+ ### Internal
55
+
56
+ - Removes test for text on error pages. That keeps changing every now and then. It would be nice to test that we're catching some text, which we can't do right now. Maybe we should be broader with where we get the text since authors can also change the DOM. At least there are screenshots when possible.
57
+
58
+ ## [5.10.2] - 2024-02-29
59
+
60
+ ### Fixed
61
+
62
+ - Fixed dates only being part-way filled.
63
+
48
64
  ## [5.10.1] - 2024-02-23
49
65
 
50
66
  ### 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
- // Set text in some kind of field (input text, input date, textarea, etc.)
1979
- // First set the value to part of the string
1980
- const to_set = answer.slice(0, -3);
1981
- const to_type = answer.slice(-3);
1982
- await handle.evaluate(( elem, text ) => {
1983
- elem.value = text;
1984
- }, to_set );
1985
- // Then type the last three characters of the string with a
1986
- // good pause to let the field register the interaction
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 = text.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
- await handle.type( to_type, { delay: 100 });
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 ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.10.1",
3
+ "version": "5.10.3",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {