@suffolklitlab/alkiln 4.10.4-cli-playground-1 → 4.10.4-cli-playground-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.
@@ -141,13 +141,27 @@ da_i.is_server_responding = async function ( dev_id_options ) {
141
141
 
142
142
  // node -e 'require("./lib/docassemble/docassemble_api_interface.js").get_dev_id()'
143
143
  da_i.get_dev_id = async function ( dev_id_options ) {
144
- /** For consistency, wrap _da_REST.get_dev_id().
145
- * See https://docassemble.org/docs/api.html#user. */
144
+ /** Get user id, either locally or on the server.
145
+ * For consistency, wrap _da_REST.get_dev_id().
146
+ * See https://docassemble.org/docs/api.html#user.
147
+ *
148
+ * @param dev_id_options {obj} Options for getting dev_id
149
+ * @param dev_id_options.timeout {int} Required if options is defined. Max MS
150
+ * to allow for server request.
151
+ */
146
152
 
147
- // Default timeouts
148
- let { timeout } = dev_id_options || { timeout: DEFAULT_MAX_REQUEST_MS };
149
- let response = await _da_REST.get_dev_id( timeout );
150
- return response.data.id;
153
+ let dev_id = null;
154
+
155
+ if ( session_vars.get_origin() === 'interview' ) {
156
+ dev_id = session_vars.get_user_id();
157
+ } else {
158
+ // Default timeouts
159
+ let { timeout } = dev_id_options || { timeout: DEFAULT_MAX_REQUEST_MS };
160
+ let response = await _da_REST.get_dev_id( timeout );
161
+ dev_id = response.data.id;
162
+ }
163
+
164
+ return dev_id;
151
165
  }; // Ends da_i.get_dev_id();
152
166
 
153
167
 
@@ -11,6 +11,7 @@ let get_base_interview_url = async function () {
11
11
  * when the user is not logged in.) We can't use `reset=2` because it caused an
12
12
  * 'Unable to locate interview session' error. */
13
13
  let server_url = session_vars.get_da_server_url();
14
+
14
15
  let dev_id = await docassemble_api_interface.get_dev_id();
15
16
  let project_name = session_vars.get_project_name();
16
17
  return `${ server_url }/interview?new_session=1&i=docassemble.playground${ dev_id }${ project_name }%3A`;
@@ -17,20 +17,23 @@ const cucumber_api = require('@cucumber/cucumber/api');
17
17
  "publishQuiet": true,
18
18
  "require": "./lib/index.js",
19
19
  "format": ["progress", "summary:cucumber-report.txt"],
20
- "paths": ["docassemble/*/data/sources/*.feature"],
20
+ "paths": ["docassemble/*/data/sources/*.feature",
21
+ // // "1" is the user id. We also need to get the Project name, etc.
22
+ // "/usr/share/docassemble/files/playgroundsources/1/test.feature"
23
+ ],
21
24
  "retry": 1,
22
25
  }
23
26
 
24
27
  // If they're running it from an interview on their server instead of from GitHub
25
28
  if ( session_vars.get_origin() === `interview` ) {
26
- provided_config.paths.append(`/usr/share/docassemble/files/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}/*.feature`);
29
+ provided_config.paths.push(`/usr/share/docassemble/files/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}/*.feature`);
27
30
  }
28
31
 
29
32
  let tag_vals = just_args;
30
33
  if ( session_vars.get_origin() === `interview` ) {
31
34
  // Should tags be given as a string or a list? String would give option to
32
35
  // give a boolean expression. TODO: offer a dropdown with available tags.
33
- tag_vals = session_vars.get_tags().split(` `);
36
+ tag_vals = session_vars.get_tags();
34
37
  }
35
38
 
36
39
  if (tag_vals.length > 0) {
@@ -49,7 +52,6 @@ const cucumber_api = require('@cucumber/cucumber/api');
49
52
  }
50
53
  }
51
54
 
52
-
53
55
  const { runConfiguration } = await cucumber_api.loadConfiguration({
54
56
  provided: provided_config
55
57
  }, environment);
@@ -66,7 +68,7 @@ const cucumber_api = require('@cucumber/cucumber/api');
66
68
  console.log(`%o`, runConfiguration);
67
69
 
68
70
  const { success } = await cucumber_api.runCucumber({...runConfiguration, support});
69
- console.log(`ALKiln run_cucumber.js succeeded:`);
71
+ console.log(`\nALKiln run_cucumber.js succeeded:`);
70
72
  console.log(`%o`, success);
71
73
  const exitCode = success ? 0 : 1;
72
74
  process.exitCode = exitCode;
package/lib/scope.js CHANGED
@@ -732,7 +732,6 @@ module.exports = {
732
732
  load: async function ( scope, file_name ) {
733
733
  /* Try to load the page. Should we also pass a `timeout` arg or just
734
734
  * use scope.timeout? */
735
-
736
735
  await scope.addToReport(scope,{
737
736
  type: `row`,
738
737
  value: `Trying to load the interview`
@@ -753,17 +752,15 @@ module.exports = {
753
752
  let base_url = await get_base_interview_url();
754
753
  interview_url = `${ base_url }${ file_name }`;
755
754
  }
755
+
756
756
  if ( session_vars.get_debug() ) { console.log( `interview_url:`, interview_url ); }
757
757
 
758
758
  if ( !scope.page ) { scope.page = await scope.browser.newPage(); }
759
759
 
760
760
  // TODO: implement and use scope.handle_possible_timeout()
761
761
  try {
762
-
763
762
  await scope.page.goto(interview_url, { waitUntil: 'domcontentloaded', timeout: scope.timeout })
764
-
765
763
  } catch ( error ) {
766
-
767
764
  // If the page didn't load because it took to long to load
768
765
  if ( error.name === `TimeoutError` ) {
769
766
 
@@ -772,7 +769,6 @@ module.exports = {
772
769
 
773
770
  // If the page didn't load because of any other reason
774
771
  } else {
775
-
776
772
  // Throw any non-timeout error
777
773
  scope.addToReport( scope, {
778
774
  type: `error`,
@@ -782,14 +778,12 @@ module.exports = {
782
778
  } // ends if error is timeout error
783
779
 
784
780
  } // ends try/catch
785
-
786
781
  let load_result = await scope.getLoadData( scope );
787
782
  // Errors, or reaching timeout, causes an exception and is shown to the developer at the end
788
783
  if ( load_result.error ) {
789
784
  await scope.addToReport(scope, { type: `error`, value: `On final attempt to load interview, got "${ load_result.error }"` });
790
785
  expect( load_result.error ).to.equal( '' );
791
786
  }
792
-
793
787
  return scope.page;
794
788
  }, // Ends scope.load()
795
789
 
package/lib/steps.js CHANGED
@@ -91,6 +91,7 @@ BeforeAll(async () => {
91
91
 
92
92
  // Make the folder to store all the files for this run of the tests
93
93
  scope.paths.artifacts = files.make_artifacts_folder();
94
+ console.log(`process.cwd()`, process.cwd());
94
95
  // Save its name in a file. `session_vars` can get it back later.
95
96
  // This is used by at least run_cucumber.js.
96
97
  session_vars.save_artifacts_path_name( scope.paths.artifacts );
@@ -35,7 +35,13 @@ session_vars.get_origin = function () {
35
35
  };
36
36
  session_vars.get_user_project_name = function () { return process.env._PROJECT_NAME || null; };
37
37
  session_vars.get_user_id = function () { return process.env._USER_ID || null; };
38
- session_vars.get_tags = function () { return process.env._TAGS || null; };
38
+ session_vars.get_tags = function () {
39
+ if ( process.env._TAGS ) {
40
+ return process.env._TAGS.split(` `);
41
+ } else {
42
+ return [];
43
+ }
44
+ };
39
45
 
40
46
  // More complex logic
41
47
  session_vars.get_server_reload_timeout = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "4.10.4-cli-playground-1",
3
+ "version": "4.10.4-cli-playground-2",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {