SuffolkLITLab / ALKiln

Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.
https://assemblyline.suffolklitlab.org/docs/alkiln/intro
MIT License
14 stars 4 forks source link

Step (discuss): How do we identify files to download on the page? Current method not sufficient #340

Closed plocket closed 2 months ago

plocket commented 3 years ago

The download step uses the given string to find an href that contains the given string in it. In the AL interviews, almost all current interviews have a table with a 'View' button, a 'Download' button, and a 'Download zip' button. Examples of hrefs:

The numbers in there are different each time you run the interview. For the current download step you'd only be able to use 'pdf_doc_1.pdf' to identify the link and both the 'View' and 'Download' buttons would look the same.

I believe the difference we see with with the download file (uploadedfiledownload) is the use of attachment=True when calling the url_for() method of a document to create those links in the buttons.

Also, when writing tests for the ALDocument classes, I ended up showing the same document on the page multiple times. Are there reasons a regular developer may do the same? A file with the same href ending on the same page? That doesn't mean the documents would be the same, just that the filenames would be the same. Would they have the same text surrounding them too?

Options I can think of in some combination:

None of these really seem sufficient. The most flexible one is ordinals, but that's also pretty fragile and, when code did change and tests failed, it would be hard to figure out why.

plocket commented 3 years ago

Another idea to add to the mix: Allow downloading multiple docs in one step - loop through the docs one by one, setting the custom timeout for each one so that, like story table rows, they each get the developer-defined amount of time to download. [We'd match however many links we could. Would that work for 'View' buttons, or would they error because nothing got downloaded? Should the download step error if nothing gets downloaded?]

plocket commented 2 years ago

~For documents that have the same name [(on the same page?)], maybe we could just detect that number in each of them and only download one file per each unique number. I wonder if our code is already able to download 'View' files. Would be good to test.~

[We've decided interview dev need to give files unique names. That's a good practice anyway.]