@suffolklitlab/alkiln 5.10.0 → 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 CHANGED
@@ -45,6 +45,18 @@ Format:
45
45
 
46
46
  <!-- ## [Unreleased] -->
47
47
 
48
+ ## [5.10.2] - 2024-02-29
49
+
50
+ ### Fixed
51
+
52
+ - Fixed dates only being part-way filled.
53
+
54
+ ## [5.10.1] - 2024-02-23
55
+
56
+ ### Changed
57
+
58
+ - Fixes the issue that typing is too fast for some fields, like Ajax comboboxes. See [#857](https://github.com/SuffolkLITLab/ALKiln/issues/857).
59
+
48
60
  ## [5.10.0] - 2024-02-22
49
61
 
50
62
  ### Added
@@ -62,7 +74,7 @@ Format:
62
74
 
63
75
  - Handle non-existence of `elem` more robustly when checking for `elem.disabled`
64
76
  - Add a pause between pull request tests and push tests when the PR is coming from our own repo
65
- - Make getting page field values more robust by doing more to ensure that undefined values don't cause errors
77
+ - Make getting page field values more robust by doing more to ensure that undefined option `value`s don't cause errors. For example, ajax combobox `select` options don't always have `value`s
66
78
 
67
79
  ## [5.9.0] - 2024-02-11
68
80
 
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,12 +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
- await handle.evaluate( el => { el.value = '' });
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.
1980
1995
  await handle.focus();
1981
- let delay = 0;
1982
- if ( session_vars.get_debug() ) { delay = 25; }
1983
- await handle.type( answer, { delay });
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
+ }
1984
2006
  },
1985
2007
 
1986
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.0",
3
+ "version": "5.10.2",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {