@suffolklitlab/alkiln 5.0.0-pre-3 → 5.0.0-pre-5

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.0.0-pre-3",
3
+ "version": "5.0.0-pre-5",
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 unit && npm run langs_setup && npm run cucumber -- $@",
7
+ "test": "npm run unit && npm run langs_setup && npm run cucumber",
8
8
  "cucumber": "./lib/run_cucumber.js",
9
9
  "langs": "npm run langs_setup && npm run cucumber",
10
10
  "langs_setup": "./lib/utils/langs.js 'docassemble/*/data/sources/*.feature'",
@@ -7,4 +7,7 @@ names.non_english_chars = `是汉字`;
7
7
  names.colon_input = `invalid:colon`;
8
8
  names.colon_output = `invalid_colon`;
9
9
 
10
+ names.long_input = `Longest scenario description should be 70 characters or less 0123456789`;
11
+ names.long_output = `Longest scenario description should be 70 characters or less 012345678`;
12
+
10
13
  module.exports = names;
@@ -39,6 +39,12 @@ describe(`When I use scope.getSafeScenarioBaseFilename()`, function() {
39
39
  expect( result ).to.equal( names.colon_output );
40
40
  });
41
41
 
42
+ it(`shortens a name over 70 chars`, async function() {
43
+ let scenario = mock_scenario( names.long_input );
44
+ let result = await getSafeScenarioBaseFilename( scope, { scenario });
45
+ expect( result ).to.equal( names.long_output );
46
+ });
47
+
42
48
  // language
43
49
  it(`adds a language correctly to a description`, async function() {
44
50
  scope.language = names.non_english_chars;
@@ -5,13 +5,12 @@
5
5
  const names = require('./names.fixtures.js');
6
6
  const scope = require('../../lib/scope.js');
7
7
  const getSafeScenarioFilename = scope.getSafeScenarioFilename;
8
-
9
-
8
+
10
9
  let test_filename = function ( expected_prefix, result ) {
11
10
  /* Test a name to see if it's valid output with a language defined. */
12
- let expected_name_regex_str = `^${ expected_prefix }-${ names.base_filename }-\.{32}$`;
11
+ let expected_name_regex_str = `^${ expected_prefix }-${ names.description }-\.{13}$`;
13
12
  if ( expected_prefix == `` ) {
14
- expected_name_regex_str = `^${ names.base_filename }-\.{32}$`;
13
+ expected_name_regex_str = `^${ names.description }-\.{13}$`;
15
14
  }
16
15
  let regex = new RegExp( expected_name_regex_str );
17
16
 
@@ -29,7 +28,7 @@ let test_filename = function ( expected_prefix, result ) {
29
28
  describe(`When I use scope.getSafeScenarioFilename()`, function() {
30
29
 
31
30
  beforeEach(function() {
32
- scope.base_filename = names.base_filename;
31
+ scope.base_filename = names.description;
33
32
  });
34
33
 
35
34
  it(`preserves chinese characters`, async function() {
@@ -81,6 +80,31 @@ let test_filename = function ( expected_prefix, result ) {
81
80
  let result = await getSafeScenarioFilename( scope, { prefix: names.numerical_input });
82
81
  test_filename( names.numerical_output, result );
83
82
  });
83
+
84
+ it(`handles a missing prefix`, async function() {
85
+ let result = await getSafeScenarioFilename( scope );
86
+ test_filename( ``, result );
87
+ });
88
+
89
+ it(`shortens ids over 20 chars long`, async function() {
90
+ // Necessary to set id correctly
91
+ scope.page = true;
92
+ let old_examine = scope.examinePageID;
93
+ scope.examinePageID = function () { return {id: names.long_id_input}; }
94
+ let result = await getSafeScenarioFilename( scope );
95
+ scope.examinePageID = old_examine;
96
+
97
+ let regext_str = `^${ names.long_id_output }-${ scope.base_filename }-\.*$`;
98
+ let regex = new RegExp( regext_str );
99
+
100
+ // Log more info if it failed
101
+ let found_match = regex.test( result );
102
+ if ( !found_match ) {
103
+ console.log( 'regex:', regex.source );
104
+ console.log( 'result:', result );
105
+ }
106
+ expect( found_match ).to.be.true;
107
+ });
84
108
 
85
109
  });
86
110
 
@@ -1,6 +1,6 @@
1
1
  let names = {};
2
2
 
3
- names.base_filename = `a_safe_id`;
3
+ names.description = `a_safe_scenario_description`;
4
4
 
5
5
  names.chinese_input = `是汉字`;
6
6
  names.chinese_output = `是汉字`;
@@ -32,4 +32,7 @@ names.two_consecutive_invalid_output = `two_consecutive__invalid`;
32
32
  names.numerical_input = `scenario_w1th_number00`;
33
33
  names.numerical_output = `scenario_w1th_number00`;
34
34
 
35
+ names.long_id_input = `over_20_chars_123456789`;
36
+ names.long_id_output = `over_20_chars_123456`;
37
+
35
38
  module.exports = names;