Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix object radio #581

Merged
merged 8 commits into from
Sep 17, 2022
Merged

Fix object radio #581

merged 8 commits into from
Sep 17, 2022

Conversation

BryceStevenWilley
Copy link
Collaborator

The values of object radio buttons are variable names encoded as base64.
Convert those values into the human readable versions of themselves if they can
be converted.

  • fromBase64 would accept invalid base64 strings, and just convert it to what it
    wanted to. This does a rough check to make sure that the value contains only
    valid base64 characters before trying to convert it. TODO: there could be more
    work done here to only add values that once decoded, end up as ascii
    characters (since we're working in python), but that can be future work.
  • Added more docstrings to the toBase64 and fromBase64 functions
  • Made unit tests pass by removing bad base64 conversions from the fixtures
  • switched one of the test argument orders, since the expected and actual values
    are backwards. TODO: should change the other as well

Tests pass locally (and in the second commit), and don't pass even when the interview steps are kept, meaning
that the fix does actually fix a DA related bug. The third commit (last one as of writing) fails because it includes extra steps not yet merged in ALAutomatedTestsingTests.

@BryceStevenWilley
Copy link
Collaborator Author

TODO:

  • make a test for checkboxes, specifically with a weird unicode string as a choice and make sure it's choosable
  • make a new docassemble YAML file for the above test (the "decoding" test)

@plocket
Copy link
Collaborator

plocket commented Sep 1, 2022

Some of the fixtures are failing. A bit braindead to dig into why right now, sorry. Fixtures are sadly fragile. I hesitated to use them in the first place. It seemed like a shame not to unit test them when the output was a string, though. We might discuss removing them.

@BryceStevenWilley
Copy link
Collaborator Author

I am aware and know why, see f81a49f.

unit tests are broken because I added multiple as an attribute to the fields, so now the deep equals are wrong

Was also having issues with chai not actually printing the diff at all (it just says the assert failed and doesn't print anything else), which was pretty annoying.

In general I don't have the bandwidth to work on this for a bit. This was supposed to be a smaller commit (fixing just object radio buttons), but has ballooned in scope to try to handle all of the base64 fields, as well as handling object multiselects and various other fields that I don't have the experience with.

BryceStevenWilley added a commit to SuffolkLITLab/docassemble-ALKilnSetup that referenced this pull request Sep 1, 2022
@BryceStevenWilley
Copy link
Collaborator Author

Since we mentioned (offline) that we should still include some of the changes from #604 and this PR in the stripped down PR, it's just easier to take out the code trying to handle multiples. That code is now in the fix_object_multiselect branch (https://github.com/SuffolkLITLab/ALKiln/pull/new/fix_object_multiselect).

I just discovered that I can't run puppeteer in WSL, so unfortunately I can't get things testing and running fully. I anticipate that i'll have to comment out all lines in test_decoding.yml that aren't object_radio for the tests to fully work, but I can confirm that the fixtures are fine now. Next week I'll have a better setup and will be able to test this fully and get to a point where it's mergable.

The values of object radio buttons are variable names encoded as base64.
Convert those values into the human readabale versions of themselves if they can
be converted.
* fromBase64 would accept invalid base64 strings, and just convert it to what it
  wanted to. This does a rough check to make sure that the value contains only
  valid base64 characters before trying to convert it. TODO: there could be more
  work done here to only add values that once decoded, end up as ascii
  characters (since we're working in python), but that can be future work.
* Added more docstrings to the toBase64 and fromBase64 functions
* Made unit tests pass by removing bad base64 conversions from the fixtures
* switched one of the test argument orders, since the expected and actual values
  are backwards. TODO: should change the other as well
Tested some unittests that have object multiselect
* separated out `fromBase64` and `toBase64`, which were
  scope only, and not async
* separated out nestedDecode from getPossibleVarNames, where we
  can also use it in getPossibleValues as well
* check for `multiple=""` in selects, meaning we can select multiple items
  and should treat them like check boxes
unit tests are broken because I added `multiple` as an attribute to the fields,
so now the deep equals are wrong, features are broken because we can't use
multipleselects, object or not. The entire framework of passing info to the
funnel needs to change so we can associate the decoded values from story tables
to the encoded values in the page.
@BryceStevenWilley
Copy link
Collaborator Author

I've got tests working on this, with the changes in SuffolkLITLab/docassemble-ALKilnSetup#197.

Should be ready for a last review, @plocket

Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good! Great changes! Some comments on clarity and some typo corrections, but this is probably good to go as far as functionality is concerned. There is one comment I feel is more important to add - the note about capturing da's encoding patterns.

This is a complex constellation of concepts to tackle. Kudos.

BryceStevenWilley and others added 2 commits September 16, 2022 14:26
Co-authored-by: plocket <52798256+plocket@users.noreply.github.com>
@BryceStevenWilley
Copy link
Collaborator Author

I think all of the comments were addressed and confirmed to be addressed or, (in the instance of #616) made into issues. Going to merge now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants