test(stand): make the download journeys prove what the file holds - #2597
Conversation
Three browser journeys downloaded a CSV or XLSX and asserted that the filename ended in the right suffix and the file was longer than zero bytes. That passes on a file holding the wrong scope, the wrong period, a header and no rows, or zeros where the grid showed blanks — every failure the export can actually have. `downloads.py` saves the download and parses it: `csv` for one format, `openpyxl` for the other, with one normalizer over CSV strings, XLSX numbers and rendered DOM text so `29`, `29.0` and a formatted `+2,705` compare equal while an empty cell stays distinct from a zero. Nothing is written down as an expected value — each journey now reconciles the two formats against each other, the record count against the grid's own `aria-rowcount`, and the rendered rows against the exported ones, so the assertions hold for whatever the stand was seeded with. Verified against a seeded compose stand: the three journeys pass, the whole `tests/stand/ui` suite passes, and each new assertion was checked against a deliberately broken reader — a missing cell serialized as zero, an export losing its last record, and files carrying values the grid never rendered all fail the journeys that should catch them. Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Correcting my own note here: the CSV/XLSX footer difference is by design, not a defect.
So there is nothing to decide and nothing to file. What was worth fixing is this journey, which compared bucket rows only and therefore asserted neither half of that contract — #2608 asserts the split in both directions. |
tests/stand/ui/holds the browser tests that click through a deployed Insightlike a user would. Three of them open a dialog and export a file —
test_git_output_timeseries,test_collaboration_card_evidence,test_metric_evidence_drilldown— and each checked only that the filename endedin
.csvor.xlsxand that the file was bigger than zero bytes. A file holdingthe wrong period, a header and no rows, or zeros where the screen showed blanks
passes that too.
What they assert now
.csv/.xlsxaria-rowcount)No expected value is written into a test, so re-seeding the stand cannot break
them. Each comparison is between two things the stand produced independently:
what the SPA rendered, and what the export path serialized.
How
One new helper,
tests/stand/ui/downloads.py. It saves the download, reads.csvwith the standard library and.xlsxwithopenpyxl(new dependency,locked), and puts every cell — CSV text, XLSX number, rendered DOM text — through
one normalizer.
29,29.0and a rendered+2,705compare equal, while an emptycell stays distinct from a zero. That last distinction is the point: a serializer
that writes
0for a missing value passes anything that merely counts rows.Verification
All 17 tests in
tests/stand/uipass against a seeded compose stand. To confirmthe new assertions can fail, the reader was broken three ways on purpose — a
missing cell read as
0, the last record dropped, every number shifted — and thethree tests failed each time.
One call for the reviewer
The XLSX export of the Git output timeseries carries the
TotalandGrand totalrows the table shows; the CSV stops at the last bucket. The test compares the
bucket rows only, so it takes no position on which is right — but one of them
probably is.