@suffolklitlab/alkiln 5.0.0-pre-8 → 5.0.0-pre-10

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,7 +45,8 @@ Format:
45
45
  be run in any directory, not just in an npm package.
46
46
  - Additional environment variables and their validation to allow for tests that run on a developer's server/Playground instead of through GitHub. Also, other functionality for that purpose. [Issue #661](https://github.com/SuffolkLITLab/ALKiln/issues/661)
47
47
  - Tests for new session_vars behavior and improve previous tests.
48
- - Adds `npm-shrinkwrap.json`, so installs from npm will have fixed version dependencies
48
+ - Adds `npm-shrinkwrap.json`, so installs from npm will have fixed version dependencies.
49
+ - Allow author to specify loops with only `.target_number`. e.g. to leave out `.there_are_any`. See [issue #706](https://github.com/SuffolkLITLab/ALKiln/issues/706) and Story Table documentation in docs folder.
49
50
 
50
51
  ### Changed
51
52
  - BREAKING: the github action no longer runs `npm run XYZ`; it directly calls scripts,
@@ -65,12 +66,16 @@ Format:
65
66
  - Shorten path names to try to accommodate limitations of windows systems while still keeping enough useful information to help devs identify the test outputs. https://github.com/SuffolkLITLab/ALKiln/issues/618
66
67
  - Updated field decoding to handle new object field encoding. See [#711](https://github.com/SuffolkLITLab/ALKiln/issues/711)
67
68
  - Allow multiple languages to be tested again. See [#713](https://github.com/SuffolkLITLab/ALKiln/issues/713).
69
+ - Fill in time fields correctly. See [#726](https://github.com/SuffolkLITLab/ALKiln/pull/726).
70
+ - Allow `.target_number` to be 0. See https://github.com/SuffolkLITLab/ALKiln/issues/706.
71
+ - Use the right number of loops for `.target_number`. See https://github.com/SuffolkLITLab/ALKiln/issues/706.
68
72
 
69
73
  ### Security
70
74
  - Pass docassemble API keys through HTTP headers instead of as parameters.
71
75
  - Parameters to certain HTTP requests are printed directly in docassemble's
72
76
  uWSGI log, leaking API keys to actors with log access on your docassemble
73
77
  server
78
+ - Update dependencies. See [#727](https://github.com/SuffolkLITLab/ALKiln/pull/727).
74
79
 
75
80
  ## [4.11.1] - 2023-03-21
76
81
  ### Changed
@@ -0,0 +1,89 @@
1
+ # Story Tables overview
2
+
3
+ The Story Table is a very flexible tool. It lets the author answer interview (form) questions in any order. They can make cosmetic changes to their interview code without having to change their tests. They can edit the order of their interview's pages, move fields from one page to another, and so on.
4
+
5
+ When the robot arrives on each interview page, it finds all the fields on the page and loops through the whole Story Table trying to match rows with fields.
6
+
7
+ Here's some [documentation on the use of Story Table rows](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/#story-tables).
8
+
9
+ ## Tracking use of rows
10
+
11
+ Why do we track how many times each Story Table row was used to set a form's fields?
12
+
13
+ First, it lets us give the author useful information. We can show the author which rows of their story table were or weren't used. This can help the author tell that some crucial variables aren't being set as they expected. It also outputs a new Story Table for them. If they had a bunch of extra rows adding cruft, like from our [story table generator](https://plocket.github.io/al_story/), it gives the author a table with only the variables that are needed for the test.
14
+
15
+ Second, in some cases we need to actually throw an error if any row was left unused, so we have to keep track of that.
16
+
17
+ Third, looping questions that gather multiple items in a list are tricky when the interview answers need the `.there_is_another` attribute. We can't use that attribute. Instead, we handle all gathering with `target_number` rows. Next we'll discuss what problem the `.there_is_another` attribute creates and our approach to solving it.
18
+
19
+ ## The loop problem
20
+
21
+ Since the Story Table loops through all its rows for each page, each row in the table needs to be unique. That is, you can only set one variable to one value. That's fine most of the time, but when gathering items in a list in a docassemble interview, there are a few ways to do it and one of them sets one variable over and over again - `.there_is_another`. This kind of loop can start with a question that sets `.there_are_any`.
22
+
23
+ For example, look for `.there_is_another` in the scenario below:
24
+
25
+ Page 1: Do you have any moms? (Set `moms.there_are_any` to `True`)
26
+ Page 2: What is your first mom's name? (Set `mom[0].name.first`)
27
+ Page 3: Do you have any other moms? (Set `moms.there_is_another` to `True`)
28
+ Page 4: What is your second mom's name? (Set `mom[1].name.first`)
29
+ Page 5: Do you have any other moms? (Set `moms.there_is_another` to `False`)
30
+
31
+ See that on page 3, `moms.there_is_another` is set to `True` and on page 5 it's set to `False`. We can't represent this in a Story Table.
32
+
33
+ ```
34
+ | x.there_is_another | True | moms.there_is_another |
35
+ ```
36
+
37
+ The above will always say that we have another `mom`. If we allowed our users to do that, it would create an infinite loop. So we prevent our users from creating a `there_is_another` row that has a value of `True`. We still need to allow them to set `.there_is_another`, though, so what do we do?
38
+
39
+ ## The loop solution
40
+
41
+ Well, there's another way to loop to gather items in docassemble - `target_number`. For example:
42
+
43
+ Page 1: How many moms do you have? (Set `moms.target_number` to `2`)
44
+ Page 2: What is your first mom's name? (Set `mom[0].name.first`)
45
+ Page 3: What is your second mom's name? (Set `mom[1].name.first`)
46
+
47
+ The target number row looks like this:
48
+
49
+ ```
50
+ | x.target_number | 2 | moms.target_number |
51
+ ```
52
+
53
+ If authors use `.target_number`, that's no problem at all for our code. We can't require authors to use that method to ask their questions, though. That may make their form questions confusing to their end users sometimes. Fortunately, we _can_ require developers to use `.target_number`[^1] in their Story Tables. We can use a `.target_number` table value to calculate what to answer for `.there_are_any` and to know how many times to set `.there_is_another` to `'True'`.
54
+
55
+ ## The loop architecture
56
+
57
+ First, the very basic flow for setting a variable. Note: whatever Step the dev uses to set a variable's value, we send it to this loop. It may be useful to follow along in the code here.
58
+
59
+ 1. If this isn't a Story Table step, transform the given arguments into a Story Table structure - a list of row objects.
60
+ 2. For each row object (see `scope.normalizeTable()`)
61
+ 1. Create a new object with almost the same properties. It contains the original object in a property called `original` so the original can be used to print stuff for the user's report.
62
+ 2. In this new object, substitute environment variables the author gave into actual values. They may have done this to keep a sensitive value (like a password) secret.
63
+ 3. Add ways to accumulate the number of times the row is used.
64
+ 3. For each page (see `scope.setFields()`)
65
+ 1. Identify and store all the fields on the page and all the variables they set.
66
+ 2. Shallowly clone the Story Table row list.
67
+ 1. Create a new object almost the same as the old object
68
+ 2. Print a warning to the user if they've created a `.there_is_another` row with a value of `'True'` and change that value to `'False'`.
69
+ 3. If there is a `.target_number` row, use it to create new artificial rows for `.there_is_another` and `.there_are_any`.
70
+ 4. This new list will be used to actually put answers into fields.
71
+ 3. For each field on the page
72
+ 1. Find which Story Table row, if any, matches that field.
73
+ 2. Set the field to the given value.
74
+ 3. Increment the row's accumulators.
75
+ 1. Increment the relevant `.used_for['foo']` by 1.
76
+ 2. Increment all relevant `.times_used`[^2] by 1.
77
+ 4. Try to continue.
78
+
79
+ <!-- From feedback, I'm not sure how to clarify this part or if readers will need it
80
+ Why make artificial rows? Well, that way when we loop through to match a page's fields to the variables in the Story Table structure, we don't have to do anything special for these rows. If they're not needed, they won't be triggered.
81
+
82
+ Why not calculate the `.there_are_any` and `.there_is_another` values in the row-matching loop? That's another stylistic choice. There's more logic to the `.there_is_another` value than we've talked about here and that method seems like it would add a lot more cruft and complexity in that match-finding loop. We may eventually change our minds.
83
+ -->
84
+
85
+ ---
86
+
87
+ [^1] Why use `target_number`? We count on our users being at least a bit familiar with docassemble variables and to have access to the docassemble docs, so the `target_number` variable is something they should be able to recognize or easily find information about. We decided to take advantage of that. Also, we chose to avoid 0 indexing so that the number starts at 1 and feels like human language, not computer language as our users are generally more human than computer. It's also the way docassemble does it.
88
+
89
+ [^2] It would seem like the `.times_used` property is redundant, but it has a different purpose that the `.used_for` properties. It lets us show the dev whether the `target_number` table row was used at all during the test to let us give appropriate feedback to the user. We could add up the `used_for` values, but for now we're avoiding doing that extra math and the extra refactoring. The choice has its pros and cons.
package/lib/scope.js CHANGED
@@ -919,15 +919,21 @@ module.exports = {
919
919
  }
920
920
 
921
921
  let result = {
922
- original: row,
922
+ // NOTE: mutating frozen objects will fail silently, so don't mutate this attribute
923
+ original: Object.freeze(row),
924
+ artificial: false,
923
925
  // Give fake data if needed to prevent some kind of hidden input field from being found
924
926
  // See bug at https://github.com/plocket/docassemble-cucumber/issues/79
925
927
  // May be able to remove this once converted to `getAllFields`
926
928
  var: row.var || 'al_no_var_name',
927
929
  value: actual_var_value,
928
930
  trigger: row.trigger || '',
931
+ // This will track how many times total the row or its connected
932
+ // artificial rows are used. Artificial rows are only added for some rows.
929
933
  times_used: 0,
934
+ used_for: {},
930
935
  }
936
+ result.used_for[ result.var ] = 0;
931
937
 
932
938
  supported_table.push( result );
933
939
  }
@@ -1755,6 +1761,13 @@ module.exports = {
1755
1761
  }
1756
1762
  await scope.setText( scope, { handle, answer: answer_date });
1757
1763
  await scope.afterStep(scope, { waitForShowIf: true });
1764
+ } else if (type == `time`) {
1765
+ // Authors should enter the time like 12:34 PM, but we shouldn't type ":", space, or M.
1766
+ let answer_time = answer.replace(":", "").replace(" ", "").replace("M", "");
1767
+ await handle.focus();
1768
+ await handle.type( answer );
1769
+ await handle.press("Enter");
1770
+ await scope.afterStep(scope, { waitForShowIf: true });
1758
1771
  } else {
1759
1772
  await scope.setText( scope, { handle, answer });
1760
1773
  await scope.afterStep(scope, { waitForShowIf: true });
@@ -2017,8 +2030,7 @@ module.exports = {
2017
2030
  });
2018
2031
 
2019
2032
  // Accumulate number of times this row was used. Esp important for `.target_number`
2020
- if ( row_used.source ) { row_used.source.times_used += 1 }
2021
- row_used.times_used += 1;
2033
+ await scope.increment_row_use( scope, { row: row_used });
2022
2034
 
2023
2035
  process.stdout.write(`\x1b[36m${ '*' }\x1b[0m`); // assumes var was set if no error occurred
2024
2036
 
@@ -2043,8 +2055,7 @@ module.exports = {
2043
2055
  });
2044
2056
 
2045
2057
  // Esp important for `.target_number`
2046
- if ( row_used.source ) { row_used.source.times_used += 1 }
2047
- row_used.times_used += 1;
2058
+ await scope.increment_row_use( scope, { row: row_used });
2048
2059
 
2049
2060
  // TODO: special continue/navigation button function that handles url and all?
2050
2061
 
@@ -2131,35 +2142,145 @@ module.exports = {
2131
2142
  // TODO: Maybe we should return something else or something in addition about used vars
2132
2143
  }, // Ends scope.setFields()
2133
2144
 
2134
- // TODO: Move this to under `normalizeTable`
2145
+ increment_row_use: async function ( scope, { row }) {
2146
+ /** Accumulate number of times this row was used. Esp important for `.target_number`.
2147
+ * Mutates `row` and its props. */
2148
+
2149
+ // Increment the number of times a row itself was used.
2150
+ row.times_used += 1;
2151
+
2152
+ // Increment the times a row was used for a particular variable.
2153
+ // TODO: check if we need this initial default assignment.
2154
+ if ( !row.used_for ) { row.used_for = {}; }
2155
+ // TODO: check if we need this initial default assignment.
2156
+ if ( row.used_for[ row.var ] ) {
2157
+ row.used_for[ row.var ] += 1;
2158
+ } else {
2159
+ row.used_for[ row.var ] = 1;
2160
+ }
2161
+
2162
+ // If this is an artificial row, increment its source row as well. This may
2163
+ // be one of multiple artificial rows and the source row will need to be
2164
+ // incremented for each of its artificial rows.
2165
+ // Right now, this is only used for `target_number` rows.
2166
+ if ( row.source ) {
2167
+ // For each artificial row, increment the total number of times its
2168
+ // source row was used.
2169
+ row.source.times_used += 1;
2170
+
2171
+ // Indicate which of the artificial rows was incremented (this one).
2172
+ // TODO: check if we need this initial default assignment.
2173
+ if ( row.source.used_for[ row.var ] ) {
2174
+ row.source.used_for[ row.var ] += 1;
2175
+ } else {
2176
+ row.source.used_for[ row.var ] = 1;
2177
+ }
2178
+ } // ends if there's a source row
2179
+
2180
+ }, // Ends scope.increment_row_use()
2181
+
2182
+
2135
2183
  ensureSpecialRows: async function ( scope, { var_data, from_story_table=true }) {
2136
2184
  /* Given a list of variable data objects, add more objects or mutate
2137
- * rows under special circumstances:
2138
- * - `.target_number` may indicate the need for a `.there_is_another` row.
2139
- * - `.there_is_another` in a table is invalid
2185
+ * row objects under special circumstances:
2186
+ * - `.target_number` will create `.there_are_any` and `.there_is_another` rows.
2187
+ * If they're unused in the end, that's fine.
2188
+ * - `.there_is_another` with a value of True in a Story Table is invalid and
2189
+ * will be neutralized.
2190
+ *
2191
+ * To learn the bigger picture, see "docs/story_tables.md"
2140
2192
  */
2141
- // Add special cases. Do not mutate `var_data` as a list, but
2142
- // do allow mutation of items inside.
2143
2193
  let enhanced_var_data = [...var_data];
2144
2194
  for ( let var_datum of var_data ) {
2145
2195
 
2146
- // Add a `.there_is_another` var if it might be needed.
2147
- // If it's not used in the end, that's fine.
2148
- // `.target_number` is sometimes a stand-in for `.there_is_another`.
2149
- // That seems the clearest way to communicate to developers about what they
2150
- // should write in the test. We will attempt to write more about
2151
- // the rationale in the documentation at some point.
2152
2196
  if ( from_story_table && var_datum.var.match( /\.target_number$/ )) {
2153
- let special_row = {
2154
- artificial: true, // not currently used but is future-proofing to mark non-dev generated rows
2197
+
2198
+ // This is a row created by us, not by the user
2199
+ let artificial = true;
2200
+
2201
+ // Add `.there_are_any` value depending on `.target_number` value.
2202
+ // If the dev has also created a `.there_are_any` row, that will come
2203
+ // first in the table and will be overriden by this later artificial row.
2204
+ // TODO: Document this for devs as this behavior might confuse folks
2205
+ // who accidentally include both and have conflicting values
2206
+ // for each of them.
2207
+ let var_name_any = var_datum.var.replace( /\.target_number$/, `.there_are_any` );
2208
+
2209
+ let there_are_any = {
2210
+ artificial,
2211
+ // For now this is very nested. We may flatten in the future.
2212
+ ...var_datum,
2213
+ // `source` is acting as the accumulator of the row use here
2214
+ source: var_datum,
2215
+ var: var_name_any,
2216
+ // devs are supposed to use the right `trigger` name, but they might not.
2217
+ // Of course, this too might be the wrong trigger name, but there's no way to
2218
+ // know that and it's unlikely.
2219
+ // TODO: Make sure this is documented.
2220
+ trigger: var_datum.trigger.replace( /\.target_number$/, `.there_are_any` ),
2221
+ used_for: {},
2222
+ };
2223
+ there_are_any.used_for[ var_name_any ] = 0;
2224
+
2225
+ // This creation function is run at the beginning of every page.
2226
+ // If this is the first page and the `target_number` source row
2227
+ // has just been created, it won't have this sub-accumulator yet,
2228
+ // so create them. Otherwise, don't override its current value.
2229
+ if ( var_datum.used_for[ var_name_any ] === undefined ) {
2230
+ var_datum.used_for[ var_name_any ] = 0;
2231
+ }
2232
+
2233
+ // If `target_number` is 0, there are none of this item
2234
+ if ( parseInt(var_datum.value) <= 0 ) {
2235
+ there_are_any.value = `False`;
2236
+ // Otherwise, there's at least one item
2237
+ } else if ( parseInt(var_datum.value) > 0 ) {
2238
+ there_are_any.value = `True`;
2239
+ }
2240
+
2241
+ // Now both `.target_number` and `.there_are_any` rows exist if needed
2242
+ enhanced_var_data.push( there_are_any );
2243
+
2244
+ // Add `.there_is_another` value depending on `.target_number` value.
2245
+ // If the dev has also created a `.there_is_another` row, that will come
2246
+ // first in the table and will be overriden by this later artificial row.
2247
+ // The dev will still get a warning at the start of each page that they've
2248
+ // included an invalid `.there_is_another` with a value of `True`.
2249
+ // This row might not be needed if `.target_number` is 0, but for now that
2250
+ // seems like it would add more logic to read.
2251
+ let var_name_another = var_datum.var.replace( /\.target_number$/, `.there_is_another` );
2252
+
2253
+ let there_is_another = {
2254
+ artificial,
2255
+ ...var_datum,
2256
+ // `source` is acting as the accumulator of the row use here
2155
2257
  source: var_datum,
2156
- var: var_datum.var.replace( /\.target_number$/, `.there_is_another` ),
2157
- value: await scope.getThereIsAnotherValue( scope, { row: var_datum, from_story_table }),
2158
- // devs are supposed to use the right `trigger` name, but they might not
2258
+ var: var_name_another,
2259
+ // devs are supposed to use the right `trigger` name, but they might not.
2260
+ // Of course, this too might be the wrong trigger name, but there's no way to
2261
+ // know that and it's unlikely.
2159
2262
  trigger: var_datum.trigger.replace( /\.target_number$/, `.there_is_another` ),
2263
+ used_for: {},
2160
2264
  };
2265
+ there_are_any.used_for[ var_name_another ] = 0;
2266
+
2267
+ // This creation function is run at the beginning of every
2268
+ // page. If this is the first page and the `target_number`
2269
+ // source row has just been created, it won't have these
2270
+ // sub-accumulators yet, so create them.
2271
+ // Otherwise, don't override their current values.
2272
+ if ( var_datum.used_for[ var_name_another ] === undefined ) {
2273
+ var_datum.used_for[ var_name_another ] = 0;
2274
+ }
2275
+
2276
+ // Use those accumulators to get `True` or `False` for `there_is_another`
2277
+ there_is_another.value = await scope.getThereIsAnotherValue(
2278
+ scope,
2279
+ { row: there_is_another, from_story_table }
2280
+ );
2161
2281
 
2162
- enhanced_var_data.push( special_row );
2282
+ // Now both `.target_number` and `.there_is_another` rows exist if needed
2283
+ enhanced_var_data.push( there_is_another );
2163
2284
 
2164
2285
  // Neutralize a `.there_is_another` row in a story table
2165
2286
  } else if ( from_story_table && var_datum.var.match( /\.there_is_another$/ ) && var_datum.value !== `False`) {
@@ -2174,8 +2295,8 @@ module.exports = {
2174
2295
  + `that list. This test will now set this row's \`value\` to \`False\`. See `
2175
2296
  + `https://suffolklitlab.github.io/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing#there_is_another. `
2176
2297
  + `The row data is\n${ JSON.stringify( var_datum.original )}` });
2177
- }
2178
- }
2298
+ } // ends if it's a `target_number` row
2299
+ } // ends for each row
2179
2300
 
2180
2301
  return enhanced_var_data;
2181
2302
  }, // Ends scope.ensureSpecialRows()
@@ -2183,23 +2304,16 @@ module.exports = {
2183
2304
  getThereIsAnotherValue: async function ( scope, { row, from_story_table=true }) {
2184
2305
  /* Given story row-like data as well as whether this is from a table row,
2185
2306
  * return the best guess as to a safe value to set for this round. Give
2186
- * the developer a warning if
2187
- * it's an inappropriate value. Avoid mutation.
2188
- *
2189
- * WARNING: Remember to decrement the actual value later.
2307
+ * the developer a warning if it's an inappropriate value. Avoid mutation.
2190
2308
  *
2191
- * Sometimes this will be from `.target_number` from story tables and
2192
- * we believe we've set it up so that people will make it a number.
2193
- * Sometimes this will be from `.there_is_another`. We think we've ensured
2194
- * that it will only come from Steps and should be `True` or `False`.
2195
- * This feels precarious, but I can't see another permutation.
2309
+ * Right now this argument should always be a `.target_number` number row from
2310
+ * Story Tables.
2196
2311
  *
2197
- * This may in future be used to normalize all values that need `True`/`False`
2198
- * normalization.
2312
+ * To learn the bigger picture, see the docs folder for info about Story Tables.
2199
2313
  */
2200
- let value = row.value.toLowerCase();
2314
+ let value = row.source.value.toLowerCase();
2201
2315
  let val_to_print = printable_var_value(row);
2202
- let int_val = parseInt( value );
2316
+ let desired_num = parseInt( value );
2203
2317
 
2204
2318
  // Step stuff. Take into account a lot of possible values
2205
2319
  if ( value.match( /(false|no|unchecked|uncheck|deselected|deselect)/i )) {
@@ -2207,35 +2321,36 @@ module.exports = {
2207
2321
  return `False`;
2208
2322
 
2209
2323
  } else if ( value.match( /(true|yes|checked|check|selected|select)/i )) {
2210
- if ( from_story_table ) {
2324
+ if ( from_story_table && !row.artificial ) {
2211
2325
  if ( row.var.match( /\.there_is_another$/ ) ) {
2212
- // `.there_is_another` should never get in here, but just in case
2213
2326
  await scope.addToReport( scope, { type: `warning`, value: `The attribute \`.there_is_another\` is invalid in story table tests. Replace it with \`.target_number\` in your \`var\` column. Set the \`value\` to the number of items in that list. This test will now set this row's \`value\` to \`False\`. See https://suffolklitlab.github.io/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing#there_is_another-loop. The row data is\n${ JSON.stringify( row.original )}` });
2214
2327
  } else {
2215
2328
  // If `target_number` is set to True instead of a number
2216
- // Since secret vars can't be passed in a table, this should never be a secret var
2217
2329
  await scope.addToReport( scope, { type: `warning`, value: `${ val_to_print } value is not a valid value for ${ row.var } here. This test will default to \`False\` to avoid problems.` });
2218
2330
  }
2219
2331
  return `False`;
2220
2332
  } else { return `True`; }
2221
-
2222
- // Story table stuff
2223
- // Target: 3 (3 items. press 'yes' twice.)
2224
- // Times used: 0 -> `True`, 1 -> `True`, 2 -> `False`,
2225
- } else if ( row.times_used >= int_val - 1 ) { // Story table loop will end
2226
- return `False`;
2227
-
2228
- } else if ( row.source && row.source.times_used >= int_val - 1 ) { // Just in case use changes a tad
2229
- return `False`;
2230
-
2231
- } else if ( isNaN( parseInt( value )) ) { // Loop will end
2232
- // I can't figure out how to trigger this warning either
2333
+
2334
+ } else if ( isNaN( desired_num )) { // Story table loop will end
2335
+ // I can't figure out how to trigger this warning, so maybe we're
2336
+ // already handling everything we need to
2233
2337
  await scope.addToReport( scope, { type: `warning`, value: `${ val_to_print } value is not a valid value for ${ row.var } here. This test will default to \`False\` to avoid problems.` });
2234
2338
  return `False`;
2235
2339
 
2236
- } else { // It's a number. Loop will continue.
2340
+ // Check that the number of elements in the list hits our desired number.
2341
+ // The first time `.there_is_another` is used, it's always the second item
2342
+ // the form is asking about (and so forth), so we have to add 1 to this check.
2343
+
2344
+ // Example behavior:
2345
+ // For 3 items, press 'yes' on there_is_another 2 times because
2346
+ // `.there_are_any` handles the first time.
2347
+ // target_number: 3
2348
+ // used_for[ <var_name>.target_number ]: 0 -> `True`, 1 -> `True`, 2 -> `False`
2349
+ } else if ( row.source && row.source.used_for[ row.var ] + 1 >= desired_num) { // Story table loop will end
2350
+ return `False`;
2351
+ } else {
2237
2352
  return `True`;
2238
- }
2353
+ } // ends act depending values
2239
2354
  }, // Ends scope.getThereIsAnotherValue()
2240
2355
 
2241
2356
  // throw_if_no_interview_content()?
@@ -2295,9 +2410,13 @@ module.exports = {
2295
2410
  let was_found = false;
2296
2411
  for ( let error_key in possible_errors ) {
2297
2412
  if ( possible_errors[ error_key ][0] ) {
2298
- // If you're debugging and you close the window early, the process will still
2413
+ // If there's a page visible (locally), give us as much time to examine it as timeout allows.
2414
+ // Because of previous actions, this may still be a bit too long.
2415
+ // Also, if you're debugging and you close the window early, the process will still
2299
2416
  // take this long to exit after the tests finish. Not sure how to account for that.
2300
- if ( session_vars.get_debug() ) { await scope.page.waitForTimeout( 60 * 1000 ); }
2417
+ if ( session_vars.get_debug() ) {
2418
+ await scope.page.waitForTimeout( ( scope.timeout - (1 * 1000)) );
2419
+ }
2301
2420
  was_found = true;
2302
2421
  error_handlers[ error_key ] = possible_errors[ error_key ][0];
2303
2422
  }
package/lib/steps.js CHANGED
@@ -341,6 +341,11 @@ When(/^(?:the user gets)?(?:I get)? to ?(?:the)?(?: ?question)?(?: id)? "([^"]+)
341
341
  var_data: supported_table,
342
342
  from_story_table: true,
343
343
  });
344
+
345
+ if ( session_vars.get_debug() ) {
346
+ console.log( `Rows, including special rows:`, JSON.stringify( ensured_var_data ));
347
+ }
348
+
344
349
  // Some errors happen in there to be closer to the relevant code. We'd have to try/catch anyway.
345
350
  let error = await scope.setFields(scope, { var_data: ensured_var_data, id, ensure_navigation: true });
346
351
  if ( error.was_found ) { await scope.throwPageError( scope, { id: id }); }
@@ -1104,8 +1109,6 @@ After(async function(scenario) {
1104
1109
  if (scenario.result.status !== `PASSED`) {
1105
1110
  if ( session_vars.get_debug() ) {
1106
1111
  console.log( `Non-passed status occurred while running test:`, scenario.result.status );
1107
- // If there's a page visible (locally), give us time to examine it
1108
- if ( scope.page ) { await scope.page.waitForTimeout( 60 * 1000 ); }
1109
1112
  }
1110
1113
 
1111
1114
  if ( scope.page ) {
@@ -1151,6 +1154,7 @@ After(async function(scenario) {
1151
1154
  // If the status was as expected, pass this criteria
1152
1155
  scenario.result.status = `PASSED`;
1153
1156
  }
1157
+
1154
1158
  if ( scope.expected_in_report && scope.expected_in_report.length > 0) {
1155
1159
  let expected = scope.expected_in_report;
1156
1160
  // Reset report values no matter what so they don't mess up future scenarios
@@ -1160,7 +1164,7 @@ After(async function(scenario) {
1160
1164
  if ( all_were_included ) { scenario.result.status = `PASSED`; }
1161
1165
  else { scenario.result.status = `FAILED`; }
1162
1166
  }
1163
-
1167
+
1164
1168
  if (scope.expected_not_in_report && scope.expected_not_in_report.length > 0) {
1165
1169
  let not_expected = scope.expected_not_in_report;
1166
1170
  // Reset report values no matter what so they don't mess up future scenarios