@suffolklitlab/alkiln 5.13.3-feat-random → 5.13.3-feat-random-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/.github/workflows/github_server.yml +3 -1
- package/.github/workflows/playground.yml +3 -1
- package/.github/workflows/unit_tests.yml +1 -1
- package/_alkiln_meta/shift_logs.js +75 -0
- package/action.yml +6 -8
- package/action_for_github_server/action.yml +31 -39
- package/lib/docassemble/setup.js +1 -3
- package/lib/run_cucumber.js +20 -53
- package/lib/setup/TestGenerator.js +48 -38
- package/lib/setup/generate.js +1 -1
- package/lib/setup/validate.js +1 -1
- package/lib/steps.js +20 -67
- package/lib/utils/Log.js +22 -9
- package/lib/utils/_alkiln-constrained_random_tests_old.js +49 -0
- package/lib/utils/reports.js +6 -7
- package/lib/utils/session_vars.js +11 -6
- package/package.json +13 -10
- package/tests/log_codes/check_codes.sh +3 -3
- package/tests/log_codes/log_code_expected_instances.txt +23 -1
- package/tests/unit_tests/constrained_random_answers/invalid.fixtures.js +46 -24
- package/tests/unit_tests/constrained_random_answers/invalid.test.js +22 -4
- package/tests/unit_tests/constrained_random_answers/valid.fixtures.js +129 -98
- package/tests/unit_tests/constrained_random_answers/valid.test.js +33 -13
package/lib/utils/reports.js
CHANGED
|
@@ -26,14 +26,14 @@ reports.addReportHeading = function (scope, { scenario }) {
|
|
|
26
26
|
tag_names.push( tag.name );
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let heading = `\n
|
|
29
|
+
let heading = `\n━━━━━━━━━━━━━━━\n`
|
|
30
30
|
+ `Scenario: ${ scenario.pickle.name }`;
|
|
31
31
|
|
|
32
32
|
if ( tag_names.length > 0 ) {
|
|
33
33
|
heading += `\nTags: ${ tag_names.join(' ') }`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
heading += `\n
|
|
36
|
+
heading += `\n━━━━━━━━━━━━━━━`;
|
|
37
37
|
|
|
38
38
|
reports.addToReport( scope, {
|
|
39
39
|
code: `ALK0176`,
|
|
@@ -279,7 +279,7 @@ let getLineText = function ({ type=`no type`, code=`ALK00rl`, value=``, indent=`
|
|
|
279
279
|
return result;
|
|
280
280
|
}; // Ends getLine()
|
|
281
281
|
|
|
282
|
-
let getDebugLine = function ({ type=``, code=`
|
|
282
|
+
let getDebugLine = function ({ type=``, code=`ALK0278`, value=``, indent=`` }) {
|
|
283
283
|
/** In debug log lines, include all the information possible. */
|
|
284
284
|
|
|
285
285
|
// `plain` is usually used for visual clarity and shouldn't have
|
|
@@ -299,12 +299,11 @@ let getDebugLine = function ({ type=``, code=`ALK00rd`, value=``, indent=`` }) {
|
|
|
299
299
|
|
|
300
300
|
start += ` ${ code }`;
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
let description_parts = [];
|
|
303
303
|
let extra_types = type.replace(/debug|info|success|warning|error/i, ``).replace(/ +/g, ' ').trim();
|
|
304
|
-
if ( extra_types.length > 0 ) {
|
|
304
|
+
if ( extra_types.length > 0 ) { description_parts = extra_types.split(` `); }
|
|
305
305
|
|
|
306
|
-
// Get all the
|
|
307
|
-
let description_parts = [];
|
|
306
|
+
// Get all the main descriptive text
|
|
308
307
|
if ( type.includes(`debug`) ) { description_parts.push( `DEBUG` ); }
|
|
309
308
|
if ( type.includes(`info`) ) { description_parts.push( `INFO` ); }
|
|
310
309
|
if ( type.includes(`success`) ) { description_parts.push( `SUCCESS` ); }
|
|
@@ -21,10 +21,14 @@ require('dotenv').config();
|
|
|
21
21
|
* */
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Discuss:
|
|
25
|
-
*
|
|
26
|
-
* to
|
|
27
|
-
*
|
|
24
|
+
* Discuss: We don't like logging directly to the console in here. Consider
|
|
25
|
+
* returning most logs (info, error, warning) so that the calling functions
|
|
26
|
+
* can use a `Log` to log them properly instead of logging to the console.
|
|
27
|
+
* Alternatively, move everything in here that `Log` uses into its own file
|
|
28
|
+
* so that `session_vars` can have its own `Log` instance. For example, put
|
|
29
|
+
* artifacts path name related functions in `Log`. That "get/set/delete"
|
|
30
|
+
* behavior would be inconsistent with other similar functions. Other places
|
|
31
|
+
* need to use artifacts path name too.
|
|
28
32
|
* */
|
|
29
33
|
|
|
30
34
|
const session_vars = {};
|
|
@@ -276,13 +280,14 @@ session_vars.get_runtime_config_var = function ( key ) {
|
|
|
276
280
|
try {
|
|
277
281
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
278
282
|
let value = json[ key ];
|
|
283
|
+
console.log(`🐛🐛🐛🐛🐛 ALK00temp config key/value pair:`, key, value);
|
|
279
284
|
if ( session_vars.get_debug() ) {
|
|
280
285
|
console.debug( `🐛 ALK0041 DEBUG: Runtime config var "${ key }" is "${ value }".` );
|
|
281
286
|
}
|
|
282
287
|
return value;
|
|
283
288
|
} catch ( get_var_error ) {
|
|
284
289
|
|
|
285
|
-
console.debug(`🖊️
|
|
290
|
+
console.debug(`🖊️ ALK0273 NOTE: Skipped getting runtime config var "${ key }".`, get_var_error.stack );
|
|
286
291
|
return null;
|
|
287
292
|
|
|
288
293
|
}
|
|
@@ -306,7 +311,7 @@ session_vars.delete_runtime_config_var = function ({ key }) {
|
|
|
306
311
|
|
|
307
312
|
} catch ( delete_var_error ) {
|
|
308
313
|
|
|
309
|
-
console.debug( `🖊️
|
|
314
|
+
console.debug( `🖊️ ALK0274 NOTE: Skipped deleting runtime config var "${ key }".`, delete_var_error.stack );
|
|
310
315
|
return null
|
|
311
316
|
|
|
312
317
|
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "5.13.3-feat-random",
|
|
3
|
+
"version": "5.13.3-feat-random-2",
|
|
4
4
|
"description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "npm run
|
|
8
|
-
"local": "npm run
|
|
9
|
-
|
|
10
|
-
"fail": "npm run build && npm run cucumber '@error'",
|
|
11
|
-
"cucumber": "npm run build && ./lib/run_cucumber.js",
|
|
12
|
-
"setup": "./lib/docassemble/setup.js",
|
|
7
|
+
"test": "npm run unit && npm run codes && npm run cucumber",
|
|
8
|
+
"local": "npm run setup && npm run cucumber; npm run takedown",
|
|
9
|
+
|
|
13
10
|
"takedown": "./lib/docassemble/takedown.js",
|
|
11
|
+
"setup": "./lib/docassemble/setup.js",
|
|
14
12
|
"server_install": "./lib/docassemble/server_install.js",
|
|
15
|
-
|
|
16
|
-
"
|
|
13
|
+
|
|
14
|
+
"pass": "npm run cucumber 'not @error and not @temp_error'",
|
|
15
|
+
"fail": "npm run cucumber '@error'",
|
|
16
|
+
"cucumber": "npm run build && ./lib/run_cucumber.js",
|
|
17
|
+
|
|
18
|
+
"build": "npm run artifacts && npm run validate && npm run generate",
|
|
17
19
|
"validate": "./lib/setup/validate.js",
|
|
18
20
|
"generate": "./lib/setup/generate.js",
|
|
19
|
-
"unit": "npm run artifacts && mocha --recursive 'tests/unit_tests/**/*.test.*'",
|
|
20
21
|
"artifacts": "./lib/setup/artifacts.js",
|
|
22
|
+
|
|
23
|
+
"unit": "npm run artifacts && mocha --recursive 'tests/unit_tests/**/*.test.*'",
|
|
21
24
|
"codes": "tests/log_codes/check_codes.sh ."
|
|
22
25
|
},
|
|
23
26
|
"repository": {
|
|
@@ -138,7 +138,7 @@ while [ "$indx" -le "$highest_code" ]; do
|
|
|
138
138
|
# if [[ "$loudness" != "0" ]]; then
|
|
139
139
|
missing+=("$long_msg")
|
|
140
140
|
# else
|
|
141
|
-
|
|
141
|
+
# missing+=("$short_msg")
|
|
142
142
|
# fi
|
|
143
143
|
|
|
144
144
|
# too_many
|
|
@@ -146,7 +146,7 @@ while [ "$indx" -le "$highest_code" ]; do
|
|
|
146
146
|
# if [[ "$loudness" != "0" ]]; then
|
|
147
147
|
too_many+=("$long_msg")
|
|
148
148
|
# else
|
|
149
|
-
|
|
149
|
+
# too_many+=("$short_msg")
|
|
150
150
|
# fi
|
|
151
151
|
fi
|
|
152
152
|
|
|
@@ -195,4 +195,4 @@ else
|
|
|
195
195
|
fi
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
exit $exit_code
|
|
198
|
+
exit $exit_code
|
|
@@ -5,8 +5,11 @@ Why we need duplicate codes sometimes: GitHub actions sometimes don't have ways
|
|
|
5
5
|
The script that tests the log codes will ignore this file (or any file with this name), and any file with these names: check_codes.sh, debug_log.txt, cucumber-report.txt. It will also ignore files in folders with these names:, node_modules, ALKilnTests, alkiln-*, _alkiln*. That list might get updated, so for an up-to-date list, always check the file check_codes.sh where we use `--exclude=` and such.
|
|
6
6
|
|
|
7
7
|
Reasons for deletion:
|
|
8
|
+
0000 - unknown
|
|
8
9
|
0053 - duplicate log
|
|
9
10
|
0173 - redundant
|
|
11
|
+
0181 - unknown
|
|
12
|
+
0223 - changed Log behavior ("Only logs that throw should give a value to `error`.")
|
|
10
13
|
|
|
11
14
|
ALK0000:0
|
|
12
15
|
ALK0001:1
|
|
@@ -231,7 +234,7 @@ ALK0219:1
|
|
|
231
234
|
ALK0220:1
|
|
232
235
|
ALK0221:1
|
|
233
236
|
ALK0222:1
|
|
234
|
-
ALK0223:0
|
|
237
|
+
ALK0223:0
|
|
235
238
|
ALK0224:1
|
|
236
239
|
ALK0225:1
|
|
237
240
|
ALK0226:1
|
|
@@ -267,3 +270,22 @@ ALK0255:1
|
|
|
267
270
|
ALK0256:1
|
|
268
271
|
ALK0257:1
|
|
269
272
|
ALK0258:1
|
|
273
|
+
ALK0259:1
|
|
274
|
+
ALK0260:1
|
|
275
|
+
ALK0261:1
|
|
276
|
+
ALK0262:1
|
|
277
|
+
ALK0263:1
|
|
278
|
+
ALK0264:1
|
|
279
|
+
ALK0265:1
|
|
280
|
+
ALK0266:1
|
|
281
|
+
ALK0267:1
|
|
282
|
+
ALK0268:1
|
|
283
|
+
ALK0269:1
|
|
284
|
+
ALK0270:1
|
|
285
|
+
ALK0271:1
|
|
286
|
+
ALK0272:1
|
|
287
|
+
ALK0273:1
|
|
288
|
+
ALK0274:1
|
|
289
|
+
ALK0275:1
|
|
290
|
+
ALK0276:1
|
|
291
|
+
ALK0277:1
|
|
@@ -49,11 +49,11 @@ Scenario: I fail with missing keywords for a fore Step
|
|
|
49
49
|
| user_choice | correct;; wrong |
|
|
50
50
|
`;
|
|
51
51
|
fixts.missing_fore_Step_keywords.expected = null;
|
|
52
|
-
fixts.missing_fore_Step_keywords.error_codes = [ `
|
|
52
|
+
fixts.missing_fore_Step_keywords.error_codes = [ `ALK0242`, `ALK0263` ];
|
|
53
53
|
fixts.missing_fore_Step_keywords.log_codes = [
|
|
54
|
-
`
|
|
55
|
-
`
|
|
56
|
-
`
|
|
54
|
+
`ALK0237`,
|
|
55
|
+
`ALK0242`,
|
|
56
|
+
`ALK0263`,
|
|
57
57
|
];
|
|
58
58
|
|
|
59
59
|
|
|
@@ -70,12 +70,12 @@ Scenario: I fail with missing keywords for a constraints Step
|
|
|
70
70
|
| user_choice | correct;; wrong |
|
|
71
71
|
`;
|
|
72
72
|
fixts.missing_constraints_Step_keywords.expected = null;
|
|
73
|
-
fixts.missing_constraints_Step_keywords.error_codes = [ `
|
|
73
|
+
fixts.missing_constraints_Step_keywords.error_codes = [ `ALK0256`, `ALK0263` ];
|
|
74
74
|
fixts.missing_constraints_Step_keywords.log_codes = [
|
|
75
|
-
`
|
|
76
|
-
`
|
|
77
|
-
`
|
|
78
|
-
`
|
|
75
|
+
`ALK0237`, `ALK0243`, `ALK0244`,
|
|
76
|
+
`ALK0245`, `ALK0248`, `ALK0249`,
|
|
77
|
+
`ALK0256`,
|
|
78
|
+
`ALK0263`,
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
|
|
@@ -92,12 +92,12 @@ Scenario: I fail with the first missing table
|
|
|
92
92
|
`;
|
|
93
93
|
// ======= ENDS ARG ======= //
|
|
94
94
|
fixts.missing_table.expected = null;
|
|
95
|
-
fixts.missing_table.error_codes = [ `
|
|
95
|
+
fixts.missing_table.error_codes = [ `ALK0251`, `ALK0263` ];
|
|
96
96
|
fixts.missing_table.log_codes = [
|
|
97
|
-
`
|
|
98
|
-
`
|
|
99
|
-
`
|
|
100
|
-
`
|
|
97
|
+
`ALK0237`, `ALK0243`, `ALK0244`,
|
|
98
|
+
`ALK0245`, `ALK0248`, `ALK0249`, `ALK0246`,
|
|
99
|
+
`ALK0251`,
|
|
100
|
+
`ALK0263`,
|
|
101
101
|
];
|
|
102
102
|
|
|
103
103
|
|
|
@@ -115,12 +115,12 @@ Scenario: I fail with missing quoted ids in constrained random answers
|
|
|
115
115
|
`;
|
|
116
116
|
// ======= ENDS ARG ======= //
|
|
117
117
|
fixts.missing_ids.expected = null;
|
|
118
|
-
fixts.missing_ids.error_codes = [ `
|
|
118
|
+
fixts.missing_ids.error_codes = [ `ALK0250`, `ALK0263` ];
|
|
119
119
|
fixts.missing_ids.log_codes = [
|
|
120
|
-
`
|
|
121
|
-
`
|
|
122
|
-
`
|
|
123
|
-
`
|
|
120
|
+
`ALK0237`, `ALK0243`, `ALK0244`,
|
|
121
|
+
`ALK0245`, `ALK0248`, `ALK0249`, `ALK0246`,
|
|
122
|
+
`ALK0250`,
|
|
123
|
+
`ALK0263`,
|
|
124
124
|
];
|
|
125
125
|
|
|
126
126
|
|
|
@@ -140,12 +140,12 @@ Scenario: Non-table row after table header
|
|
|
140
140
|
| user_choice | correct;; wrong |
|
|
141
141
|
`;
|
|
142
142
|
fixts.only_row_is_header.expected = null;
|
|
143
|
-
fixts.only_row_is_header.error_codes = [`
|
|
143
|
+
fixts.only_row_is_header.error_codes = [`ALK0252`, `ALK0263`];
|
|
144
144
|
fixts.only_row_is_header.log_codes = [
|
|
145
|
-
`
|
|
146
|
-
`
|
|
147
|
-
`
|
|
148
|
-
`
|
|
145
|
+
`ALK0237`, `ALK0243`, `ALK0244`,
|
|
146
|
+
`ALK0245`, `ALK0248`, `ALK0249`, `ALK0246`,
|
|
147
|
+
`ALK0252`,
|
|
148
|
+
`ALK0263`,
|
|
149
149
|
];
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -153,3 +153,25 @@ fixts.only_row_is_header.log_codes = [
|
|
|
153
153
|
* can't detect it)
|
|
154
154
|
* */
|
|
155
155
|
|
|
156
|
+
|
|
157
|
+
fixts.multiple_scenarios = {};
|
|
158
|
+
fixts.multiple_scenarios.arg =
|
|
159
|
+
`Feature: It is invalid to have multiple Scenarios in one generator file
|
|
160
|
+
|
|
161
|
+
Scenario: The first of 2 Scenarios
|
|
162
|
+
Given ALKiln makes 1 constrained random answers tests
|
|
163
|
+
Given I start the interview at "test_kickout"
|
|
164
|
+
And ALKiln will get to "end" with:
|
|
165
|
+
| var | possible_values |
|
|
166
|
+
| user_choice | correct;; wrong |
|
|
167
|
+
|
|
168
|
+
Scenario: The second of 2 Scenarios
|
|
169
|
+
Given ALKiln makes 1 constrained random answers tests
|
|
170
|
+
Given I start the interview at "test_kickout"
|
|
171
|
+
And ALKiln will get to "end" with:
|
|
172
|
+
| var | possible_values |
|
|
173
|
+
| user_choice | correct;; wrong |
|
|
174
|
+
`;
|
|
175
|
+
fixts.multiple_scenarios.expected = null;
|
|
176
|
+
fixts.multiple_scenarios.error_codes = [`ALK0236`];
|
|
177
|
+
fixts.multiple_scenarios.log_codes = [`ALK0236`];
|
|
@@ -39,7 +39,7 @@ function get_log_codes({ logger }) {
|
|
|
39
39
|
* */
|
|
40
40
|
let codes = [];
|
|
41
41
|
|
|
42
|
-
for ( let record of logger.
|
|
42
|
+
for ( let record of logger.internal_log_records ) {
|
|
43
43
|
codes.push( record.opts.code );
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -62,8 +62,8 @@ function mutate_globals_with({ testing_vals }) {
|
|
|
62
62
|
*
|
|
63
63
|
* @returns {undefined}
|
|
64
64
|
* */
|
|
65
|
-
//
|
|
66
|
-
logger.
|
|
65
|
+
// Reset log codes
|
|
66
|
+
logger.clear_internal_log_records();
|
|
67
67
|
|
|
68
68
|
// Fresh namespace
|
|
69
69
|
let generator = new TestGenerator();
|
|
@@ -98,7 +98,7 @@ describe(`Constrained random answers parser,`, function () {
|
|
|
98
98
|
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
describe(`when given
|
|
101
|
+
describe(`when given an empty string`, function () {
|
|
102
102
|
|
|
103
103
|
before(function () { mutate_globals_with({ testing_vals: fixtures.generator_missing_contents }); });
|
|
104
104
|
|
|
@@ -228,6 +228,24 @@ describe(`Constrained random answers parser,`, function () {
|
|
|
228
228
|
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
+
describe(`that has multiple Scenarios,`, function () {
|
|
232
|
+
|
|
233
|
+
before(function () { mutate_globals_with({ testing_vals: fixtures.multiple_scenarios }); });
|
|
234
|
+
|
|
235
|
+
let outer = fixtures.multiple_scenarios;
|
|
236
|
+
|
|
237
|
+
it(`returns \`null\` for contents value`, function () {
|
|
238
|
+
expect( new_contents ).to.equal( fixture.expected );
|
|
239
|
+
});
|
|
240
|
+
it(`has these exact error codes: ${ JSON.stringify( outer.error_codes )}`, function () {
|
|
241
|
+
expect( get_error_codes({ errors: errors }) ).to.have.all.members( fixture.error_codes );
|
|
242
|
+
});
|
|
243
|
+
it(`has these exact _log_ codes: ${ JSON.stringify( outer.log_codes )}`, function () {
|
|
244
|
+
expect( get_log_codes({ logger }) ).to.have.all.members( fixture.log_codes );
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
});
|
|
248
|
+
|
|
231
249
|
});
|
|
232
250
|
|
|
233
251
|
});
|