@suffolklitlab/alkiln 5.12.0-delete6 → 5.13.0-logs1
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/.env.example +29 -0
- package/.github/workflows/github_server.yml +11 -9
- package/.github/workflows/log_code_tests.yml +0 -2
- package/.github/workflows/playground.yml +7 -5
- package/CHANGELOG.md +30 -5
- package/CONTRIBUTING.md +98 -83
- package/action.yml +66 -28
- package/action_for_github_server/action.yml +59 -31
- package/docs/decisions/006_which_log_level_to_pick_2024_09_5.md +46 -0
- package/docs/decisions/adopt_architectural_decision_records.md +58 -0
- package/docs/decisions/detect_sign_in.md +124 -0
- package/docs/decisions/pdfjs_version_2024_08_08.md +18 -0
- package/docs/decisions/reports_and_logs_2024_08_11.md +141 -0
- package/docs/decisions/update_puppeteer_2024_07_28.md +62 -0
- package/lib/docassemble/docassemble_api_interface.js +63 -34
- package/lib/docassemble/server_install.js +23 -9
- package/lib/docassemble/setup.js +33 -20
- package/lib/docassemble/takedown.js +27 -7
- package/lib/run_cucumber.js +81 -33
- package/lib/scope.js +152 -79
- package/lib/steps.js +84 -51
- package/lib/utils/files.js +8 -6
- package/lib/utils/log.js +477 -84
- package/lib/utils/reports.js +14 -5
- package/lib/utils/session_vars.js +25 -18
- package/lib/utils/time.js +44 -0
- package/npm-shrinkwrap.json +635 -193
- package/package.json +6 -6
- package/tests/log_codes/check_codes.sh +163 -108
- package/tests/log_codes/log_code_expected_instances.txt +213 -0
- package/tests/unit_tests/getAllFields.test.js +5 -0
- package/tests/unit_tests/getMatchingRows.test.js +5 -0
- package/tests/unit_tests/log.test.js +20 -0
- package/tests/unit_tests/normalizeTable.test.js +5 -0
- package/tests/log_codes/deleted_codes.json +0 -8
package/.env.example
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Setup
|
|
2
|
+
DOCASSEMBLE_DEVELOPER_API_KEY=<ask @niharikasingh>
|
|
3
|
+
SERVER_URL=https://apps-dev.suffolklitlab.org
|
|
4
|
+
REPO_URL=https://github.com/SuffolkLITLab/alkiln
|
|
5
|
+
SERVER_RELOAD_TIMEOUT_SECONDS=
|
|
6
|
+
MAX_SECONDS_FOR_SETUP=
|
|
7
|
+
|
|
8
|
+
# Set DEBUG to 1 to run in non-headless mode and see the test run live
|
|
9
|
+
DEBUG=
|
|
10
|
+
# If you edit interview files (.yml files), you should push to a new
|
|
11
|
+
# branch and update BRANCH_PATH to that branch name
|
|
12
|
+
|
|
13
|
+
# Custom variables for our tests
|
|
14
|
+
|
|
15
|
+
BRANCH_PATH=v5
|
|
16
|
+
USER1_EMAIL=<ask @niharikasingh>
|
|
17
|
+
USER1_PASSWORD=<ask @niharikasingh>
|
|
18
|
+
NORMAL_USER_EMAIL=<tbd>
|
|
19
|
+
NORMAL_USER_PASSWORD=<tbd>
|
|
20
|
+
NORMAL_USER_API_KEY=<tbd>
|
|
21
|
+
WRONG_EMAIL=wrong_email@example.com
|
|
22
|
+
WRONG_PASSWORD=wrong_password
|
|
23
|
+
INVALID_API_KEY=invalidAPIkey
|
|
24
|
+
SECRET_VAR1=secret-var1-value
|
|
25
|
+
SECRET_VAR2=secret-var2-value
|
|
26
|
+
SECRET_FOR_MISSING_FIELD=secret for missing field
|
|
27
|
+
SECRET_INVALID_THERE_IS_ANOTHER=invalid value for there_is_another
|
|
28
|
+
EMPTY_STRING=
|
|
29
|
+
_ORIGIN=local
|
|
@@ -45,13 +45,15 @@ jobs:
|
|
|
45
45
|
#### keyword or values at all. See
|
|
46
46
|
#### https://assemblyline.suffolklitlab.org/docs/alkiln/writing#env-vars
|
|
47
47
|
env:
|
|
48
|
+
NORMAL_USER_EMAIL: alkiln@example.com
|
|
49
|
+
NORMAL_USER_PASSWORD: User123^
|
|
50
|
+
WRONG_EMAIL: wrong_email@example.com
|
|
51
|
+
WRONG_PASSWORD: wrong_password
|
|
52
|
+
INVALID_API_KEY: invalidAPIkey
|
|
53
|
+
EMPTY_STRING: ""
|
|
48
54
|
SECRET_VAR1: secret-var1-value
|
|
49
55
|
SECRET_VAR2: secret-var2-value
|
|
50
56
|
SECRET_FOR_MISSING_FIELD: secret for missing field
|
|
51
|
-
INVALID_API_KEY: invalidAPIkey
|
|
52
|
-
EMPTY_STRING: ""
|
|
53
|
-
USER_NO_PERMISSIONS_EMAIL: alkiln@example.com
|
|
54
|
-
USER_NO_PERMISSIONS_PASSWORD: User123^
|
|
55
57
|
|
|
56
58
|
steps:
|
|
57
59
|
# Place the root directory in this branch to access
|
|
@@ -91,8 +93,8 @@ jobs:
|
|
|
91
93
|
-H 'Content-Type: application/json' \
|
|
92
94
|
-d '{
|
|
93
95
|
"key": "${{ env.KEY }}",
|
|
94
|
-
"username": "${{ env.
|
|
95
|
-
"password": "${{ env.
|
|
96
|
+
"username": "${{ env.NORMAL_USER_EMAIL }}",
|
|
97
|
+
"password": "${{ env.NORMAL_USER_PASSWORD }}"
|
|
96
98
|
}')
|
|
97
99
|
echo "User data:"
|
|
98
100
|
echo "$user_data"
|
|
@@ -113,7 +115,7 @@ jobs:
|
|
|
113
115
|
unquoted="${no_end_quote#\"}"
|
|
114
116
|
echo "unquoted: $unquoted"
|
|
115
117
|
|
|
116
|
-
echo "
|
|
118
|
+
echo "NORMAL_USER_API_KEY=$unquoted" >> "$GITHUB_ENV"
|
|
117
119
|
|
|
118
120
|
#### Developer note: You can probably leave this out
|
|
119
121
|
## Optional debugging to explore things like docker issues
|
|
@@ -158,7 +160,7 @@ jobs:
|
|
|
158
160
|
#### Developer note: You can probably leave the rest out
|
|
159
161
|
#### To learn more, see https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
|
|
160
162
|
ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
|
|
161
|
-
ALKILN_VERSION:
|
|
163
|
+
ALKILN_VERSION: logs
|
|
162
164
|
|
|
163
165
|
#### Developer note: Example of making an issue when tests fail
|
|
164
166
|
#### that includes the text of the failure output file
|
|
@@ -167,7 +169,7 @@ jobs:
|
|
|
167
169
|
if: ${{ failure() }}
|
|
168
170
|
env:
|
|
169
171
|
GH_TOKEN: ${{ github.token }}
|
|
170
|
-
|
|
172
|
+
PATH_TO_REPORT_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_REPORT_LOG_FILE }}"
|
|
171
173
|
PATH_TO_UNEXPECTED_RESULTS_FILE: "${{ steps.alkiln.outputs.PATH_TO_UNEXPECTED_RESULTS_FILE }}"
|
|
172
174
|
PATH_TO_DEBUG_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_DEBUG_LOG_FILE }}"
|
|
173
175
|
run: |
|
|
@@ -43,10 +43,12 @@ jobs:
|
|
|
43
43
|
PLAYGROUND_ID: ${{ secrets.PLAYGROUND_ID }}
|
|
44
44
|
USER1_EMAIL: ${{ secrets.USER1_EMAIL }}
|
|
45
45
|
USER1_PASSWORD: ${{ secrets.USER1_PASSWORD }}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
NORMAL_USER_EMAIL: ${{ secrets.USER_NO_PERMISSIONS_EMAIL }}
|
|
47
|
+
NORMAL_USER_PASSWORD: ${{ secrets.USER_NO_PERMISSIONS_PASSWORD }}
|
|
48
|
+
NORMAL_USER_API_KEY: ${{ secrets.USER_NO_PERMISSIONS_API_KEY }}
|
|
49
49
|
INVALID_API_KEY: invalidAPIkey
|
|
50
|
+
WRONG_EMAIL: wrong_email@example.com
|
|
51
|
+
WRONG_PASSWORD: wrong_password
|
|
50
52
|
EMPTY_STRING: ""
|
|
51
53
|
SECRET_VAR1: secret-var1-value
|
|
52
54
|
SECRET_VAR2: secret-var2-value
|
|
@@ -77,6 +79,6 @@ jobs:
|
|
|
77
79
|
# Internal: docassemble changes sometimes break @a11y tests. That is
|
|
78
80
|
# a da problem, not ours. We will trigger these tests manually when we
|
|
79
81
|
# want to check up on this.
|
|
80
|
-
ALKILN_TAG_EXPRESSION: "
|
|
82
|
+
ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
|
|
81
83
|
#### Developer note: You can probably leave this out
|
|
82
|
-
ALKILN_VERSION:
|
|
84
|
+
ALKILN_VERSION: logs
|
package/CHANGELOG.md
CHANGED
|
@@ -47,18 +47,43 @@ Format:
|
|
|
47
47
|
|
|
48
48
|
### Changed
|
|
49
49
|
|
|
50
|
+
- Moves "expected" status error to only be visible to internal test errors. Closes [#933](https://github.com/SuffolkLITLab/ALKiln/issues/933).
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- Detects failed sign in. Closes [#918](https://github.com/SuffolkLITLab/ALKiln/issues/918).
|
|
55
|
+
|
|
56
|
+
### Internal
|
|
57
|
+
|
|
58
|
+
- Improved checks of log codes - more robust and flexible. See [#920](https://github.com/SuffolkLITLab/ALKiln/issues/920).
|
|
59
|
+
- Returns report text from `.addToReport()` so it can be used again for error messages.
|
|
60
|
+
- Update puppeteer to v22.15.0. Closes [#930](https://github.com/SuffolkLITLab/ALKiln/issues/930).
|
|
61
|
+
- Update npm vulnerabilities except pdfjs-dist. See docs/decisions/pdfjs_version_2024_08_08.md.
|
|
62
|
+
- Adds decision docs
|
|
63
|
+
- Updated CONTRIBUTING.md
|
|
64
|
+
- Added example.env, closes [#374](https://github.com/SuffolkLITLab/ALKiln/issues/374)
|
|
65
|
+
|
|
66
|
+
## [5.13.0] - 2024-07-11
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- Authors can now make sure that ALKiln deletes the interviews it creates for an ALKiln testing account. They can add a new (optional) value, an API key, to [the "sign in" Step](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sign-in) and use the ["start interview" Step](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#start-interview) to go to the interview. The API key must belong to the user who signs in. Example: `Given I sign in with the email "<username env var>", the password "<password env var>", and the API key "<user API key>`. Admins can create an API key for a regular user with https://docassemble.org/docs/api.html#api_user_user_id_api_post. We will add this to the documentation for the "sign in" Step.
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
|
|
50
74
|
- Update links in logs to new Suffolk docs pages
|
|
51
75
|
|
|
52
76
|
### Fixed
|
|
53
77
|
|
|
54
|
-
- Now ALKiln deletes interviews upon interview completion for [signed in users](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sign-in) as long as the user has an API key. Also, the author must have used the ["start interview" Step](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#start-interview) to get to the interview. Admins can give a regular user
|
|
78
|
+
- Now ALKiln deletes interviews upon interview completion for [signed in users](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sign-in) as long as the user has an API key. Also, the author must have used the ["start interview" Step](https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#start-interview) to get to the interview. Admins can give an API key to a regular user with https://docassemble.org/docs/api.html#api_user_user_id_api_post. See [#831](https://github.com/SuffolkLITLab/ALKiln/issues/831).
|
|
55
79
|
|
|
56
80
|
### Internal
|
|
57
81
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
82
|
+
- Tests deleting interviews upon interview completion for signed in users.
|
|
83
|
+
- Switches to mostly using a lowest-access-level user account for actually running interviews.
|
|
84
|
+
- Switches to adding our own `users[0]` question because of changes in Assembly Line.
|
|
85
|
+
- Adds @temp_error to neutralize tests that are getting undesired errors right now, but which we anticipate being fixed soon. We want to ignore them for a short while. For example, an upstream change temporarily breaking some tests.
|
|
86
|
+
- Excludes docassemble/ALKiln files from log code checks.
|
|
62
87
|
|
|
63
88
|
## [5.12.0] - 2024-06-06
|
|
64
89
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -33,90 +33,83 @@ Before making a pull request
|
|
|
33
33
|
1. Wait for the GitHub tests to pass. You may have to re-run failing tests—server restarts or race conditions may interfere with them. We have reduced them greatly, but some are impossible to avoid.
|
|
34
34
|
1. Make your pull request. Work in progress pull requests are great too. A pull request must be reviewed before it can be merged.
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Running internal tests
|
|
37
|
+
|
|
38
|
+
### Setup and takedown
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
Only run this the first time you run our internal tests. That will install the code that you will test onto the docassemble server:
|
|
39
41
|
|
|
40
42
|
```bash
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
DOCASSEMBLE_DEVELOPER_API_KEY=<ask @niharikasingh>
|
|
44
|
-
SERVER_URL=https://apps-dev.suffolklitlab.org
|
|
45
|
-
REPO_URL=https://github.com/SuffolkLITLab/alkiln
|
|
46
|
-
SERVER_RELOAD_TIMEOUT_SECONDS=
|
|
47
|
-
MAX_SECONDS_FOR_SETUP=
|
|
48
|
-
|
|
49
|
-
# For internal tests
|
|
50
|
-
|
|
51
|
-
# Set DEBUG to 1 to run in non-headless mode and see the test run live
|
|
52
|
-
DEBUG=
|
|
53
|
-
# If you edit interview files (.yml files), you should push to a new
|
|
54
|
-
# branch and update BRANCH_PATH to that branch name
|
|
55
|
-
BRANCH_PATH=v4
|
|
56
|
-
USER1_EMAIL=<ask @niharikasingh>
|
|
57
|
-
USER1_PASSWORD=<ask @niharikasingh>
|
|
58
|
-
SECRET_VAR1=secret-var1-value
|
|
59
|
-
SECRET_VAR2=secret-var2-value
|
|
60
|
-
SECRET_FOR_MISSING_FIELD=secret for missing field
|
|
61
|
-
SECRET_INVALID_THERE_IS_ANOTHER=invalid value for there_is_another
|
|
43
|
+
npm run setup
|
|
62
44
|
```
|
|
63
45
|
|
|
64
|
-
|
|
46
|
+
If you run `takedown`, you will then have to run `setup` again:
|
|
65
47
|
|
|
66
|
-
|
|
48
|
+
```bash
|
|
49
|
+
npm run takedown
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Use the syntax below to trigger all tests that should be passing[^1] (`pass` and unit tests):
|
|
67
53
|
|
|
68
54
|
```bash
|
|
69
|
-
npm run
|
|
55
|
+
npm run test
|
|
70
56
|
```
|
|
71
57
|
|
|
72
|
-
|
|
58
|
+
Run only cucumber tests that should pass:
|
|
73
59
|
|
|
74
|
-
|
|
60
|
+
```bash
|
|
61
|
+
npm run pass
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run deliberately failing cucumber tests:
|
|
75
65
|
|
|
76
66
|
```bash
|
|
77
|
-
npm run
|
|
67
|
+
npm run fail
|
|
78
68
|
```
|
|
79
69
|
|
|
80
|
-
Run
|
|
70
|
+
Run all cucumber tests, even those that are incorrectly failing:
|
|
81
71
|
|
|
82
72
|
```bash
|
|
83
73
|
npm run cucumber
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run tests with specific cucumber tags or tag expressions:
|
|
84
77
|
|
|
85
|
-
|
|
86
|
-
npm run cucumber
|
|
78
|
+
```bash
|
|
79
|
+
npm run cucumber @tagname
|
|
87
80
|
```
|
|
88
81
|
|
|
89
|
-
|
|
82
|
+
Run only unit tests:
|
|
90
83
|
|
|
91
84
|
```bash
|
|
92
85
|
npm run unit
|
|
93
86
|
```
|
|
94
87
|
|
|
95
|
-
If you or someone else changes the interview code in `./docassemble`, you have to clean up the old
|
|
88
|
+
If you or someone else changes the interview code in `./docassemble/ALKilnTests/data/questions/*.yml`, you have to clean up the old code on the server before running `setup` again:
|
|
96
89
|
|
|
97
90
|
```bash
|
|
98
91
|
npm run takedown
|
|
99
92
|
```
|
|
100
93
|
|
|
101
|
-
##
|
|
94
|
+
## Updating dependencies
|
|
95
|
+
|
|
96
|
+
To add or update a dependency, edit `package.json` with an exact version. That means avoid notations like `^`, `~`, and `x`. Then run `npm install` and `npm shrinkwrap` to update `npm-shrinkwrap.json`.
|
|
97
|
+
|
|
98
|
+
## How one type of GitHub setup runs tests
|
|
102
99
|
|
|
103
|
-
Our tests require the user/developer to have a docassemble server on which they host these interviews (online forms) and at least one developer account. With our help, our users set up the tests to run when they commit new code
|
|
100
|
+
Our tests require the user/interview author/developer to have a docassemble server on which they host these interviews (online forms) and at least one developer account. With our help, our users set up the tests to run when they commit new code to GitHub. When these GitHub tests run, ALKiln does the following:
|
|
104
101
|
|
|
105
|
-
1. Sets up on the docassemble server.
|
|
106
|
-
1.
|
|
107
|
-
1. Pulls in the code from
|
|
102
|
+
1. Sets up on the docassemble server.
|
|
103
|
+
1. In a given docassemble developer account's Playground it creates a new Project.
|
|
104
|
+
1. Pulls in the code from the given branch into the new Project.
|
|
108
105
|
1. Runs the tests
|
|
109
|
-
1. Pretends to be an anonymous account that comes to the form and inputs answers.
|
|
110
|
-
1. Writes up reports and
|
|
111
|
-
1. Cleans up by deleting the
|
|
106
|
+
1. Pretends to be an anonymous or signed-in account that comes to the form and inputs answers.
|
|
107
|
+
1. Writes up reports and creates other artifacts to show to the developer.
|
|
108
|
+
1. Cleans up by deleting the Project it created.
|
|
112
109
|
|
|
113
110
|
When the developer commits code to GitHub, their account triggers our code, passing along variables that our code needs, like their GitHub secret of the API key for their docassemble server developer account.
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Sometimes you will have to add dependencies to ALKiln. You can do so by adding the dependency in the `package.json` "dependencies" section, specifying an exact version. Then, run `npm install` to update `npm-shrinkwrap.json` to have the new dependency.
|
|
118
|
-
|
|
119
|
-
If you have to update an existing dependency, you can change the version in `package.json`, and run `npm install` to update `npm-shrankwrap.json`.
|
|
112
|
+
There are [other kinds of test you can read more about in the user documentation](https://assemblyline.suffolklitlab.org/docs/alkiln/setup). The differences can be subtle and hard to explain, but they each have their pros and cons.
|
|
120
113
|
|
|
121
114
|
## Very general architecture of files and folders
|
|
122
115
|
|
|
@@ -124,24 +117,7 @@ An honest look at our current project architecture—some of our files and folde
|
|
|
124
117
|
|
|
125
118
|
### Logic architecture
|
|
126
119
|
|
|
127
|
-
ALKiln uses [cucumber](https://cucumber.io/docs/installation/javascript/)[^
|
|
128
|
-
|
|
129
|
-
#### .feature files
|
|
130
|
-
|
|
131
|
-
The `.feature` files are written in Gherkin, a syntax cucumber uses. The "code" in there relies on the functions set up in `./lib/steps.js`.
|
|
132
|
-
|
|
133
|
-
```js
|
|
134
|
-
// The test_something.feature file step
|
|
135
|
-
Then I sign
|
|
136
|
-
|
|
137
|
-
// relies on the code in steps.js
|
|
138
|
-
Then('I sign', { timeout: -1 }, async () => {
|
|
139
|
-
return wrapPromiseWithTimeout(
|
|
140
|
-
scope.steps.sign( scope ),
|
|
141
|
-
scope.timeout
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
```
|
|
120
|
+
ALKiln uses [cucumber](https://cucumber.io/docs/installation/javascript/)[^2] with [Gherkin](https://cucumber.io/docs/gherkin/reference/) syntax, [puppeteer](https://pptr.dev/), and [chai](https://www.chaijs.com/).
|
|
145
121
|
|
|
146
122
|
#### steps.js
|
|
147
123
|
|
|
@@ -170,42 +146,81 @@ The file handles things like:
|
|
|
170
146
|
* Checking for server restarts
|
|
171
147
|
* Generating test report content
|
|
172
148
|
|
|
173
|
-
|
|
149
|
+
#### Setup and takedown logic
|
|
174
150
|
|
|
175
|
-
|
|
151
|
+
All of the setup and takedown logic is in the `./lib/docassemble` directory. It is named after the docassemble API code that is in there. Setup and takedown interact very closely with docassemble and the docassemble server API.
|
|
176
152
|
|
|
177
|
-
###
|
|
153
|
+
### .env
|
|
178
154
|
|
|
179
|
-
|
|
155
|
+
You need to copy [our `.env.example` file](https://github.com/SuffolkLITLab/ALKiln/blob/HEAD/.env.example). It has sensitive variables, like passwords. It also has custom values our tests need. Contact us to get involved with the project and get the sensitive information. We need to use environment variables in the same way our users do when they run their workflow files in their GitHub action. At the moment, it is the only way to pass values into ALKiln from a GitHub action.
|
|
180
156
|
|
|
181
|
-
###
|
|
157
|
+
### GitHub composite actions
|
|
182
158
|
|
|
183
|
-
|
|
159
|
+
Our `./action.yml` and `action_for_github_server/action.yml` are [composite actions](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action). The GitHub workflow files are there to trigger the code in these files. These composite actions install npm, install ALKiln. They execute the scripts in our `package.json` to set up the tests, run them, save the output of the tests - artifacts reports, errors, screenshots, etc. - clean up the tests, and output the reports back to the author's workflow files.
|
|
184
160
|
|
|
185
|
-
|
|
161
|
+
### Internal tests
|
|
186
162
|
|
|
187
|
-
|
|
163
|
+
We have our own docassemble package inside our repo `./docassemble` folder to test our own code with its own interview files and `.feature` test files.
|
|
188
164
|
|
|
189
|
-
|
|
165
|
+
There are other files the docassemble package needs, like `./setup.py`, so if you see them around, don't worry about them.
|
|
190
166
|
|
|
191
|
-
|
|
167
|
+
If you want to run the tests, you can go to the [instructions for running tests section](#running-internal-tests) in this README.
|
|
192
168
|
|
|
193
|
-
|
|
169
|
+
#### .feature and .yml files
|
|
194
170
|
|
|
195
|
-
|
|
171
|
+
The `.feature` are in `./docassemble/ALKilnTests/data/sources/*.feature`. They're written in Gherkin, a syntax cucumber uses. The "code" in there relies on the functions set up in `./lib/steps.js`. For example:
|
|
196
172
|
|
|
197
|
-
|
|
173
|
+
```js
|
|
174
|
+
// The test_something.feature file Step
|
|
175
|
+
Then I sign
|
|
198
176
|
|
|
199
|
-
|
|
177
|
+
// relies on the code in steps.js
|
|
178
|
+
Then('I sign', { timeout: -1 }, async () => {
|
|
179
|
+
return wrapPromiseWithTimeout(
|
|
180
|
+
scope.steps.sign( scope ),
|
|
181
|
+
scope.timeout
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
```
|
|
200
185
|
|
|
201
|
-
|
|
186
|
+
See [the documentation](https://assemblyline.suffolklitlab.org/docs/alkiln/writing) for other examples.
|
|
202
187
|
|
|
203
|
-
|
|
188
|
+
The `.yml` interviews (online forms) those tests go to are in `./docassemble/ALKilnTests/data/questions/*.yml`.
|
|
204
189
|
|
|
205
|
-
|
|
190
|
+
#### Unit tests
|
|
191
|
+
|
|
192
|
+
Our unit tests are in `./tests/unit_tests` and their filenames end in `.test.js`. Like some of the cucumber Steps, they use chai for assertions. The fixtures for the tests are also contained in that folder and end in `.fixtures.js`.
|
|
193
|
+
|
|
194
|
+
We also validate our log codes. Log codes help identify specific messages the user gets. An example of a log code is `ALK0105`. We want to avoid repeating or leaving out log code numbers, so we check those log codes before pushing or merging. That test, a bash file, is also in `./tests/unit_tests`.
|
|
195
|
+
|
|
196
|
+
#### GitHub workflow files
|
|
197
|
+
|
|
198
|
+
Like our users, we use GitHub workflow files in `.github/workflows` to trigger the ALKiln composite actions. These files do their best to act as the most up-to-date demonstration of what an ALKiln workflow file can look like. They contain notes for our users to try to help them adjust the code to their purposes. It's not ideal, but they're the files that we can update most reliably.
|
|
199
|
+
|
|
200
|
+
Those files use [environment variables that store sensitive information and custom variables](#env).
|
|
201
|
+
|
|
202
|
+
We also use workflow files to trigger our unit tests and our log codes validation.
|
|
203
|
+
|
|
204
|
+
### Logging
|
|
205
|
+
|
|
206
|
+
`./lib/utils/log.js` and `./lib/utils/reports.js` take care of logging information of various kinds (normal, debug, error) to the command line in ways we hope are useful, as well as building files to store the same information. We should probably find a logging library instead, but this is what we have for now. An important feature is that it ensures the messages clearly belong to ALKiln and not to some other process.
|
|
207
|
+
|
|
208
|
+
### session_vars.js
|
|
209
|
+
|
|
210
|
+
The `./lib/utils/session_var.js` file keeps track of what you might otherwise think of as environment variables. We like to think of them as constants, but some of them do need to go through functions, so for consistency we get them all through functions. It is also easier to test them when they are functions.
|
|
211
|
+
|
|
212
|
+
### Bash commands
|
|
213
|
+
|
|
214
|
+
ALKiln is a command line tool to avoid some complexity in GitHub actions, increase security, and align with what this framework has grown into. When you `npm run` the scripts in our `./package.json` they will setup, run, or take down tests.
|
|
215
|
+
|
|
216
|
+
### Files that you probably don't need to look at
|
|
206
217
|
|
|
207
218
|
`index.js` and `world.js` are short files that cucumber needs.
|
|
208
219
|
|
|
209
220
|
## Footnotes
|
|
210
221
|
|
|
211
|
-
[1]
|
|
222
|
+
[^1]: Some of our tests are sometimes in a failing state. For example, at times docassemble has changed its behavior and accessibility tests have failed. Those problems take a while to update and in the meantime we still need to continue development. For that reason, we sometimes mark tests with the tag `@temp_error`.
|
|
223
|
+
</br></br>We have tests that pass when they cause errors. They let us test our own error messages and error behavior. They will log an `F` in the console and yet those Scenarios will still pass.
|
|
224
|
+
</br></br>We also have some tests that cause actual errors so we can see their proper behavior. We have to run those manually and we avoid running them on GitHub. They have the tag `@error`.
|
|
225
|
+
|
|
226
|
+
[^2]: To be clear, our framework is a misuse of cucumberjs. cucumberjs is geared towards behavior driven development. We try to make BDD available to our developers, but it's not always possible and not necessarily our goal.
|