@suffolklitlab/alkiln 5.12.0 → 5.13.0-logs2

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.
Files changed (38) hide show
  1. package/.env.example +29 -0
  2. package/.github/workflows/github_server.yml +59 -12
  3. package/.github/workflows/playground.yml +11 -4
  4. package/CHANGELOG.md +41 -1
  5. package/CONTRIBUTING.md +98 -83
  6. package/README.md +1 -1
  7. package/action.yml +69 -29
  8. package/action_for_github_server/action.yml +65 -31
  9. package/docs/decisions/006_which_log_level_to_pick_2024_09_5.md +46 -0
  10. package/docs/decisions/adopt_architectural_decision_records.md +58 -0
  11. package/docs/decisions/detect_sign_in.md +124 -0
  12. package/docs/decisions/pdfjs_version_2024_08_08.md +18 -0
  13. package/docs/decisions/reports_and_logs_2024_08_11.md +141 -0
  14. package/docs/decisions/update_puppeteer_2024_07_28.md +62 -0
  15. package/docs/story_tables.md +1 -1
  16. package/lib/docassemble/docassemble_api_REST.js +67 -1
  17. package/lib/docassemble/docassemble_api_interface.js +225 -18
  18. package/lib/docassemble/server_install.js +23 -9
  19. package/lib/docassemble/setup.js +33 -20
  20. package/lib/docassemble/takedown.js +27 -7
  21. package/lib/run_cucumber.js +83 -33
  22. package/lib/scope.js +222 -82
  23. package/lib/steps.js +206 -62
  24. package/lib/utils/files.js +8 -6
  25. package/lib/utils/log.js +477 -84
  26. package/lib/utils/reports.js +14 -5
  27. package/lib/utils/session_vars.js +25 -18
  28. package/lib/utils/time.js +44 -0
  29. package/npm-shrinkwrap.json +635 -193
  30. package/package.json +8 -8
  31. package/setup.py +1 -1
  32. package/tests/log_codes/check_codes.sh +163 -108
  33. package/tests/log_codes/log_code_expected_instances.txt +213 -0
  34. package/tests/unit_tests/getAllFields.test.js +5 -0
  35. package/tests/unit_tests/getMatchingRows.test.js +5 -0
  36. package/tests/unit_tests/log.test.js +20 -0
  37. package/tests/unit_tests/normalizeTable.test.js +5 -0
  38. 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
@@ -43,8 +43,14 @@ jobs:
43
43
  #### Developer note: You can probably leave out these specific
44
44
  #### environment variables. You may not even need the `env`
45
45
  #### keyword or values at all. See
46
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing#env-vars
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
@@ -54,7 +60,7 @@ jobs:
54
60
  # relative paths to action files
55
61
  - uses: actions/checkout@v4
56
62
 
57
- - name: ALKiln - Start the isolated temporary docassemble server on GitHub
63
+ - name: "ALKiln - Start the isolated temporary docassemble server on GitHub"
58
64
  id: github_server
59
65
  #### Developer note: you'll need to replace `uses: ./action_for_github_server`
60
66
  #### with the path to ALKiln’s repository name and branch name. For example,
@@ -71,13 +77,54 @@ jobs:
71
77
  shell: bash
72
78
 
73
79
  #### Developer note: You can probably leave this out
74
- # # Optional debugging to explore things like docker issues
75
- # - name: Docker debug tmate session
76
- # if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
77
- # uses: mxschmitt/action-tmate@v3
80
+ - name: "Add a low-level user and their API key (in an env var)"
81
+ env:
82
+ SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
83
+ KEY: ${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}
84
+ run: |
85
+ # Create user and their API key
86
+
87
+ # Install json processor
88
+ sudo apt-get install jq
89
+
90
+ # https://docassemble.org/docs/api.html#user_new
91
+ user_data=$(curl -X POST \
92
+ ${{ env.SERVER_URL }}/api/user/new \
93
+ -H 'Content-Type: application/json' \
94
+ -d '{
95
+ "key": "${{ env.KEY }}",
96
+ "username": "${{ env.NORMAL_USER_EMAIL }}",
97
+ "password": "${{ env.NORMAL_USER_PASSWORD }}"
98
+ }')
99
+ echo "User data:"
100
+ echo "$user_data"
101
+
102
+ user_id=$(echo "$user_data" | jq '.user_id' -r)
103
+
104
+ # https://docassemble.org/docs/api.html#api_user_user_id_api_post
105
+ new_key_with_quotes=$(curl -X POST \
106
+ ${{ env.SERVER_URL }}/api/user/"$user_id"/api \
107
+ -H 'Content-Type: application/json' \
108
+ -d '{
109
+ "key": "${{ env.KEY }}",
110
+ "name": "alkiln_key",
111
+ "method": "none"
112
+ }')
113
+ echo "new key (watch out, this contains actual quotation marks): $new_key_with_quotes"
114
+ no_end_quote="${new_key_with_quotes%\"}"
115
+ unquoted="${no_end_quote#\"}"
116
+ echo "unquoted: $unquoted"
117
+
118
+ echo "NORMAL_USER_API_KEY=$unquoted" >> "$GITHUB_ENV"
119
+
120
+ #### Developer note: You can probably leave this out
121
+ ## Optional debugging to explore things like docker issues
122
+ #- name: Docker debug tmate session
123
+ # #if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
124
+ # uses: mxschmitt/action-tmate@v3
78
125
 
79
126
  #### Developer note: You can probably leave this out
80
- - name: Run ALKiln - Env vars for our own tests from server output
127
+ - name: "Create other env vars for our own tests from server output"
81
128
  run: |
82
129
  echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
83
130
  echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
@@ -103,17 +150,17 @@ jobs:
103
150
  # Internal: docassemble changes sometimes break @a11y tests. That is
104
151
  # a da problem, not ours. We will trigger these tests manually when we
105
152
  # want to check up on this.
106
- ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @a11y) and (not @error)' }}"
153
+ ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @error) and (not @temp_error)' }}"
107
154
  with:
108
155
  #### Developer note: Required inputs. See
109
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#sandbox-inputs
156
+ #### https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sandbox-inputs
110
157
  SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
111
158
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
112
159
  INSTALL_METHOD: "server"
113
160
  #### Developer note: You can probably leave the rest out
114
- #### To learn more, see https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#optional-inputs
161
+ #### To learn more, see https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
115
162
  ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
116
- ALKILN_VERSION: output
163
+ ALKILN_VERSION: logs
117
164
 
118
165
  #### Developer note: Example of making an issue when tests fail
119
166
  #### that includes the text of the failure output file
@@ -122,7 +169,7 @@ jobs:
122
169
  if: ${{ failure() }}
123
170
  env:
124
171
  GH_TOKEN: ${{ github.token }}
125
- PATH_TO_REPORT_FILE: "${{ steps.alkiln.outputs.PATH_TO_REPORT_FILE }}"
172
+ PATH_TO_REPORT_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_REPORT_LOG_FILE }}"
126
173
  PATH_TO_UNEXPECTED_RESULTS_FILE: "${{ steps.alkiln.outputs.PATH_TO_UNEXPECTED_RESULTS_FILE }}"
127
174
  PATH_TO_DEBUG_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_DEBUG_LOG_FILE }}"
128
175
  run: |
@@ -43,6 +43,13 @@ jobs:
43
43
  PLAYGROUND_ID: ${{ secrets.PLAYGROUND_ID }}
44
44
  USER1_EMAIL: ${{ secrets.USER1_EMAIL }}
45
45
  USER1_PASSWORD: ${{ secrets.USER1_PASSWORD }}
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
+ INVALID_API_KEY: invalidAPIkey
50
+ WRONG_EMAIL: wrong_email@example.com
51
+ WRONG_PASSWORD: wrong_password
52
+ EMPTY_STRING: ""
46
53
  SECRET_VAR1: secret-var1-value
47
54
  SECRET_VAR2: secret-var2-value
48
55
  SECRET_FOR_MISSING_FIELD: secret for missing field
@@ -61,17 +68,17 @@ jobs:
61
68
  - uses: ./
62
69
  #### Developer note: You can probably leave this out
63
70
  env:
64
- ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @a11y) and (not @error)' }}"
71
+ ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @error) and (not @temp_error)' }}"
65
72
  with:
66
73
  #### Developer note: Required ALKiln inputs. You can read more at
67
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#githubNyou-inputs
74
+ #### https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#githubNyou-inputs
68
75
  SERVER_URL: "${{ env.SERVER_URL }}"
69
76
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ env.DOCASSEMBLE_DEVELOPER_API_KEY }}"
70
- #### Developer note: See https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#optional-inputs
77
+ #### Developer note: See https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
71
78
  #### You can probably leave this out
72
79
  # Internal: docassemble changes sometimes break @a11y tests. That is
73
80
  # a da problem, not ours. We will trigger these tests manually when we
74
81
  # want to check up on this.
75
82
  ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
76
83
  #### Developer note: You can probably leave this out
77
- ALKILN_VERSION: output
84
+ ALKILN_VERSION: logs
package/CHANGELOG.md CHANGED
@@ -43,7 +43,47 @@ Format:
43
43
  -
44
44
  -->
45
45
 
46
- <!-- ## [Unreleased] -->
46
+ ## [Unreleased]
47
+
48
+ ### Changed
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
+
74
+ - Update links in logs to new Suffolk docs pages
75
+
76
+ ### Fixed
77
+
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).
79
+
80
+ ### Internal
81
+
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.
47
87
 
48
88
  ## [5.12.0] - 2024-06-06
49
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
- ## .env
36
+ ## Running internal tests
37
+
38
+ ### Setup and takedown
37
39
 
38
- You need to make your own `.env` file. It contains sensitive variables, like passwords. We use them for our internal tests. The file should look something like the below:
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
- # For everyone
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
- ## Running internal tests
46
+ If you run `takedown`, you will then have to run `setup` again:
65
47
 
66
- Only run this the first time you run tests in this repository to make the code available to test on the docassemble server:
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 setup
55
+ npm run test
70
56
  ```
71
57
 
72
- If you run `takedown`, you will then have to run `setup` again.
58
+ Run only cucumber tests that should pass:
73
59
 
74
- Use the syntax below to trigger all tests (cucumber and unit tests):
60
+ ```bash
61
+ npm run pass
62
+ ```
63
+
64
+ Run deliberately failing cucumber tests:
75
65
 
76
66
  ```bash
77
- npm run test
67
+ npm run fail
78
68
  ```
79
69
 
80
- Run only cucumber tests:
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
- # To test Features or Scenarios specific tags:
86
- npm run cucumber -- "--tags" "@tagname"
78
+ ```bash
79
+ npm run cucumber @tagname
87
80
  ```
88
81
 
89
- To run the unit tests in isolation:
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 data on the server before running `setup` again:
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
- ## How the tests run
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 or to run manually. When GitHub runs the tests, it does the following:
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. In a given developer account:
106
- 1. Creates a new interview for this particular branch of the repository.
107
- 1. Pulls in the code from that branch into the docassemble server.
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 possibly takes screenshots to show to the developer.
111
- 1. Cleans up by deleting the interview it created
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
- ## Updating dependencies
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/)[^1] with [Gherkin](https://cucumber.io/docs/gherkin/reference/) syntax, [puppeteer](https://pptr.dev/), and [chai](https://www.chaijs.com/).
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
- ### Logging
149
+ #### Setup and takedown logic
174
150
 
175
- `./lib/utils/log.js` takes care of logging information of various kinds (normal, debug, error) to the command line in ways we hope are useful. 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.
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
- ### session_vars.js
153
+ ### .env
178
154
 
179
- 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. Also because it was easier to test them when they are functions.
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
- ### Setup and takedown logic
157
+ ### GitHub composite actions
182
158
 
183
- 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. Also, setup and takedown interact very closely with docassemble and the docassemble server.
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
- Other files also use the docassemble API functions, so this folder is in a bit of a messy position.
161
+ ### Internal tests
186
162
 
187
- ### Bash commands
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
- When you `npm run` the scripts in our `./package.json` you can setup, run, or takedown tests. We are working on converting this to a command line tool to avoid some complexity in GitHub actions, increase security, and align more with what this framework has grown into. (TODO: Define this better)
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
- ### GitHub composite action
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
- Our `./action.yml` is a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action). The users/developers let it do most of the work for them. It installs npm, installs our repo, then uses our repo to set up the tests, run the tests, generate and save reports, errors, and screenshots, and clean up the tests.
169
+ #### .feature and .yml files
194
170
 
195
- ### Internal tests
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
- We have our own docassemble package in our repo to test our own end-to-end tests. Most of what the package needs is in `./docassemble`. That docassemble package is what the test setup pulls into the docassemble server. Our internal end-to-end cucumber tests are `.feature` files that are stored in `./docassemble/ALKilnTests/data/sources`. The interview (online form) `.yml` files that those `.feature` files use are also deep in the `./docassemble` package. You probably won't be touching the interview files. If you get curious, feel free to ask us.
173
+ ```js
174
+ // The test_something.feature file Step
175
+ Then I sign
198
176
 
199
- There are other files the docassemble package needs, like `./setup.py`, so if you see them around, don't worry about them.
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
- Our unit tests are in `./tests/unit_tests` and their filenames end in `.test.js`. Like the cucumber tests, they use chai for assertions. The fixtures for the tests are also contained in that folder and end in `.fixtures.js`.
186
+ See [the documentation](https://assemblyline.suffolklitlab.org/docs/alkiln/writing) for other examples.
202
187
 
203
- If you want to know the commands, you can go to the [instructions for running tests](#running-internal-tests).
188
+ The `.yml` interviews (online forms) those tests go to are in `./docassemble/ALKilnTests/data/questions/*.yml`.
204
189
 
205
- ### Files that you don't need to look at
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] 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.
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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ https://github.com/18F/open-source-guide/blob/18f-pages/pages/making-readmes-rea
12
12
 
13
13
  ## Use ALKiln
14
14
 
15
- Read about how to use this framework in [Assembly Line's documentation](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing/).
15
+ Read about how to use [this framework in Assembly Line's documentation](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/intro).
16
16
 
17
17
  If you have questions or need to report a bug, [start a new issue](https://github.com/SuffolkLITLab/ALKiln/issues/new).
18
18