@suffolklitlab/alkiln 4.11.6 → 5.0.0-experimental2
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/pull_request_template.md +17 -0
- package/.github/workflows/test_tests.yml +7 -6
- package/CHANGELOG.md +22 -15
- package/CONTRIBUTING.md +6 -0
- package/action.yml +10 -37
- package/lib/docassemble/docassemble_api_REST.js +12 -6
- package/lib/docassemble/docassemble_api_interface.js +28 -7
- package/lib/run_cucumber.js +88 -0
- package/lib/scope.js +80 -77
- package/lib/steps.js +18 -3
- package/lib/utils/session_vars.js +78 -36
- package/npm-shrinkwrap.json +5010 -0
- package/package.json +9 -9
- package/tests/unit_tests/session_vars.test.js +111 -18
- package/cucumber.js +0 -3
- package/lib/utils/clean_reports.js +0 -29
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-experimental2",
|
|
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
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"cucumber_external": "run_cucumber(){ tmp_path=`pwd`; ( new_path=\"$1\"; shift; cd \"$new_path\"; npm run --prefix \"${tmp_path}\" cucumber_base -- \"$@\" \"$new_path\"/docassemble/*/data/sources/*.feature;) }; run_cucumber",
|
|
11
|
-
"langs": "npm run langs_setup && ./node_modules/.bin/cucumber-js --require ./lib/index.js docassemble/*/data/sources/*_lang*.feature",
|
|
7
|
+
"test": "npm run unit && npm run langs_setup && npm run cucumber",
|
|
8
|
+
"cucumber": "./lib/run_cucumber.js",
|
|
9
|
+
"langs": "npm run langs_setup && npm run cucumber",
|
|
12
10
|
"langs_setup": "./lib/utils/langs.js 'docassemble/*/data/sources/*.feature'",
|
|
13
11
|
"langs_local": "npm run langs_setup && npm run local",
|
|
14
12
|
"local": "npm run setup && npm run cucumber; npm run takedown",
|
|
@@ -36,13 +34,14 @@
|
|
|
36
34
|
"homepage": "https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing/",
|
|
37
35
|
"dependencies": {
|
|
38
36
|
"@axe-core/puppeteer": "4.4.2",
|
|
39
|
-
"@cucumber/cucumber": "
|
|
37
|
+
"@cucumber/cucumber": "8.6.0",
|
|
40
38
|
"@faker-js/faker": "^7.3.0",
|
|
41
39
|
"axios": "0.24.0",
|
|
42
40
|
"chai": "4.2.0",
|
|
43
41
|
"cheerio": "1.0.0-rc.10",
|
|
44
|
-
"dotenv": "8.2.0",
|
|
45
42
|
"deep-equal-in-any-order": "^2.0.0",
|
|
43
|
+
"dotenv": "8.2.0",
|
|
44
|
+
"glob": "^10.2.7",
|
|
46
45
|
"mocha": "9.2.0",
|
|
47
46
|
"puppeteer": "13.1.3",
|
|
48
47
|
"qs": "6.10.2",
|
|
@@ -52,6 +51,7 @@
|
|
|
52
51
|
"bin": {
|
|
53
52
|
"alkiln-setup": "./lib/docassemble/setup.js",
|
|
54
53
|
"alkiln-takedown": "./lib/docassemble/takedown.js",
|
|
55
|
-
"alkiln-langs": "./lib/utils/langs.js"
|
|
54
|
+
"alkiln-langs": "./lib/utils/langs.js",
|
|
55
|
+
"alkiln-run": "./lib/run_cucumber.js"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -4,42 +4,135 @@ const expect = chai.expect;
|
|
|
4
4
|
const session_vars = require("../../lib/utils/session_vars.js");
|
|
5
5
|
const validateEnvironment = session_vars.validateEnvironment;
|
|
6
6
|
|
|
7
|
+
// Not going to totally support these any more.
|
|
8
|
+
delete process.env.BRANCH_PATH;
|
|
9
|
+
delete process.env.BASE_URL;
|
|
10
|
+
|
|
7
11
|
describe('When the `session_vars` object uses', function () {
|
|
8
12
|
describe('validateEnvironment, it', function() {
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
|
-
* All required variables should be defined in .env.
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
* All required variables should be defined in .env. Different
|
|
16
|
+
* env vars for different test runner locations/origins.
|
|
17
|
+
*/
|
|
18
|
+
it("successfully completes when all required local env vars exist", function() {
|
|
19
|
+
process.env._ORIGIN = `local`;
|
|
20
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
21
|
+
process.env.DOCASSEMBLE_DEVELOPER_API_KEY = `1`;
|
|
22
|
+
process.env.REPO_URL = `https://github.com/org/docassemble-repo`;
|
|
23
|
+
process.env.BRANCH_NAME = `a_branch`;
|
|
24
|
+
|
|
25
|
+
delete process.env._PROJECT_NAME;
|
|
26
|
+
delete process.env._USER_ID;
|
|
27
|
+
|
|
18
28
|
session_vars.validateEnvironment();
|
|
19
29
|
});
|
|
30
|
+
it("successfully completes when all required GitHub env vars exist", function() {
|
|
31
|
+
process.env._ORIGIN = `github`;
|
|
32
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
33
|
+
process.env.DOCASSEMBLE_DEVELOPER_API_KEY = `1`;
|
|
34
|
+
process.env.REPO_URL = `https://github.com/org/docassemble-repo`;
|
|
35
|
+
process.env.BRANCH_NAME = `a_branch`;
|
|
36
|
+
|
|
37
|
+
delete process.env._PROJECT_NAME;
|
|
38
|
+
delete process.env._USER_ID;
|
|
39
|
+
|
|
40
|
+
session_vars.validateEnvironment();
|
|
41
|
+
});
|
|
42
|
+
it("successfully completes when all required Playground env vars exist", function() {
|
|
43
|
+
process.env._ORIGIN = `playground`;
|
|
44
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
45
|
+
process.env._PROJECT_NAME = `TheProject`;
|
|
46
|
+
process.env._USER_ID = `1`;
|
|
20
47
|
|
|
21
|
-
/**
|
|
22
|
-
* This test has an ordering dependency with the test below. I'm not certain if I am getting lucky or if I need to explicitly declare the order.
|
|
23
|
-
*/
|
|
24
|
-
it("throws a reference error when any var is missing", function() {
|
|
25
48
|
delete process.env.DOCASSEMBLE_DEVELOPER_API_KEY;
|
|
49
|
+
delete process.env.REPO_URL;
|
|
50
|
+
delete process.env.BRANCH_NAME;
|
|
26
51
|
|
|
27
|
-
|
|
52
|
+
session_vars.validateEnvironment();
|
|
28
53
|
});
|
|
29
54
|
|
|
30
55
|
/**
|
|
31
|
-
*
|
|
56
|
+
* Throwing errors
|
|
32
57
|
*/
|
|
33
|
-
it("names all missing variables in the error
|
|
34
|
-
|
|
35
|
-
|
|
58
|
+
it("names all missing always-required variables in the error", function() {
|
|
59
|
+
process.env._ORIGIN = 'playground';
|
|
60
|
+
// Ensure it doesn't fail because of Playground required vars
|
|
61
|
+
process.env._PROJECT_NAME = `TheProject`;
|
|
62
|
+
process.env._USER_ID = `1`;
|
|
63
|
+
|
|
36
64
|
delete process.env.SERVER_URL;
|
|
37
|
-
delete process.env.REPO_URL;
|
|
38
65
|
|
|
39
66
|
// This test just tests that the variable names show up in a fixed order.
|
|
40
67
|
expect(session_vars.validateEnvironment).to.throw(
|
|
41
68
|
ReferenceError,
|
|
42
|
-
/
|
|
69
|
+
/SERVER_URL/
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("identifies when _ORIGIN has an invalid value", function() {
|
|
74
|
+
process.env._ORIGIN = 'invalid';
|
|
75
|
+
delete process.env.SERVER_URL;
|
|
76
|
+
|
|
77
|
+
// This test just tests that the variable names show up in a fixed order.
|
|
78
|
+
expect(session_vars.validateEnvironment).to.throw(
|
|
79
|
+
ReferenceError,
|
|
80
|
+
/_ORIGIN/
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("names all missing local variables in the error, not just one", function() {
|
|
85
|
+
// Ensure it doesn't fail because of always-required vars
|
|
86
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
87
|
+
// Ensure it doesn't fail because of Playground required vars
|
|
88
|
+
process.env._PROJECT_NAME = `TheProject`;
|
|
89
|
+
process.env._USER_ID = `1`;
|
|
90
|
+
|
|
91
|
+
process.env._ORIGIN = `local`;
|
|
92
|
+
delete process.env.DOCASSEMBLE_DEVELOPER_API_KEY;
|
|
93
|
+
delete process.env.REPO_URL;
|
|
94
|
+
delete process.env.BRANCH_NAME;
|
|
95
|
+
|
|
96
|
+
// Matches message contents in any order
|
|
97
|
+
expect(session_vars.validateEnvironment).to.throw(
|
|
98
|
+
ReferenceError,
|
|
99
|
+
/(?=[\S\s]*REPO_URL)(?=[\S\s]*BRANCH_NAME)(?=[\S\s]*DOCASSEMBLE_DEVELOPER_API_KEY)/
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("names all missing GitHub variables in the error, not just one", function() {
|
|
104
|
+
// Ensure it doesn't fail because of always-required vars
|
|
105
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
106
|
+
// Ensure it doesn't fail because of Playground required vars
|
|
107
|
+
process.env._PROJECT_NAME = `TheProject`;
|
|
108
|
+
process.env._USER_ID = `1`;
|
|
109
|
+
|
|
110
|
+
process.env._ORIGIN = `github`;
|
|
111
|
+
delete process.env.DOCASSEMBLE_DEVELOPER_API_KEY;
|
|
112
|
+
delete process.env.REPO_URL;
|
|
113
|
+
delete process.env.BRANCH_NAME;
|
|
114
|
+
|
|
115
|
+
expect(session_vars.validateEnvironment).to.throw(
|
|
116
|
+
ReferenceError,
|
|
117
|
+
/(?=[\S\s]*REPO_URL)(?=[\S\s]*BRANCH_NAME)(?=[\S\s]*DOCASSEMBLE_DEVELOPER_API_KEY)/
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("names all missing Playground variables in the error, not just one", function() {
|
|
122
|
+
// Ensure it doesn't fail because of always-required vars
|
|
123
|
+
process.env.SERVER_URL = `https://example.com`;
|
|
124
|
+
// Ensure it doesn't fail because of GitHub required vars
|
|
125
|
+
process.env.DOCASSEMBLE_DEVELOPER_API_KEY = `1`;
|
|
126
|
+
process.env.REPO_URL = `https://github.com/org/docassemble-repo`;
|
|
127
|
+
process.env.BRANCH_NAME = `a_branch`;
|
|
128
|
+
|
|
129
|
+
process.env._ORIGIN = `playground`;
|
|
130
|
+
delete process.env._PROJECT_NAME;
|
|
131
|
+
delete process.env._USER_ID;
|
|
132
|
+
|
|
133
|
+
expect(session_vars.validateEnvironment).to.throw(
|
|
134
|
+
ReferenceError,
|
|
135
|
+
/(?=[\S\s]*_PROJECT_NAME)(?=[\S\s]*_USER_ID)/
|
|
43
136
|
);
|
|
44
137
|
});
|
|
45
138
|
});
|
package/cucumber.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const log = require('./log');
|
|
5
|
-
const session_vars = require('./session_vars');
|
|
6
|
-
|
|
7
|
-
// This is hardcoded information from `cucumber.js`. Once we move to cucumber 8, we should
|
|
8
|
-
// change that the cucumber.json and actually parse the info from it.
|
|
9
|
-
// The file won't be used for anything other than detecting and removing color codes
|
|
10
|
-
let summary_file_name = 'cucumber-report.txt';
|
|
11
|
-
fs.readFile(summary_file_name, 'utf8', (err, data) => {
|
|
12
|
-
if (err) {
|
|
13
|
-
console.error(err);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Replace terminal color codes, if present
|
|
18
|
-
// https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#colors--graphics-mode
|
|
19
|
-
data = data.replace(/\x1b\[[0-9][0-9]?[0-9]?m/g, '');
|
|
20
|
-
|
|
21
|
-
// Put it in the correct file in the correct folder
|
|
22
|
-
let artifacts_path = session_vars.get_artifacts_path_name();
|
|
23
|
-
fs.appendFile( `${ artifacts_path }/${ log.debug_log_file }`, data, err => {
|
|
24
|
-
if (err) {
|
|
25
|
-
console.error(err);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}); // Ends appendFileSync
|
|
29
|
-
});
|