behave-contrib / behave-html-pretty-formatter

HTML Pretty formatter for Behave
GNU General Public License v3.0
15 stars 4 forks source link

download button not automatically showing when data is too big #76

Closed Kory291 closed 1 month ago

Kory291 commented 1 month ago

If you try to embed data without specifying download_button=True when using embed() you will get the standard message "Compressed data are too big, click download above." but it will not show the download button. Either the message in the report should be adjusted or the download button should be visible if the compressed data is too big.

modehnal commented 1 month ago

AFAIK that should be the case. Download button should be visible when embedding large data.

One idea that comes to mind is that we are checking with mime type text number of lines, and your data is a single line, or perhaps there is an edge case with compressed data which comes from java script. What do you think @fpokryvk

An example how to reproduce would be welcome.

Kory291 commented 1 month ago

For example I did the following to provoke this:

long_data = "foo".join(["bar" for _ in range(1024*1024)])
context.formatter.embed(data=long_data, mime_type="text/plain", caption="download button", download_button=True)
context.formatter.embed(data=long_data, mime_type="text/plain", caption="no download button")
fpokryvk commented 1 month ago

Could you provide more specific info (type of embeded data, size), in our case the data compression works fine (I have reports with 50MB of linux journal compressed to few hundreds of kB) and Download button is there.

Kory291 commented 1 month ago

I guess @modehnal was right. When I change it to use new lines, it adds the download button in both scenarios. The type of data would be html. If it is helpful for you, I could also provide an example using plotly (this was the specific use case where I first found this behaviour.).

fpokryvk commented 1 month ago

Aha, I see, there is condition of 20 lines to show Download button, but it is probably not overriden by compression - I will investigate deeper and fix. Thanks for the report!

modehnal commented 1 month ago

Tag 1.12 was created and pushed, updated version should be in pypi shortly. Please give it a try.