@suffolklitlab/alkiln 5.16.1-always-html-1 → 5.16.1-always-html-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/lib/scope.js CHANGED
@@ -3090,6 +3090,7 @@ module.exports = {
3090
3090
  /** Allow the developer to log a user into their server using GitHub
3091
3091
  * secrets to authenticate.
3092
3092
  */
3093
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-1.jpg`});
3093
3094
  // Don't take a picture of a failed login in case one of the inputs is correct
3094
3095
  scope.disable_error_screenshot = true;
3095
3096
 
@@ -3101,6 +3102,7 @@ module.exports = {
3101
3102
 
3102
3103
  // Go to the sign in page
3103
3104
  let login_url = `${ session_vars.get_da_server_url() }/user/sign-in`;
3105
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-2.jpg`});
3104
3106
 
3105
3107
  // TODO: implement and use scope.handle_possible_timeout()
3106
3108
  try {
@@ -3108,10 +3110,13 @@ module.exports = {
3108
3110
  await scope.page.goto( login_url, { waitUntil: `domcontentloaded`, timeout: scope.timeout });
3109
3111
  await scope.page.waitForSelector( `.dabody` );
3110
3112
 
3113
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-3.jpg`});
3114
+
3111
3115
  } catch ( error ) {
3112
3116
 
3113
3117
  let err_msg = `Error occurred when ALKiln tried to go to "${ login_url }".`
3114
3118
  if ( error.name === `TimeoutError` ) {
3119
+ console.log(`šŸ–Šļø 110`);
3115
3120
  let non_reload_report_msg = `It took too long to load "${ login_url }"`;
3116
3121
  await scope.handle_page_timeout_error( scope, { non_reload_report_data: {
3117
3122
  code: `ALK0159`,
@@ -3119,6 +3124,8 @@ module.exports = {
3119
3124
  }, error });
3120
3125
  } else {
3121
3126
  // Throw any non-timeout error
3127
+ console.log(`šŸ–Šļø 111`);
3128
+ await scope.take_a_screenshot(scope, {path:`./_alkiln_temp/Temp-4.jpg`});
3122
3129
  reports.addToReport( scope, { type: `error`, code: `ALK0160`, value: err_msg });
3123
3130
  throw error;
3124
3131
  } // ends if error is timeout error
@@ -3159,6 +3166,8 @@ module.exports = {
3159
3166
  scope.scenarios.get( scope.scenario_id ).api_keys.push( api_key );
3160
3167
  }
3161
3168
  }
3169
+ console.log(`šŸ–Šļø 112`);
3170
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-4.jpg`});
3162
3171
 
3163
3172
  expect( email, email_msg ).to.not.equal( undefined );
3164
3173
  expect( password, password_msg ).to.not.equal( undefined );
@@ -3168,9 +3177,14 @@ module.exports = {
3168
3177
  await scope.page.type( `#password`, password );
3169
3178
  let elem = await scope.page.$( `button[type="submit"]` );
3170
3179
  await scope.guard_against_missing_tap_element(scope, { elem });
3180
+ console.log(`šŸ–Šļø 113`);
3181
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-5.jpg`});
3171
3182
 
3172
3183
  // Submit and see what happens
3173
- let winner = await scope.steps.race_sign_in_navigation( scope, { elem });
3184
+ let winner = await scope.steps.race_sign_in_navigation( scope, { elem, login_url });
3185
+ console.log(`šŸ–Šļø 113.5 ${ winner }`);
3186
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-6.jpg`});
3187
+ // console.log(`šŸ–Šļø 113.6 ${ winner }`);
3174
3188
  // Add the result to the report and possibly throw errors
3175
3189
  if ( winner[0] === `success` ) {
3176
3190
  reports.addToReport( scope, {
@@ -3183,6 +3197,7 @@ module.exports = {
3183
3197
  type: `error`, code: `ALK0209`,
3184
3198
  value: `Failed to sign into ${ login_url }. Make sure you followed the instructions at https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sign-in.`
3185
3199
  });
3200
+ console.log(`šŸ‰ ${ error_msg }`);
3186
3201
  throw new Error( error_msg );
3187
3202
  } else if ( winner[0] === `error` ) {
3188
3203
  let error_msg = reports.addToReport( scope, {
@@ -3191,59 +3206,94 @@ module.exports = {
3191
3206
  });
3192
3207
  throw new Error( error_msg );
3193
3208
  }
3209
+ console.log(`šŸ–Šļø 114`);
3210
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-7.jpg`});
3211
+ if (error_msg) {
3212
+ return [ error_msg ];
3213
+ } else {
3214
+ return [];
3215
+ }
3194
3216
  }, // Ends scope.steps.sign_in()
3195
3217
 
3196
- race_sign_in_navigation: async function ( scope, { elem }) {
3218
+ race_sign_in_navigation: async function ( scope, { elem, login_url='unknown' }) {
3197
3219
  /** Wait for sign in navigation success or failure, or system error. */
3198
3220
 
3221
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-0.jpg`});
3222
+
3199
3223
  // After everything, clean up incomplete promises
3200
3224
  const controller = new AbortController;
3225
+ console.log(`ā³ 200`);
3201
3226
 
3202
3227
  // Redirect
3203
- let redirect_promise = scope.page.waitForResponse(function ( response ) {
3228
+ let redirect_promise = scope.page.waitForResponse(async ( response ) => {
3229
+ console.log(`ā³ 300`);
3204
3230
  return response.status() === 302;
3205
3231
  }, { signal: controller.signal })
3206
- .catch(( catch_info ) => {
3232
+ .catch(async ( catch_info ) => {
3233
+ console.log(`ā³ 201`);
3234
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-1.jpg`});
3207
3235
  log.debug({ code: `ALK0204`, context: `nav`, },
3208
3236
  `302 sign-in wait catch error:`, catch_info.name, catch_info,
3209
3237
  );
3210
3238
  });
3211
3239
 
3212
3240
  // Invalid credentials, no navigation, no sign in
3213
- let wrong_sign_in_promise = scope.page.waitForResponse(function ( response ) {
3241
+ let wrong_sign_in_promise = scope.page.waitForResponse(async ( response ) => {
3242
+ console.log(`ā³ 301`);
3214
3243
  return response.status() >= 200 && response.status() < 300 && response.url().includes(`/sign-in`);
3215
3244
  }, { signal: controller.signal })
3216
- .catch(( catch_info ) => {
3245
+ .catch(async ( catch_info ) => {
3246
+ // errors?
3247
+ console.log(`ā³ 202`);
3248
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-2.jpg`});
3217
3249
  log.debug({ code: `ALK0205`, context: `nav`, },
3218
3250
  `200s sign-in wait catch error:`, catch_info.name, catch_info,
3219
3251
  );
3220
3252
  });
3221
3253
 
3222
3254
  // System error
3223
- let error_promise = scope.page.waitForResponse(function ( response ) {
3255
+ let error_promise = scope.page.waitForResponse(async ( response ) => {
3256
+ console.log(`ā³ 302`);
3224
3257
  return response.status() >= 500 && response.status() < 600;
3225
3258
  }, { signal: controller.signal })
3226
- .catch(( catch_info ) => {
3259
+ .catch(async ( catch_info ) => {
3260
+ console.log(`ā³ 203`);
3261
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-3.jpg`});
3227
3262
  log.debug({ code: `ALK0206`, context: `nav`, },
3228
3263
  `500s sign-in wait catch error:`, catch_info.name, catch_info,
3229
3264
  );
3230
3265
  });
3231
3266
 
3267
+ // Duh, the other catches were triggered because those promises were aborted
3268
+
3232
3269
  let click_promise = elem.click(); // MUST complete
3270
+ let nav_promise = scope.nav_race(scope, {}).result;
3271
+ let pic_promise = true; // scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-10.jpg`});
3272
+ console.log(`ā³ 204`);
3233
3273
  const winner = await Promise.race([
3234
- Promise.all([ `success`, click_promise, redirect_promise ]),
3235
- Promise.all([ `failure`, click_promise, wrong_sign_in_promise ]),
3236
- Promise.all([ `error`, click_promise, error_promise ]),
3237
- ]).catch(function ( error ) {
3274
+ Promise.all([ `success`, click_promise, pic_promise, redirect_promise ]),
3275
+ Promise.all([ `failure`, click_promise, pic_promise, wrong_sign_in_promise ]),
3276
+ Promise.all([ `error`, click_promise, pic_promise, error_promise ]),
3277
+ ]).catch(async ( error ) => {
3278
+ console.log(`ā³ 205`);
3279
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-4.jpg`});
3238
3280
  let error_msg = reports.addToReport( scope, {
3239
3281
  type: `error`, code: `ALK0207`,
3240
3282
  value: `Unknown error waiting for results during sign in at ${ login_url }.`
3241
3283
  });
3242
- throw new Error( error );
3284
+ console.log(`ā³ 205.1`, error);
3285
+ throw error;
3243
3286
  });
3244
3287
 
3288
+ console.log(`ā³ 206`);
3289
+ // // await waitForTimeout(500);
3290
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp2-5.jpg`});
3291
+
3245
3292
  // Clean up unresolved promises
3246
3293
  controller.abort();
3294
+ console.log(`ā³ 207`);
3295
+ await nav_promise;
3296
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp3-1.jpg`});
3247
3297
 
3248
3298
  log.debug({ code: `ALK0208`, context: `nav` },
3249
3299
  `Sign-in winner:`, winner
@@ -3517,14 +3567,15 @@ module.exports = {
3517
3567
  let scenario = scope.report.get( scope.scenario_id );
3518
3568
  let report = reports.getPrintableScenario( scenario );
3519
3569
  let all_are_included = true;
3570
+ let missing = [];
3520
3571
  for ( let one_expectation of expected ) {
3521
3572
  if ( !report.includes( one_expectation )) {
3522
3573
  all_are_included = false;
3523
- expect( report ).to.contain( one_expectation );
3574
+ missing.push( one_expectation );
3524
3575
  }
3525
3576
  }
3526
3577
 
3527
- return all_are_included;
3578
+ return { all_included: all_are_included, missing };
3528
3579
  }, // Ends scope.reportIncludesAllExpected()
3529
3580
 
3530
3581
  reportDoesNotInclude: async function ( scope, { not_expected=[] }) {
package/lib/steps.js CHANGED
@@ -297,6 +297,7 @@ Given(/I go to "([^"]+)"/i, {timeout: -1}, async ( url ) => {
297
297
  return result;
298
298
  });
299
299
 
300
+ foo = null
300
301
  Given(
301
302
  /I (?:sign|log) ?(?:in)?(?:on)?(?:to the server)? with(?: the email)? "([^"]+)",?(?: and)?(?: the password)? "([^"]+)"(?: SECRETs)?(?:,?(?: and)?(?: the API key)? "([^"]+)")?/i,
302
303
  { timeout: -1 },
@@ -314,11 +315,21 @@ Given(
314
315
  // `page` timeout will deal with custom timeout
315
316
  // Couldn't test the timeout for tapping the button because there's not
316
317
  // enough of a pause between initial navigation and pressing button.
317
- await scope.steps.sign_in( scope, {
318
+ foo = scope.page
319
+ console.log(`ā­ļø ${ JSON.stringify(scope.page, null, 2) }`)
320
+ let result = await scope.steps.sign_in( scope, {
318
321
  email_secret_name: email,
319
322
  password_secret_name: password,
320
323
  api_key_secret_name: api_key
321
324
  });
325
+
326
+
327
+ console.log(`šŸ–Šļø 115`);
328
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-8.jpg`});
329
+
330
+ // if ( !result.ok && result.errors.length > 0 ) {
331
+ // throw result.errors[ result.errors.length - 1 ];
332
+ // }
322
333
  });
323
334
 
324
335
  // I am using a mobile/pc
@@ -1332,6 +1343,8 @@ Then(/I fail to delete (\d) detected interview(?:s)? and get no error __internal
1332
1343
 
1333
1344
  AfterStep(async function({ result }) {
1334
1345
  // TODO: Abstract this
1346
+ // await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-13.jpg`});
1347
+ console.log(`šŸ›‘ 100`);
1335
1348
  if ( result.status === `PASSED` ) { log.stdout({ records_only: true }, `.`); }
1336
1349
  else if ( result.status === `FAILED` ) { log.stdout({ records_only: true }, `F`); }
1337
1350
  else if ( result.status === `UNDEFINED` ) { log.stdout({ records_only: true }, `U`); }
@@ -1339,10 +1352,13 @@ AfterStep(async function({ result }) {
1339
1352
  else if ( result.status === `PENDING` ) { log.stdout({ records_only: true }, `P`); }
1340
1353
 
1341
1354
  reports.outdent();
1355
+ console.log(`šŸ›‘ 101`);
1342
1356
  });
1343
1357
 
1344
- After(async function(scenario) {
1345
-
1358
+ After(afterScenario);
1359
+ async function afterScenario(scenario) {
1360
+ console.log(`šŸ‘€ 1 ${ foo == scope.page } ${ JSON.stringify(scope.page, null, 2) }`);
1361
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-30.jpg`});
1346
1362
  // Log errors
1347
1363
  if ( scenario.result.message ) {
1348
1364
  log.debug({ code: `ALK0091`, context: `scenario`, },
@@ -1361,6 +1377,8 @@ After(async function(scenario) {
1361
1377
  value: `Accessibility standards tests failed. See information above.`
1362
1378
  });
1363
1379
  }
1380
+ console.log(`šŸ‘€ 2`);
1381
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-9.jpg`});
1364
1382
 
1365
1383
  if ( scope.failed_pdf_compares.length > 0) {
1366
1384
  let msg = scope.failed_pdf_compares.reduce((str, new_msg) => `${ str }\n―――\n${ new_msg }`)
@@ -1382,6 +1400,8 @@ After(async function(scenario) {
1382
1400
  );
1383
1401
 
1384
1402
  if ( scope.page ) {
1403
+ console.log(`šŸ‘€ 3`);
1404
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-10.jpg`});
1385
1405
 
1386
1406
  if ( !!scope.disable_error_screenshot ) {
1387
1407
  reports.addToReport(scope, {
@@ -1392,6 +1412,9 @@ After(async function(scenario) {
1392
1412
  // proprietary info in the HTML itself.
1393
1413
  value: `For security, ALKiln will avoid creating a picture of the page for this error. It's possible a secret is being used on this screen. ALKiln will save the HTML, which omits the values in the fields.`
1394
1414
  });
1415
+ }
1416
+ console.log(`šŸ‘€ 4 ${ foo == scope.page } ${ JSON.stringify(scope.page, null, 2) }`);
1417
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-11.jpg`});
1395
1418
 
1396
1419
  // Save/download a picture of the screen that's showing during the unexpected status
1397
1420
  // Save one copy in the outer-most artifact folder
@@ -1402,6 +1425,8 @@ After(async function(scenario) {
1402
1425
  disable_pic: scope.disable_error_screenshot,
1403
1426
  disable_html: false,
1404
1427
  });
1428
+ console.log(`šŸ‘€ 5 ${ foo == scope.page } ${ JSON.stringify(scope.page, null, 2) }`);
1429
+ await scope.take_a_screenshot(scope, {path:`${scope.paths.artifacts}/Temp-12.jpg`});
1405
1430
 
1406
1431
  // Save another copy in the artifact's Scenario folder
1407
1432
  let screenshot_name = `error_on`;
@@ -1414,6 +1439,7 @@ After(async function(scenario) {
1414
1439
  disable_pic: scope.disable_error_screenshot,
1415
1440
  disable_html: false,
1416
1441
  });
1442
+ console.log(`šŸ‘€ 6`);
1417
1443
 
1418
1444
  } // ends if scope.page exists
1419
1445
 
@@ -1421,37 +1447,59 @@ After(async function(scenario) {
1421
1447
  if (changeable_test_status === `FAILED`) {
1422
1448
  reports.addToReport(scope, { type: `outcome failure info`, code: `ALK0096`, value: `**-- Scenario Failed --**` });
1423
1449
  }
1450
+ console.log(`šŸ‘€ 7`);
1424
1451
 
1425
1452
  } // ends if not passed
1453
+ console.log(`šŸ‘€ 8`);
1426
1454
 
1427
1455
  // Add report text to Scenario folder after everything has been added to the report
1428
1456
  let scenario_report_obj = scope.report.get( scope.scenario_id );
1457
+ console.log(`šŸ‘€ 8.01`);
1429
1458
  let report = reports.getPrintableScenario( scenario_report_obj );
1430
1459
  // Save the report as in the Scenario folder
1460
+ console.log(`šŸ‘€ 8.02`);
1431
1461
  fs.writeFileSync( scope.paths.scenario_report, report );
1462
+ console.log(`šŸ‘€ 8.03`);
1432
1463
  // TODO: Save any cucumber failure message for the Scenario here (instead of waiting till run_cucumber.js)
1433
1464
 
1434
1465
  // ---------------- Check internal test results ----------------
1435
1466
 
1436
1467
  if ( scope.expected_in_report && scope.expected_in_report.length > 0) {
1437
- let report_includes_all_expected_strings = await scope.reportIncludesAllExpected(
1468
+ console.log(`šŸ‘€ 8.04`);
1469
+ let data = await scope.reportIncludesAllExpected(
1438
1470
  scope,
1439
1471
  { expected: scope.expected_in_report }
1440
1472
  );
1441
- if ( !report_includes_all_expected_strings ) { changeable_test_status = `FAILED`; }
1473
+ let report_includes_all_expected_strings = data.all_included;
1474
+ console.log(`šŸ‘€ 8.05`);
1475
+ if ( !report_includes_all_expected_strings ) {
1476
+ changeable_test_status = `FAILED`;
1477
+ let msg = `These strings are missing from the report:
1478
+ ${ JSON.stringify(data.missing, null, 2) }
1479
+ Instead the report had this text:
1480
+ ${ report }`;
1481
+ expect( report, msg ).to.contain( data.missing[0] );
1482
+ }
1442
1483
  // Reset report values no matter what so they don't mess up future scenarios
1443
1484
  scope.expected_in_report = null;
1485
+
1444
1486
  }
1487
+ console.log(`šŸ‘€ 8.06`);
1445
1488
 
1446
1489
  if (scope.expected_not_in_report && scope.expected_not_in_report.length > 0) {
1490
+ console.log(`šŸ‘€ 8.07`);
1447
1491
  let all_prohibited_strings_were_absent = await scope.reportDoesNotInclude(
1448
1492
  scope,
1449
1493
  { not_expected: scope.expected_not_in_report }
1450
1494
  );
1495
+ console.log(`šŸ‘€ 8.08`);
1451
1496
  if ( !all_prohibited_strings_were_absent ) { changeable_test_status = `FAILED`;}
1497
+ console.log(`šŸ‘€ 8.09`);
1452
1498
  // Reset report values no matter what so they don't mess up future scenarios
1453
1499
  scope.expected_not_in_report = null;
1500
+ console.log(`šŸ‘€ 8.091`);
1454
1501
  }
1502
+ console.log(`šŸ‘€ 9`);
1455
1503
 
1456
1504
  // ---------------- Ends internal results check ----------------
1457
1505
 
@@ -1489,6 +1537,7 @@ After(async function(scenario) {
1489
1537
  );
1490
1538
  }
1491
1539
  }
1540
+ console.log(`šŸ‘€ 10`);
1492
1541
  scope.expected_status = null; // reset for next Scenario
1493
1542
 
1494
1543
  let need_to_force_failed_status = false;
@@ -1529,12 +1578,15 @@ After(async function(scenario) {
1529
1578
  let signout_error_msg = ``;
1530
1579
  // If there is a page open, then sign out and close it
1531
1580
  if ( scope.page ) {
1581
+ console.log(`šŸ‘€ 11`);
1532
1582
  // Catch a possible reload error.
1533
1583
  try {
1534
1584
  // puppeteer will ensure proper timeout.
1585
+ console.log(`šŸ‘€ 12`);
1535
1586
  await scope.page.goto(`${ session_vars.get_da_server_url() }/user/sign-out`, {waitUntil: `domcontentloaded`});
1536
1587
 
1537
1588
  } catch ( error ) {
1589
+ console.log(`šŸ‘€ 13`);
1538
1590
  signout_succeeded = false;
1539
1591
 
1540
1592
  if ( error.name === `TimeoutError` ) {
@@ -1561,6 +1613,7 @@ After(async function(scenario) {
1561
1613
  } // ends try/catch
1562
1614
 
1563
1615
  } // ends if scope.page
1616
+ console.log(`šŸ‘€ 14`);
1564
1617
 
1565
1618
  // Now that we're no longer on the interview page, one way or
1566
1619
  // another, try to delete the interviews created during the test
@@ -1617,13 +1670,13 @@ After(async function(scenario) {
1617
1670
  internal_errors
1618
1671
  );
1619
1672
  }
1673
+ console.log(`šŸ‘€ 15`);
1620
1674
 
1621
1675
  // Find the race condition.
1622
1676
  log.debug({ code: `ALK0100`, context: `scenario`, },
1623
1677
  `Scenario After() message:`, scenario.result.message
1624
1678
  );
1625
-
1626
- });
1679
+ } // Ends afterScenario()
1627
1680
 
1628
1681
  AfterAll(async function() {
1629
1682
  // Stop collecting server response statuses
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.16.1-always-html-1",
3
+ "version": "5.16.1-always-html-3",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {