@suffolklitlab/alkiln 5.13.0 → 5.13.1-fix-download-name
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 +7 -5
- package/.github/workflows/playground.yml +5 -3
- package/CHANGELOG.md +28 -2
- package/CONTRIBUTING.md +98 -83
- package/README.md +26 -5
- 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/update_puppeteer_2024_07_28.md +62 -0
- package/lib/scope.js +162 -36
- package/lib/steps.js +17 -12
- package/lib/utils/reports.js +1 -1
- package/lib/utils/session_vars.js +1 -1
- package/npm-shrinkwrap.json +647 -201
- package/package.json +6 -6
- package/tests/log_codes/check_codes.sh +162 -108
- package/tests/log_codes/log_code_expected_instances.txt +209 -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
|
|
@@ -50,8 +50,10 @@ jobs:
|
|
|
50
50
|
SECRET_FOR_MISSING_FIELD: secret for missing field
|
|
51
51
|
INVALID_API_KEY: invalidAPIkey
|
|
52
52
|
EMPTY_STRING: ""
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
NORMAL_USER_EMAIL: alkiln@example.com
|
|
54
|
+
NORMAL_USER_PASSWORD: User123^
|
|
55
|
+
WRONG_EMAIL=wrong_email@example.com
|
|
56
|
+
WRONG_PASSWORD=wrong_password
|
|
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
|
|
@@ -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
|
package/CHANGELOG.md
CHANGED
|
@@ -43,11 +43,37 @@ Format:
|
|
|
43
43
|
-
|
|
44
44
|
-->
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
## [Unreleased]
|
|
47
|
+
|
|
48
|
+
<!-- ## [5.13.2] - 2024-11-21 -->
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- Fixes download Step unable to use a partial filename match. The Step needed the whole name, including the extension. See [#725](https://github.com/SuffolkLITLab/ALKiln/issues/725).
|
|
52
|
+
|
|
53
|
+
## [5.13.1] - 2024-10-23
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Moves "expected" status error to only be visible to internal test errors. Closes [#933](https://github.com/SuffolkLITLab/ALKiln/issues/933).
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- Detects failed sign in. Closes [#918](https://github.com/SuffolkLITLab/ALKiln/issues/918).
|
|
62
|
+
|
|
63
|
+
### Internal
|
|
64
|
+
|
|
65
|
+
- Improved checks of log codes - more robust and flexible. See [#920](https://github.com/SuffolkLITLab/ALKiln/issues/920).
|
|
66
|
+
- Returns report text from `.addToReport()` so it can be used again for error messages.
|
|
67
|
+
- Update puppeteer to v22.15.0. Closes [#930](https://github.com/SuffolkLITLab/ALKiln/issues/930).
|
|
68
|
+
- Update npm vulnerabilities except pdfjs-dist. See docs/decisions/pdfjs_version_2024_08_08.md.
|
|
69
|
+
- Adds decision docs
|
|
70
|
+
- Updated CONTRIBUTING.md
|
|
71
|
+
- Added example.env, closes [#374](https://github.com/SuffolkLITLab/ALKiln/issues/374)
|
|
72
|
+
- Updates pdfjs-dist for node v20 and v22. See [#952](https://github.com/SuffolkLITLab/ALKiln/issues/952).
|
|
47
73
|
|
|
48
74
|
## [5.13.0] - 2024-07-11
|
|
49
75
|
|
|
50
|
-
|
|
76
|
+
### Added
|
|
51
77
|
|
|
52
78
|
- 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.
|
|
53
79
|
|
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.
|
package/README.md
CHANGED
|
@@ -41,25 +41,46 @@ Read about contributing in our [CONTRIBUTING.md document](CONTRIBUTING.md). Here
|
|
|
41
41
|
## Cheat sheet
|
|
42
42
|
|
|
43
43
|
*Once you've already read the contributing documentation, you can use these as quick reminders for running our internal tests.*
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
### `setup` before starting development of a feature/fix
|
|
46
|
+
|
|
47
|
+
Set up for the cucumber integration tests.
|
|
48
|
+
|
|
49
|
+
Add the feature branch name to your `.env` file:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
BRANCH=42_feat_life_the_univers_and_everything
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then create the project on the server:
|
|
45
56
|
|
|
46
57
|
```bash
|
|
47
58
|
npm run setup
|
|
48
59
|
```
|
|
49
60
|
|
|
50
|
-
|
|
61
|
+
### Run tests repeatedly
|
|
62
|
+
|
|
63
|
+
Run all cucumber tests that are not currently blocked by upstream changes:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm run pass
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Trigger cucumber tests with specific tags:
|
|
51
70
|
|
|
52
71
|
```bash
|
|
53
|
-
npm run cucumber
|
|
72
|
+
npm run cucumber "@tagname"
|
|
54
73
|
```
|
|
55
74
|
|
|
56
|
-
|
|
75
|
+
Run the unit tests:
|
|
57
76
|
|
|
58
77
|
```bash
|
|
59
78
|
npm run unit
|
|
60
79
|
```
|
|
61
80
|
|
|
62
|
-
|
|
81
|
+
### Always run `takedown` before running `setup` again
|
|
82
|
+
|
|
83
|
+
If you or someone else changes the interview code in our `./docassemble` directory, you have to delete the code currently on the testing server before running `setup` again. Also do this when you're done with the feature/fix or starting a new feature/fix.
|
|
63
84
|
|
|
64
85
|
```bash
|
|
65
86
|
npm run takedown
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Document decisions
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
What is a good way to avoid re-hashing old decisions, or to at least know why those decisions were made?
|
|
6
|
+
|
|
7
|
+
## Considered Options
|
|
8
|
+
|
|
9
|
+
- GitHub issues
|
|
10
|
+
- GitHub discussions
|
|
11
|
+
- Actual files in the repo
|
|
12
|
+
|
|
13
|
+
Formats:
|
|
14
|
+
- https://adr.github.io/madr
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Decision Outcome
|
|
18
|
+
|
|
19
|
+
Use in-repo .md files using the https://adr.github.io/madr format. We found keeping the data within the repo to be the most compelling factor.
|
|
20
|
+
|
|
21
|
+
## Pros and Cons of the Options
|
|
22
|
+
|
|
23
|
+
### GitHub issues
|
|
24
|
+
|
|
25
|
+
Pros:
|
|
26
|
+
|
|
27
|
+
- Easy to search.
|
|
28
|
+
- Can add labels and such.
|
|
29
|
+
- In one of the most common places to search.
|
|
30
|
+
- Allows comments
|
|
31
|
+
|
|
32
|
+
Cons:
|
|
33
|
+
|
|
34
|
+
- Not actually in the repository, so any forks or clones would lose that info.
|
|
35
|
+
- Comments can get confusing and hard to read.
|
|
36
|
+
|
|
37
|
+
### GitHub discussions
|
|
38
|
+
|
|
39
|
+
Pros:
|
|
40
|
+
|
|
41
|
+
- Labels and such.
|
|
42
|
+
- Probably easy to search?
|
|
43
|
+
|
|
44
|
+
Cons:
|
|
45
|
+
|
|
46
|
+
- A separate place from issues. Not everyone even knows those exist.
|
|
47
|
+
- All the cons of GitHub issues
|
|
48
|
+
|
|
49
|
+
### Actual files in the repo
|
|
50
|
+
|
|
51
|
+
Pros:
|
|
52
|
+
|
|
53
|
+
- They go everywhere the repo goes.
|
|
54
|
+
|
|
55
|
+
Cons:
|
|
56
|
+
|
|
57
|
+
- Probably not as searchable, though maybe we could institute a way to "label"/tag them.
|
|
58
|
+
- Not very visible.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Use response data to detect sign-in success
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
What is a robust way to detect whether signing in worked or not?
|
|
6
|
+
|
|
7
|
+
## Considered Options
|
|
8
|
+
|
|
9
|
+
- Elements in the DOM.
|
|
10
|
+
- Use some class or ID that only the sign-in page has, so we can detect that a user is on a new page and succeeded.
|
|
11
|
+
- User-facing invalidation message elements in the DOM on failure.
|
|
12
|
+
- URL change.
|
|
13
|
+
- Response data.
|
|
14
|
+
|
|
15
|
+
## Decision Outcome
|
|
16
|
+
|
|
17
|
+
Use a change in the URL to detect sign-in navigation.
|
|
18
|
+
|
|
19
|
+
## Pros and Cons of the Options
|
|
20
|
+
|
|
21
|
+
### DOM
|
|
22
|
+
|
|
23
|
+
Pros:
|
|
24
|
+
|
|
25
|
+
- It can be easy to do with the tools we are using.
|
|
26
|
+
|
|
27
|
+
Cons:
|
|
28
|
+
|
|
29
|
+
- The DOM can, and has been, changed by docassemble and these kinds of changes are made pretty quietly so we find it hard to keep track of them.
|
|
30
|
+
- It is pretty easy for site developers to change the HTML of standard pages like the sign-in page.
|
|
31
|
+
|
|
32
|
+
### URL change
|
|
33
|
+
|
|
34
|
+
Pros:
|
|
35
|
+
|
|
36
|
+
- It seems very likely that developers will keep an unsuccessful sign-in on the same page, even if they change some other functionality.
|
|
37
|
+
- It seems very likely that developers will change the url when the sign-in succeeds.
|
|
38
|
+
- Sticking with checking the url would mesh with how we currently detecting page navigation. See the cons for issues with that.
|
|
39
|
+
|
|
40
|
+
Cons:
|
|
41
|
+
|
|
42
|
+
- It seems precarious, though I haven't yet been able to articulate why. I know it hasn't been a sufficient full solution in the past for interview pages. For example, in a `show if` infinite page loop.
|
|
43
|
+
- Developers can manipulate a page's url, though it seems unlikely in this situation.
|
|
44
|
+
|
|
45
|
+
### Response data
|
|
46
|
+
|
|
47
|
+
Use the response data from the sign in request.
|
|
48
|
+
|
|
49
|
+
Pros:
|
|
50
|
+
|
|
51
|
+
- It seems reliable - it seems very likely that developers will re-direct their users to a different page, even if they change some other functionality.
|
|
52
|
+
- Less likely to change than the DOM.
|
|
53
|
+
- Has some standard values we can expect, like status codes.
|
|
54
|
+
|
|
55
|
+
Cons:
|
|
56
|
+
|
|
57
|
+
- DA's responses are not typical. There's no 400's in unsuccessful responses.
|
|
58
|
+
- Regular interview page navigation doesn't get a 302, so this method would be a special case for signing in.
|
|
59
|
+
|
|
60
|
+
Options are:
|
|
61
|
+
|
|
62
|
+
- 302 redirection status. It seems fairly reliable that a developer will send a user to a different page after they sign in, and also likely that they will keep the user on the same page if the sign-in failed.
|
|
63
|
+
- Cache-Control header value that contains "must-revalidate" (See [MDN cache control directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives)). It makes sure this data isn't cached. I'm not familiar with this and I'm not sure what might or might not trigger this.
|
|
64
|
+
- Cookie with the name "secret". This seems promising, but I don't know much about cookies.
|
|
65
|
+
|
|
66
|
+
Based on our current knowledge, we think the 302 status response will be most reliable.
|
|
67
|
+
|
|
68
|
+
Notes for response data:
|
|
69
|
+
|
|
70
|
+
I have isolated the differences between the sign-in success and failure responses.
|
|
71
|
+
|
|
72
|
+
Key for following entries:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
<key of object containing the data>
|
|
76
|
+
🌈 <sign in success data>
|
|
77
|
+
vs
|
|
78
|
+
🤕 <sign in failure data>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Findings:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
response
|
|
85
|
+
🌈 "redirectURL": "/path", "headersSize": 552, "bodySize": 0, "_transferSize": 552,
|
|
86
|
+
vs
|
|
87
|
+
🤕 "redirectURL": "", "headersSize": 570, "bodySize": 1998, "_transferSize": 2568,
|
|
88
|
+
---
|
|
89
|
+
response
|
|
90
|
+
🌈 "status": 302, "statusText": "FOUND",
|
|
91
|
+
vs
|
|
92
|
+
🤕 "status": 200, "statusText": "OK",
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
headers
|
|
96
|
+
🌈 no cache-control
|
|
97
|
+
vs
|
|
98
|
+
🤕 { "name": "Cache-Control", "value": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0" },
|
|
99
|
+
---
|
|
100
|
+
headers
|
|
101
|
+
🌈 { "name": "Content-Length", "value": "209" },
|
|
102
|
+
vs
|
|
103
|
+
🤕 { "name": "Content-Encoding", "value": "gzip" },
|
|
104
|
+
---
|
|
105
|
+
headers
|
|
106
|
+
🌈 { "name": "Location", "value": "/interviews" },
|
|
107
|
+
vs
|
|
108
|
+
🤕 no location
|
|
109
|
+
---
|
|
110
|
+
headers
|
|
111
|
+
🌈 { "name": "Set-Cookie", "value": "secret=secretchars; Secure; HttpOnly; Path=/; SameSite=Lax" },
|
|
112
|
+
vs
|
|
113
|
+
🤕 no secret
|
|
114
|
+
---
|
|
115
|
+
headers
|
|
116
|
+
🌈 no transfer-encoding
|
|
117
|
+
vs
|
|
118
|
+
🤕 { "name": "Transfer-Encoding", "value": "chunked" },
|
|
119
|
+
---
|
|
120
|
+
cookies
|
|
121
|
+
🌈 { "name": "secret", "value": "secretchars", "path": "/", "domain": "site.com", "expires": null, "httpOnly": true, "secure": true, "sameSite": "Lax" },
|
|
122
|
+
vs
|
|
123
|
+
🤕 no secret
|
|
124
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Leave pdfjs at its current version
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
pdfjs has a security vulnerability (that does not affect us) where malicious PDFs can inject code into an unsuspecting project and cause havoc.
|
|
6
|
+
|
|
7
|
+
Our users are downloading and manipulating their own PDFs. We will assume they're not putting malicious code into their PDFs.
|
|
8
|
+
|
|
9
|
+
The update changes pdfjs .js files to be .mjs files. It might take some bother to configure our repo to use .mjs files.
|
|
10
|
+
|
|
11
|
+
## Considered Options
|
|
12
|
+
|
|
13
|
+
- Update pdfjs
|
|
14
|
+
- Leave pdfjs at its current version, 3.2.146
|
|
15
|
+
|
|
16
|
+
## Decision Outcome
|
|
17
|
+
|
|
18
|
+
Leave pdfjs at its current version, 3.2.146. The vulnerability is irrelevant for our situation and we don't have bandwidth to set up the configurations right now.
|