Skip to content

Commit

Permalink
Close #582, implement 2-column Story Tables with no trigger var (#850)
Browse files Browse the repository at this point in the history
* Add the new proxy var HTML node

* Use a different arbitrary url that hopefully times out less often

* Remove weird whitespace characters

* Some refactoring and lang improvments prepping for double columns

* Include first varname value in the list of guesses

* Gather proxy-substituted DOM var names without breaking old code

* Fix typo and add new tests

Co-authored-by: pjg11 <45182159+pjg11@users.noreply.github.com>

* Add new method docstring

* Update fixtures for unit tests, avoid absent proxies

TODO:
- Update signature too
- Make issue: `not_decoded_name = href.replace(/^[A-Za-z0-9]*/, '_');` may need `g` flag

* Clean up with a bit of refactoring

* Test with the current version

* Add new test files and docs

* Write fixture tests, fix undefined var

* Restore simple.pdf

* Update changelog

* Reduce the trigger var warnings a la #452, add comments

* Clean up unused code

* Use less problematic suffix for name tests

* Use more robust suffix name. Improve error for missing page value

"Robust suffix name": We were setting the suffix to "Sr", but that got changed somewhere to "Sr." (note the new period). I'm not sure if that's an AssemblyLine thing or a docassemble thing. "II" shouldn't run into the same problems.

* Publish dev version with new behavior

* Identify reason for unexpected skip - wrong test status check

* Fix internal report test passes unexpectedly. Also...

- Add name of Scenario to progress dots. May help with logging progress on GitHub
- Add internal test to fail even when the report is correct (a previously undiscovered bug)
- Allow "expected status" tests to accept more than 'passed' and 'failed'
- Added doc explaining what results we expect
- Fix failures because upstream Assembly Line change (https://github.com/SuffolkLITLab/docassemble-AssemblyLine/blob/f9bd864990f8bc2c0c0096700ba6ad647772cb83/docassemble/AssemblyLine/al_general.py#L1008) added punctuation

Co-authored-by: justcho5 <justcho5@gmail.com>

* Change npm version to test GitHub issues

* Fix version typo

* Make sure failure test suffix is wrong under all circumstances

* Test PR on branch making the PR instead of the PR target branch

---------

Co-authored-by: pjg11 <45182159+pjg11@users.noreply.github.com>
Co-authored-by: justcho5 <justcho5@gmail.com>
  • Loading branch information
3 people authored Feb 12, 2024
1 parent cba21db commit 96a7f17
Show file tree
Hide file tree
Showing 36 changed files with 1,324 additions and 349 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/github_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: GitHub server installation
on:
push:
# Default "opened", "reopened", "synchronize". "edited" fires when the PR title gets edited, etc.
pull_request_target:
pull_request:
workflow_dispatch:
inputs:
tags:
Expand Down Expand Up @@ -91,4 +91,5 @@ jobs:
#### to debug the docker install step
#### Use a "tag expression" to specify which tagged tests to run (https://cucumber.io/docs/cucumber/api/#tag-expressions)
# ALKILN_TAG_EXPRESSION: @a_tag_expression
ALKILN_VERSION: 2column

4 changes: 2 additions & 2 deletions .github/workflows/playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Playground installation
on:
push:
# Default: opened, reopened, synchronize. "edited" is not what we want.
pull_request_target:
pull_request:
workflow_dispatch:
inputs:
tags:
Expand Down Expand Up @@ -55,4 +55,4 @@ jobs:
#### to debug the docker install step
# ALKILN_TAG_EXPRESSION: @a_tag_expression
#### Developer note: you probalby don't need this
# ALKILN_VERSION: 5.7.0-feature-tap1
ALKILN_VERSION: 2column
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Format:

<!-- ## [Unreleased] -->

### Added

- 2-column Story Tables that work without the trigger variable. Now column 1, "var", should only contain the actual variable name with no proxies (x, i, j, etc). For example, instead of `x[i].name.first` the var column should now contain `users[0].name.first`. Column 2 is the same as it was before - the answer for the field. See [#582](https://github.com/SuffolkLITLab/ALKiln/issues/582).

## [5.8.1] - 2023-12-28

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/AL_custom_dates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ include:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
id: interview order
mandatory: True
Expand Down
11 changes: 9 additions & 2 deletions docassemble/ALKilnTests/data/questions/AL_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ include:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;">
</div>
---
id: interview order
mandatory: True
Expand All @@ -26,9 +33,9 @@ sets:
question: |
Mix of code and proxy var
subquestion: |
The name fields variables will be using `users[0]` while the last field
The name fields variables will be using `users[1]` while the last field
will be using `users[i]`. The sought variable will be using
`users[0]`. The testing framework needs to be able to handle that.
`users[1]`. The testing framework needs to be able to handle that.
fields:
- code: |
users[i].name_fields()
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/all_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ features:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_date_and_time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ features:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ metadata:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ metadata:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_loops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ metadata:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
objects:
- there_are_any_people: DAList.using(object_type=Individual)
Expand Down
28 changes: 18 additions & 10 deletions docassemble/ALKilnTests/data/questions/test_pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ features:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
code: |
proxy_list.gather()
see_simple_doc
download_2_signatures
---
objects:
- proxy_list: DAList.using(object_type=Individual, ask_number=True, target_number=1, complete_attribute="complete")
- proxy_list: DAList.using(object_type=Individual, ask_number=True, target_number=2, complete_attribute="complete")
---
code: |
proxy_list[i].name.first
Expand All @@ -45,20 +51,22 @@ question: |
Signature
signature: x[i].signature
---
id: simple doc
id: 2_signature download
question: |
Document
subquestion: |
[Tap to download](${ simple_doc.pdf.url_for( attachment=True ) })
event: see_simple_doc
[Tap to download](${ doc_with_2_signatures.pdf.url_for( attachment=True ) })
event: download_2_signatures
---
id: simple attachment
id: 2_signature attachment
attachment:
variable name: simple_doc
pdf template file: simple.pdf
filename: simple-doc
variable name: doc_with_2_signatures
pdf template file: 2_signature.pdf
filename: 2_signature
skip undefined: True
editable: False
fields:
- "proxy1_name_first": ${ proxy_list[0].name.first }
- "proxy1_signature": ${ proxy_list[0].signature }
- "proxy1_signature": ${ proxy_list[0].signature }
- "proxy2_name_first": ${ proxy_list[1].name.first }
- "proxy2_signature": ${ proxy_list[1].signature }
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_random_input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ modules:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
############# Interview order #############
mandatory: True
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_signature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ metadata:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
6 changes: 6 additions & 0 deletions docassemble/ALKilnTests/data/questions/url_args.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ metadata:
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
<div id="alkiln_proxy_var_values"
data-generic_object="${ encode_name(str( x.instanceName if defined('x') else '' )) }"
% for letter in [ 'i', 'j', 'k', 'l', 'm', 'n' ]:
data-index_var_${ letter }="${ encode_name(str( value( letter ) if defined( letter ) else '' )) }"
% endfor
aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
Expand Down
Binary file not shown.
19 changes: 16 additions & 3 deletions docassemble/ALKilnTests/data/sources/assembly_line.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Assembly Line package-specific Steps
@fast @al1
Scenario: I have two name parts
Given the max secs for each step is 120
  Given I start the interview at "AL_tests"
Given I start the interview at "AL_tests"
And I set the name of "users[0]" to "Uli User"
And I tap to continue
And I set the address of "users[0]" to "120 Tremont Street, Unit 2, Boston, MA 02108"
Expand All @@ -18,9 +18,22 @@ Scenario: I have two name parts
And I tap to continue
Then the question id should be "end"

@fast @al1_no_proxy @no_proxy
Scenario: I have two name parts
Given the max secs for each step is 120
Given I start the interview at "AL_tests"
And I set the name of "users[0]" to "Uli User"
And I tap to continue
And I set the address of "users[0]" to "120 Tremont Street, Unit 2, Boston, MA 02108"
And I tap to continue
And I set the name of "users[1]" to "Uli2 User2"
And I set the var "users[1].proxy_var" to "Mixed proxy var step test"
And I tap to continue
Then the question id should be "end"

@fast @al2
Scenario: I have three name parts
  Given I start the interview at "AL_tests"
Given I start the interview at "AL_tests"
And I set the name of "users[0]" to "Uli Udo User"
And I tap to continue
And I set the address of "users[0]" to "120 Tremont Street, Unit 2, Boston, MA 02108"
Expand All @@ -32,7 +45,7 @@ Scenario: I have three name parts

@fast @al3
Scenario: I have four name parts
  Given I start the interview at "AL_tests"
Given I start the interview at "AL_tests"
And I set the name of "users[0]" to "Uli Udo User II"
And I tap to continue
And I set the address of "users[0]" to "120 Tremont Street, Unit 2, Boston, MA 02108"
Expand Down
14 changes: 7 additions & 7 deletions docassemble/ALKilnTests/data/sources/establishing_steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Scenario: I am able to set a custom wait time before an interview has been loade

@fast @e3 @urlargs
Scenario: Interview name includes url args
  Given I start the interview at "url_args.yml&from=theinternets&random=zoo"
  Then I should see the phrase "zoo"
Given I start the interview at "url_args.yml&from=theinternets&random=zoo"
Then I should see the phrase "zoo"

@slow @e4 @wait_first
Scenario: I can wait as a first step in a test
Expand All @@ -33,7 +33,7 @@ Scenario: Interview name includes url args with a wait

@fast @e6 @signin
Scenario: I sign in
  Given I sign in with the email "USER1_EMAIL" and the password "USER1_PASSWORD"
Given I sign in with the email "USER1_EMAIL" and the password "USER1_PASSWORD"
And I start the interview at "all_tests"

@fast @e7 @arbitraryurl
Expand All @@ -43,20 +43,20 @@ Scenario: I want to go to a full arbitrary url
"""
Trying to load the interview at "https://apps-test.suffolklitlab.org/start/demo/questions"
"""
  Given I start the interview at "https://apps-test.suffolklitlab.org/start/demo/questions"
  Then I should see the phrase "What language do you speak?"
Given I start the interview at "https://apps-test.suffolklitlab.org/start/demo/questions"
Then I should see the phrase "What language do you speak?"

# WARNING: This Scenario may fail if the file moves or changes too much
@fast @failing @e8 @rfe8 @arbitraryurl
Scenario: Fail with no interview at arbitrary url
Given the final Scenario status should be "failed"
And the Scenario report should include:
"""
Trying to load the interview at "https://apps-test.suffolklitlab.org/list"
Trying to load the interview at "https://retractionwatch.com"
"""
And the Scenario report should include:
"""
ALKiln could not find any interview question page
"""
And the max seconds for each step in this scenario is 5
Then I start the interview at "https://apps-test.suffolklitlab.org/list"
Then I start the interview at "https://retractionwatch.com"
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ Scenario: I set various values
# Next page
Then the question id should be "the end"

@fast @i2 @secret
@fast @i2 @secret @fail
Scenario: handles settings from Github secrets
Given the final Scenario status should be "failed"
And the Scenario report should include:
"""
The GitHub SECRET "SECRET_NOT_THERE" doesn't exist
ALKiln could not find the GitHub secret "SECRET_NOT_THERE"
"""
Given I start the interview at "test_secret_vars"
When I set the var "first_text_entry" to the secret "SECRET_VAR1"
Expand Down
Binary file not shown.
Loading

0 comments on commit 96a7f17

Please sign in to comment.