@suffolklitlab/alkiln 3.0.9

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 (40) hide show
  1. package/.github/workflows/test_tests.yml +77 -0
  2. package/CHANGELOG.md +381 -0
  3. package/README.md +18 -0
  4. package/action.yml +158 -0
  5. package/lib/DOM.md.html +63 -0
  6. package/lib/github_integration/install-branch.js +84 -0
  7. package/lib/github_integration/puppeteer-utils.js +224 -0
  8. package/lib/github_integration/setup.js +4 -0
  9. package/lib/github_integration/takedown.js +4 -0
  10. package/lib/index.js +2 -0
  11. package/lib/scope.js +1632 -0
  12. package/lib/steps.js +878 -0
  13. package/lib/utils/env_vars.js +173 -0
  14. package/lib/utils/langs.js +51 -0
  15. package/lib/world.js +10 -0
  16. package/package.json +53 -0
  17. package/tests/features/assembly_line.feature +43 -0
  18. package/tests/features/establishing_steps.feature +22 -0
  19. package/tests/features/example_test.feature +11 -0
  20. package/tests/features/interactive_steps.feature +85 -0
  21. package/tests/features/observation_steps.feature +97 -0
  22. package/tests/features/reports.feature +482 -0
  23. package/tests/features/some_png_1.png +0 -0
  24. package/tests/features/some_png_2.png +0 -0
  25. package/tests/features/story_table_formats.feature +77 -0
  26. package/tests/features/story_tables.feature +88 -0
  27. package/tests/unit_tests/ensureSpecialRows.test.js +34 -0
  28. package/tests/unit_tests/env_vars.test.js +53 -0
  29. package/tests/unit_tests/fields.fixtures.js +904 -0
  30. package/tests/unit_tests/getAllFields.test.js +142 -0
  31. package/tests/unit_tests/getMatchingRows.test.js +261 -0
  32. package/tests/unit_tests/getSafeScenarioBaseFilename.fixtures.js +12 -0
  33. package/tests/unit_tests/getSafeScenarioBaseFilename.test.js +62 -0
  34. package/tests/unit_tests/getSafeScenarioFilename.test.js +83 -0
  35. package/tests/unit_tests/html.fixtures.js +861 -0
  36. package/tests/unit_tests/matches.fixtures.js +168 -0
  37. package/tests/unit_tests/names.fixtures.js +35 -0
  38. package/tests/unit_tests/normalizeTable.test.js +22 -0
  39. package/tests/unit_tests/special_rows.fixtures.js +101 -0
  40. package/tests/unit_tests/tables.fixtures.js +428 -0
@@ -0,0 +1,77 @@
1
+ name: Test the tests
2
+
3
+ on:
4
+ push:
5
+ workflow_dispatch:
6
+ inputs:
7
+ extra_languages:
8
+ description: 'Optional. A list of comma separated language names visible on buttons or links that change the language of the interview. Overrides the EXTRA_LANGUAGES repo secret.'
9
+ default: ''
10
+ tags:
11
+ description: 'Optional. Use a "tag expression" specify which tagged tests to run (https://cucumber.io/docs/cucumber/api/#tag-expressions)'
12
+ default: ''
13
+
14
+ jobs:
15
+
16
+ puppeteer-tests:
17
+ runs-on: ubuntu-latest
18
+
19
+ strategy:
20
+ matrix:
21
+ node-version: [12.x]
22
+
23
+ env:
24
+ BASE_URL: https://apps-dev.suffolklitlab.org
25
+ PLAYGROUND_EMAIL: ${{ secrets.PLAYGROUND_EMAIL }}
26
+ PLAYGROUND_PASSWORD: ${{ secrets.PLAYGROUND_PASSWORD }}
27
+ PLAYGROUND_ID: ${{ secrets.PLAYGROUND_ID }}
28
+ BRANCH_PATH: main
29
+ EXTRA_LANGUAGES: ${{ secrets.EXTRA_LANGUAGES }}
30
+ REPO_URL: https://github.com/plocket/docassemble-ALAutomatedTestingTests
31
+
32
+ name: Run Puppeteer tests
33
+ steps:
34
+ - name: Set languages
35
+ run: echo "EXTRA_LANGUAGES=${{ github.event.inputs.extra_languages }}" >> $GITHUB_ENV
36
+ if: ${{ github.event.inputs.extra_languages != '' }}
37
+ # For the testing repo, the `REPO_URL` is that of a different repo and is created in `env:`
38
+ - run: echo "Repo address is $REPO_URL"
39
+ - name: Checkout
40
+ uses: actions/checkout@v2
41
+ - name: Setup environment
42
+ uses: actions/setup-node@v1
43
+ with:
44
+ node-version: ${{ matrix.node-version }}
45
+ - run: npm install
46
+ - run: npm run setup
47
+ - run: npm run test -- ${{ github.event.inputs.tags && format('"--tags" "{0}"', github.event.inputs.tags) }}
48
+ - name: upload error artifacts
49
+ uses: actions/upload-artifact@v2
50
+ if: ${{ failure() }}
51
+ with:
52
+ name: errors
53
+ path: ./**/error*.jpg
54
+ - name: upload screenshot steps
55
+ uses: actions/upload-artifact@v2
56
+ # They will upload even if a previosu step has failed
57
+ if: ${{ always() }}
58
+ with:
59
+ name: screenshots
60
+ path: ./**/screenshot*.jpg
61
+ - name: upload downloads
62
+ uses: actions/upload-artifact@v2
63
+ # They will upload even if a previous step has failed
64
+ if: ${{ always() }}
65
+ with:
66
+ name: downloads
67
+ path: ./**/downloads_*
68
+ - name: upload report
69
+ uses: actions/upload-artifact@v2
70
+ # They will upload even if a previous step has failed
71
+ if: ${{ always() }}
72
+ with:
73
+ name: report
74
+ path: ./**/*_report_*
75
+ - name: Cleanup
76
+ if: ${{ always() }}
77
+ run: npm run takedown
package/CHANGELOG.md ADDED
@@ -0,0 +1,381 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ <!-- How to create a new entry:
7
+ See the documentation for Keep a Changelog above.
8
+ Try to keep them in this order if possible, skipping what you don't need:
9
+
10
+ Added - for new features.
11
+ Changed - for changes in existing functionality.
12
+ Deprecated - for soon-to-be removed features.
13
+ Removed - for now removed features.
14
+ Fixed - for any bug fixes.
15
+ Security - in case of vulnerabilities.
16
+
17
+ Format:
18
+
19
+ ## [Unreleased]
20
+ -
21
+
22
+ ## [1.0.0] - 2021-01-16
23
+ ### Added
24
+ -
25
+
26
+ ### Changed
27
+ -
28
+
29
+ ### Deprecated
30
+ -
31
+
32
+ ### Removed
33
+ -
34
+
35
+ ### Fixed
36
+ -
37
+
38
+ ### Security
39
+ -
40
+ -->
41
+ <!-- ## [Unreleased] -->
42
+ ## [3.0.9] - 2022-01-10
43
+ ### Security
44
+ - Install the security fix in the action's package.json as well. Because dependents have to require cucumber itself, if they're not using our action (if they have their own package.json), they're going to have to implement this fix in their repo too. That's why our fix isn't working. We'll start the process of helping developers update. We also need to deprecate all previous versions of ALKiln. See #489.
45
+
46
+ ## [3.0.8] - 2022-01-10
47
+ ### Security
48
+ - Fully publish the security fix in v3.0.7
49
+
50
+ ## [3.0.7] - 2022-01-10
51
+ ### Security
52
+ - Pinned colors library to 1.4.0. See https://www.bleepingcomputer.com/news/security/dev-corrupts-npm-libs-colors-and-faker-breaking-thousands-of-apps/. We don't use faker, so we don't need to handle that.
53
+
54
+ ## [3.0.6] - 2022-01-07
55
+ ### Changed
56
+ - See #371
57
+ - Scenario heading tags are now on a second line
58
+ - Artifact filenames use dashes more and are created separately from Scenario headings
59
+ - Scenario ids are separated from filenames and Scenario headings
60
+
61
+ ## [3.0.5] - 2022-01-06
62
+ ### Added
63
+ - Add action.yml that runs most of what users' workflows run now, along with notes for a new user workflow that will take less maintainance. See #420. We need to add documentation on how to write a workflow file as it currently is if they want to take back control. Setup interview has not yet been updated with this workflow.
64
+ - Add package.json creation/overwriting to action.yml. Simplify package.json.
65
+
66
+ <!-- ## [3.0.1-peer-deps.1] - 2021-12-07 -->
67
+ ### Removed
68
+ - Peer dependencies and dev dependencies. Now `cucumber` is just a dependency. See https://github.com/SuffolkLITLab/ALKiln/issues/396 for discussion. Setup interview has not been updated to remove dependencies.
69
+
70
+ ### Fixed
71
+ - Fixed interview name not allowing url parameters. #449
72
+
73
+ ## [3.0.4] - 2021-12-11
74
+ ### Fixed
75
+ - Use different criteria for testing that the package was saved.
76
+
77
+ ## [3.0.3] - 2021-12-11
78
+ ### Fixed
79
+ - Implement a temporary fix for inability to pull private repos into empty da Projects. See https://github.com/SuffolkLITLab/ALKiln/issues/417#issuecomment-991812294
80
+
81
+ ## [3.0.2] - 2021-12-10
82
+ ### Changed
83
+ - Improve some error messages and handling for the new private repo workflow.
84
+
85
+ ## [3.0.1] - 2021-12-10
86
+ ### Fixed
87
+ - Allow authenticated GitHub user to pull from a private repository for which they have at least read permissions.
88
+
89
+
90
+ ## [3.0.0] - 2021-12-07
91
+ ### Changed
92
+ - v3 release to update to da Bootstrap 5. Breaks for servers that have not yet updated to that da version.
93
+
94
+ ## [2.7.0-pre-update-dom.4] - 2021-12-03
95
+ ### Changed
96
+ - Give test resetting, a common failure point, a couple of tries and add a warning and instructions about simply re-running the tests.
97
+
98
+ ## [2.7.0-pre-update-dom.3] - 2021-12-02
99
+ ### Fixed
100
+ - Abandon puppeteer clicks and handle them all ourselves. This means people can't run a mobile device because they can't tap. It takes some implementation. See https://stackoverflow.com/a/56547605/14144258.
101
+
102
+ ## [2.7.0-pre-update-dom.2] - 2021-12-02
103
+ ### Fixed
104
+ - Quick fix for frequent timeout errors. See https://github.com/SuffolkLITLab/ALKiln/issues/389#issuecomment-984844240, Option 1 - disable cucumber timeout and, instead, handle timeout errors to allow 3 attempts to load an interview. For future development, convert to API key to check if server is restarting.
105
+
106
+ ## [2.7.0-pre-update-dom] - 2021-11-22
107
+ ### Changed
108
+ - Update to Bootstrap 5 Docassemble DOM changes
109
+ - Remove test(s?) for guessing proxy vars as we don't do that anymore #221
110
+ - Added instructions for using tags when running cucumber tests
111
+ - Handle clicking in `tapElement()` ourselves now instead of with puppeteer. See previous commit for the change.
112
+
113
+ ## [2.6.0] - 2021-08-07
114
+ ### Added
115
+ - 'today' and 'today - 1' for setting dates
116
+
117
+ ## [2.5.4] - 2021-08-07
118
+ ### Fixed
119
+ - In page load, total timeout needs to be checked in more places to give useful error message before Step fully times out.
120
+
121
+ ## [2.5.3] - 2021-08-06
122
+ ### Fixed
123
+ - Not giving enough time for package to load - failing too soon on error of module not found.
124
+ - Not waiting for package page to appear on setup: https://github.com/plocket/docassemble-cucumber/issues/367#issuecomment-892591770. I believe we tried this in the past and it wasn't enough.
125
+
126
+ ## [2.5.2] - 2021-08-03
127
+ ### Fixed
128
+ - Wrong error when server times out on page load.
129
+
130
+ ## [2.5.1] - 2021-07-31
131
+ ### Added
132
+ - Tests for failed Scenarios and their reports
133
+
134
+ ### Changed
135
+ - Tweak report wording
136
+
137
+ ### Fixed
138
+ - Internal report check logic
139
+ - Loading page did not catch system error and re-trying without timeout was not robust.
140
+
141
+ ## [2.5.0] - 2021-07-31
142
+ ### Added
143
+ - Report line for error on load.
144
+ - Internal testing Step to test contents of reports include certain content.
145
+ - Internal testing Step to check passing tests should be passing and failing ones should be failing.
146
+
147
+ ## [2.4.2] - 2021-07-31
148
+ ### Fixed
149
+ - Steps that set vars (other than the story table) should fail when they can't set their var, but they did not fail.
150
+
151
+ ## [2.4.1] - 2021-07-24
152
+ ### Fixed
153
+ - Upload Step wasn't waiting for files to finish uploading
154
+
155
+ ## [2.4.0] - 2021-07-23
156
+ ### Added
157
+ - Values can be set to comma-separated list of names of files to upload to upload multiple files. Files must be in the package's 'sources' folder or in the 'tests/features' folder.
158
+
159
+ ### Changed
160
+ - Increased `showif_timeout` because a hidden field missed getting set via a race condition. The only explanation we could come up with was that the field wasn't shown fast enough.
161
+ - Allow duplicates of '[class="file-caption-name"]' fields as they should not be dangerous.
162
+
163
+ ## [2.3.0] - 2021-07-22
164
+ ### Changed
165
+ - Report: List failed scenarios first, other non-passing scenarios second (should not run into those much I think), and passed scenarios last.
166
+ - Two internal tests adjusted to be 10 secs shorter each
167
+ - One internal test tag updated
168
+
169
+ ### Fixed
170
+ - Some report ids not being recorded because old id from previous test was not different from new id in new scenario.
171
+
172
+ ## [2.2.3] - 2021-07-18
173
+ ### Changed
174
+ - Updated package-lock.json with `npm fix` based on `npm audit`
175
+
176
+ ## [2.2.2] - 2021-07-16
177
+ ### Fixed
178
+ - `toBase64` returns default valid base 64 value with clear name if needed
179
+
180
+ ### Added
181
+ - Clarifying code comments
182
+
183
+ ## [2.2.1] - 2021-07-14
184
+ ### Fixed
185
+ - Variable undefined in scope.js (message)
186
+
187
+ ## [2.2.0] - 2021-07-12
188
+ ### Added
189
+ - Tests for reports for unexpected failures
190
+
191
+ ### Changed
192
+ - Bump minor version for added timeout behavior, etc.
193
+
194
+ ## [2.1.8] - 2021-07-11
195
+ ### Added
196
+ - Step: Custom global timeout, #317, for when interviews know they'll need longer timeouts for such things as loading large documents.
197
+
198
+ ### Changed
199
+ - Timeout is now 30 sec instead of 2 min as individual devs can set a custom timeout for their scenarios. We've made an assumption that this will be enough for most interviews and will have to see if that bears out.
200
+
201
+ ## [2.1.7] - 2021-07-08
202
+ ### Added
203
+ - More detailed reports that print 1. variables that were set on each page 2. all rows that set variables, and 3. all rows that weren't used
204
+
205
+ ## [2.1.6] - 2021-07-07
206
+ ### Added
207
+ - Backwards compatibility with `#sought_variable` element.
208
+ - Report tests
209
+
210
+ ### Fixed
211
+ - Typo in report
212
+
213
+ ## [2.1.5] - 2021-07-07
214
+ ### Changed
215
+ - Not sure. Can't find this commit.
216
+
217
+ ## [2.1.4] - 2021-07-06
218
+ ### Fixed
219
+ - Var name typos in `scope.ensureSpecialRows()`
220
+
221
+ ## [2.1.3] - 2021-07-06
222
+ ### Added
223
+ - Reports now also show data about which variables were used on each page, as well as a list of which variables from a story table were used and which weren't.
224
+
225
+ ## [2.1.2] - 2021-07-04
226
+ ### Changed
227
+ - Refactor `scope.processVar()`, including rename
228
+
229
+ ## [2.1.1] - 2021-07-04
230
+ ### Changed
231
+ - Use new Buffer reference instead of old deprecated reference.
232
+
233
+ ## [2.1.0] - 2021-07-01
234
+ ### Added
235
+ - Support interview filenames ending in `.yml` in the first step
236
+
237
+ ## [2.0.0] - 2021-06-29
238
+ ### Added
239
+ - Support for `.there_is_another` loops in story tables using `.target_number`
240
+ - New step: 'I should see the link to' and its test.
241
+ - 'I get to' is available in the `And I get to the question "some id" with this data:` instead of just 'the user gets to'
242
+ - Add some warnings/feedback for the developer.
243
+ - Tests for some observational Steps.
244
+ - Tests for some interactive Steps.
245
+ - Tests for Assembly Line package-specific tests.
246
+ - Move debug logs for getMatchingRow and getPageData to appropriate places.
247
+
248
+ ### Changed
249
+ - Added `trigger` column to table to define trigger var (| var | value | checked | trigger |). See https://github.com/plocket/docassemble-cucumber/issues/256. This allows devs to use index vars and generic objects (proxy vars) freely in their interview.
250
+ - Tried to make element selectors more picky.
251
+ - Make screenshot names unique and line up alphabetically with timestamps.
252
+ - Allow more languages in scenario name.
253
+ - Different data structure for matches - check one field at a time - and replace `page_data` with `fields`.
254
+ - Remove the need for the `checked` story table column and prop by: 1) Moving the `value` of checkboxes into their var name column. 2) Moving the `checked` value of checkboxes into the `value` column.
255
+ - Combined checkbox encoding matching regex into one regex.
256
+ - Steps setting choices now work the same as the story tables - only two values given. No need for a 'trigger' column value.
257
+ - Updated tests to match new functionality.
258
+
259
+ ### Deprecated
260
+ - Previous formats of the table: `| var | choice | value |` *and* `| var | value | checked |`
261
+
262
+ ### Removed
263
+ - Some Steps that won't work with translations and are not currently being used by anyone. TODO: Look up and ennumerate which steps.
264
+ - `checked` column.
265
+ - `scope.getField()` and other now unused scope functionality.
266
+
267
+ ### Fixed
268
+ - Assert found invalid input.
269
+ - 'I sign' was passing incorrect arguments.
270
+ - Regex testing for match to proxy var - both the regex itself being more strict and the test for a match being more predictable.
271
+ - #202 handles accidental mixup of single quotes for double quotes or visa versa in all columns.
272
+
273
+ ## [1.3.5] - 2021-05-04
274
+ ### Added
275
+ - Handles setting [AssemblyLine](https://github.com/SuffolkLITLab/docassemble-AssemblyLine) ([ALToolbox](https://github.com/SuffolkLITLab/docassemble-ALToolbox)) `BirthDate` datatype. [See example of HTML here](https://github.com/plocket/docassemble-cucumber/pull/217).
276
+
277
+ ## [1.3.4] - 2021-04-21
278
+ ### Fixed
279
+ - Dropdowns created with objects always fail.
280
+
281
+ ## [1.3.3] - 2021-04-16
282
+ ### Changed
283
+ - This repo no longer has an action to generate test folders and scripts in the dependant repo. From now on, devs will use the interview in https://github.com/plocket/docassemble-ALAutomatedTestingTests to add it themselves. Note: That interview will put the tests in the `/sources` dir. Previous repos' scripts will continue as they are.
284
+
285
+ ## [1.3.2] - 2021-04-07
286
+ ### Changed
287
+ - Each test run creates a unique da Project now. No need to wait for previous tests to finish.
288
+
289
+ ## [1.3.1] - 2021-04-07
290
+ ### Fixed
291
+ - Message about duplicate selector matches.
292
+ - Bump _minor_ version number appropriately.
293
+
294
+ ## [1.2.8] - 2021-04-06
295
+ ### Fixed
296
+ - Newly found race condition on 'continue'. Can replicate inside of [DBD](https://github.com/caroRob/docassemble-DeadBrokeDads2/tree/add_tests_to_separating_interview_code_etc) very consistently, but not outside of it. See [#190](https://github.com/plocket/docassemble-cucumber/issues/190).
297
+ - Make action buttons more permissive. Some action buttons don't lead to an event, they just have a url. See [#200](https://github.com/plocket/docassemble-cucumber/issues/200).
298
+ - Fix all checkboxes getting checked no matter what.
299
+ - Account for `choices:` specifier DOM difference - unlike other fields, it has no `.form-group` container.
300
+ - Incorrect truthy test.
301
+
302
+ ### Added
303
+ - New warning in report about variable appearing on a page in multiple places.
304
+
305
+ ## [1.2.7] - 2021-04-05
306
+ ### Changed
307
+ - A new table format is highly encouraged: `| var | value | checked |`. var = variable name, value = words of the value to set, checked = whether to select or unselect a checkbox (only needed for checkboxes).
308
+ - Basically, address much of [#158](https://github.com/plocket/docassemble-cucumber/issues/158), as noted below.
309
+
310
+ ### Deprecated
311
+ - Previous version of table columns format (`| var | choice | value |`). The new version uses `| var | value | checked |`, though we do need a better name than `checked`. It will simplify the table for developers and for the code.
312
+
313
+ ### Fixed
314
+ - Some proxy field var name finding
315
+ - Improved page var name finding in general
316
+ - Refactored to get all fields from the page first, then compare to a new format of table
317
+
318
+ ## [1.2.6] - 2021-03-14
319
+ ### Added
320
+ - Automated integrated self-testing
321
+ - Unit tests for getField with cheerio
322
+ - Refactor getField to use data
323
+
324
+ ### Fixed
325
+ - Infinite loop when specific button tap causes error #168
326
+ - Some items not getting selected at all (scroll into view problem)
327
+
328
+ ## [1.2.5] - 2021-03-06
329
+ ### Fixed
330
+ - Simplest case of [index var](https://github.com/plocket/docassemble-cucumber/issues/158) (i.e. `i`) question.
331
+
332
+ ## [1.2.4] - 2021-03-03
333
+ ### Fixed
334
+ - Race condition where puppeteer thinks the page has progressed but it really hasn't.
335
+
336
+ ## [1.2.3] - 2021-02-07
337
+ ### Fixed
338
+ - Options of dropdown fields created with objects are not found [#149](https://github.com/plocket/docassemble-cucumber/issues/149)
339
+
340
+ ## [1.2.2] - 2021-02-03
341
+ ### Fixed
342
+ - Signature field rows (`/sign`) are not used up all in one loop
343
+
344
+ ### Added
345
+ - .env-example file to files that will be pushed to dependants
346
+
347
+ ## [1.2.1] - 2021-01-26
348
+ ### Fixed
349
+ - #79, race condition breaks story table scenarios (ex: MADE `rental agreement`)
350
+ - #115, order of table items matter - continue button pressed too soon
351
+ - #139, `scope.getField()` `set_to` doesn't find all the fields
352
+
353
+
354
+ ## [1.2.0] - 2021-01-13
355
+ ### Changed
356
+ - Reports are saved as `.txt` files instead of `.md` files.
357
+ - Reports are prettier.
358
+ - Story table: If there are only two columns needed in a table row, the table doesn't care which columns the second item is in. This is to allow generated tests to work without a human editing them.
359
+ - Automatically generated language tags now handle spaces.
360
+
361
+ ### Fixed
362
+ - Broken error message - showed the wrong error.
363
+
364
+ ## [1.1.0] - 2021-01-13
365
+ ### Changed
366
+ - Skipped this version somehow. Was sure it was in there somewhere...
367
+
368
+ ## [1.0.0] - 2021-01-13
369
+ ### Added
370
+ - Steps for setting variables, interacting with elements, and observing (to be documented elsewhere TODO: add link)
371
+ - 'Story' table - a Step with a cucumber table that can set several variables until a specified `question id` is reached
372
+ - Translations support - many Steps that work with any language, including the 'story' table
373
+ - Reports about the order the pages appeared that are saved in [github artifacts](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/downloading-workflow-artifacts)
374
+ - Screenshots from scenarios that created errors
375
+ - Ability to download documents
376
+ - [Basic documentation for test writing](https://docs.google.com/document/d/1hkNr78mrU3Ha98tPUL4OKWi3eNnt-1Sba7L8470u06g/edit?usp=sharing)
377
+ - Ability for this repo to push all needed files to other repositories on which it has push permissions. Those files make sure the tests will get run by github. See the files outlined below:
378
+ - `example.feature` - an example test to get a project started
379
+ - `github/workflows/run_form_tests.yml` - Automated github workflow to run tests when code is pushed and a manual trigger for testing without needing to push
380
+ - `.gitignore` - ignores files that are generated by the tests and shouldn't be added to the repo
381
+ - `package.json` - keep up-to-date version of this test repository and hold scripts that the automated tests run
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # docassemble-cucumber
2
+ Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.
3
+
4
+ ## Integration tests
5
+ To setup for the integration tests, create the project on the server:
6
+ ```
7
+ npm run setup
8
+ ```
9
+
10
+ Use the syntax below to trigger specific tags:
11
+ ```
12
+ npm run cucumber -- "--tags" "@tagname"
13
+ ```
14
+
15
+ To run the unit tests in isolation:
16
+ ```
17
+ npm run unit
18
+ ```
package/action.yml ADDED
@@ -0,0 +1,158 @@
1
+ name: "ALKiln: Automated docassemble tests"
2
+ description: "Automatically test any docassemble interview in a any branch on your GitHub repository whenever you commit or push. See https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing."
3
+
4
+ inputs:
5
+ SERVER_URL:
6
+ description: 'The url of your docassemble server. This should be in your GitHub SECRETS or the SECRETS of your org.'
7
+ required: true
8
+ PLAYGROUND_EMAIL:
9
+ description: 'The email of your docassemble testing account. This should be in your GitHub SECRETS or the SECRETS of your org.'
10
+ required: true
11
+ PLAYGROUND_PASSWORD:
12
+ description: 'The password of your docassemble testing account. This should be in your GitHub SECRETS or the SECRETS of your org.'
13
+ required: true
14
+ PLAYGROUND_ID:
15
+ description: 'The id of your docassemble testing account. This should be in your GitHub SECRETS or the SECRETS of your org.'
16
+ required: true
17
+ EXTRA_LANGUAGES:
18
+ description: 'Other languages you want to test. This should be in your GitHub SECRETS or the SECRETS of your org.'
19
+ required: false
20
+ default: ''
21
+
22
+ runs:
23
+ using: "composite"
24
+ steps:
25
+ # This doesn't use an already established package-lock.json and that
26
+ # comes with some types of test breaking risks. Same problem as before.
27
+ - name: Overwrite or create package.json
28
+ run: |
29
+ cat << EOF > "package.json"
30
+ {
31
+ "scripts": {
32
+ "test": "npm run langs_setup && npm run cucumber -- $@",
33
+ "cucumber_base": "./node_modules/.bin/cucumber-js --require ./node_modules/docassemble-cucumber/lib/index.js",
34
+ "cucumber": "run_cucumber(){ npm run cucumber_base -- \"$@\" docassemble/*/data/sources/*.feature; }; run_cucumber",
35
+ "langs": "npm run langs_setup && ./node_modules/.bin/cucumber-js --require ./node_modules/docassemble-cucumber/lib/index.js docassemble/*/data/sources/*_lang*.feature",
36
+ "langs_setup": "node_modules/.bin/da-langs 'docassemble/*/data/sources/*.feature'",
37
+ "setup": "node_modules/.bin/da-setup",
38
+ "takedown": "node_modules/.bin/da-takedown"
39
+ },
40
+ "dependencies": {
41
+ "cucumber": "^6.0.5",
42
+ "docassemble-cucumber": "^3.0.0",
43
+ "colors": "1.4.0"
44
+ }
45
+ }
46
+ shell: bash
47
+
48
+ # Install node
49
+ - name: "ALKiln: Install node packages"
50
+ uses: actions/setup-node@v1
51
+ with:
52
+ node-version: "12"
53
+ - run: npm install
54
+ shell: bash
55
+
56
+ # Set environment variables
57
+ - name: "ALKiln: Set environment variables"
58
+ # If extra languages were set manually, override the repository
59
+ # EXTRA_LANGUAGES secret with the manually set values
60
+ run: |
61
+ if ${{ github.event.inputs.extra_languages != '' }}
62
+ then
63
+ echo "Manually set languages: ${{ github.event.inputs.extra_languages }}"
64
+ echo "EXTRA_LANGUAGES=${{ github.event.inputs.extra_languages }}" >> $GITHUB_ENV
65
+ else
66
+ echo "Use EXTRA_LANGUAGES secret: ${{ inputs.EXTRA_LANGUAGES }}"
67
+ echo "EXTRA_LANGUAGES=${{ inputs.EXTRA_LANGUAGES }}" >> $GITHUB_ENV
68
+ fi
69
+ echo "REPO_URL=${{ github.server_url }}/${{ github.repository }}" >> $GITHUB_ENV
70
+ echo "BRANCH_PATH=${{ github.ref }}" >> $GITHUB_ENV
71
+ echo "BASE_URL=${{ inputs.SERVER_URL }}" >> $GITHUB_ENV
72
+ echo "PLAYGROUND_EMAIL=${{ inputs.PLAYGROUND_EMAIL }}" >> $GITHUB_ENV
73
+ echo "PLAYGROUND_PASSWORD=${{ inputs.PLAYGROUND_PASSWORD }}" >> $GITHUB_ENV
74
+ echo "PLAYGROUND_ID=${{ inputs.PLAYGROUND_ID }}" >> $GITHUB_ENV
75
+ shell: bash
76
+ - name: "ALKiln: confirm info"
77
+ run: echo -e "\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nManually added languages are $EXTRA_LANGUAGES\nAll other data is secret\n"
78
+ shell: bash
79
+
80
+ # Run tests
81
+ - name: "ALKiln: Create a Project and pull the package from GitHub"
82
+ run: npm run setup
83
+ shell: bash
84
+ - name: "ALKiln: Run tests"
85
+ if: ${{ success() }}
86
+ run: npm run test -- ${{ github.event.inputs.tags && format('"--tags" "{0}"', github.event.inputs.tags) }}
87
+ shell: bash
88
+ - run: echo -e "\n\n====ALKiln could not create a project on your server's testing account or pull your package into it. Check the messages above this line.\n\n"
89
+ if: ${{ failure() }}
90
+ shell: bash
91
+ - name: "ALKiln: Delete project from docassemble test account"
92
+ if: ${{ always() }}
93
+ run: npm run takedown
94
+ shell: bash
95
+
96
+ # Upload artifacts that subscribers can download on the Actions summary page
97
+ - name: "ALKiln: Upload errors to action summary artifacts"
98
+ if: ${{ failure() }}
99
+ uses: actions/upload-artifact@v2
100
+ with:
101
+ name: errors
102
+ path: ./**/error*.jpg
103
+ - name: "ALKiln: Upload screenshots to action summary artifacts"
104
+ if: ${{ always() }}
105
+ uses: actions/upload-artifact@v2
106
+ #if-no-files-found: ignore
107
+ with:
108
+ name: screenshots
109
+ path: ./**/screenshot*.jpg
110
+ - name: "ALKiln: Upload downloaded files to action summary artifacts"
111
+ if: ${{ always() }}
112
+ uses: actions/upload-artifact@v2
113
+ #if-no-files-found: ignore
114
+ with:
115
+ name: downloads
116
+ path: ./**/downloads_*
117
+ - name: "ALKiln: Upload report to action summary artifacts"
118
+ if: ${{ always() }}
119
+ uses: actions/upload-artifact@v2
120
+ with:
121
+ name: report
122
+ path: ./**/*_report_*
123
+
124
+ # ##################################
125
+ # # A developer's workflow should look similar to the below
126
+ # # In place of `uses: suffolkLITLab/ALKiln@releases/v4`, they
127
+ # # might use another version.
128
+
129
+ # name: Use the ALKiln testing framework
130
+ # description: "Use the ALKiln testing framework to test interviews. See https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/automated_integrated_testing."
131
+
132
+ # on:
133
+ # push:
134
+ # workflow_dispatch:
135
+ # inputs:
136
+ # extra_languages:
137
+ # description: 'Optional. A list of comma separated language names visible on buttons or links in the interview that change the language of the interview. Overrides the EXTRA_LANGUAGES GitHub secret.'
138
+ # default: ''
139
+ # tags:
140
+ # description: 'Optional. Use a "tag expression" specify which tagged tests to run. See https://cucumber.io/docs/cucumber/api/#tag-expressions for syntax.'
141
+ # default: ''
142
+
143
+ # jobs:
144
+
145
+ # interview-testing:
146
+ # runs-on: ubuntu-latest
147
+ # name: Run interview tests
148
+ # steps:
149
+ # - uses: actions/checkout@v2
150
+ # - name: Use ALKiln to run tests
151
+ # uses: suffolkLITLab/ALKiln@releases/v4
152
+ # with:
153
+ # SERVER_URL: "${{ secrets.SERVER_URL }}"
154
+ # PLAYGROUND_EMAIL: "${{ secrets.PLAYGROUND_EMAIL }}"
155
+ # PLAYGROUND_PASSWORD: "${{ secrets.PLAYGROUND_PASSWORD }}"
156
+ # PLAYGROUND_ID: "${{ secrets.PLAYGROUND_ID }}"
157
+ # EXTRA_LANGUAGES: "${{ secrets.EXTRA_LANGUAGES }}"
158
+ # - run: echo "Finished running ALKiln tests"