o-spreadsheet icon indicating copy to clipboard operation
o-spreadsheet copied to clipboard

[IMP] tests: Snapshot rendered canvas

Open LucasLefevre opened this issue 3 years ago • 5 comments

Writing renderer tests is cumbersome. It relies on a mock canvas and tests must check what properties/methods the renderer calls. It is hard to write and read. As a result, the renderer is poorly tested.

Moreover, this testing strategy is fragile since it relies on the renderer implementation.

This PR addresses both issues at once. We can now "screenshot" the canvas and save it as a jest snapshot. Like regular jest snapshot, tests will fail if the screenshot is not identical to the previous one.

One downside: png images are committed in the repo. It shouldn't be much of a problem since they would usually be small. But makes sure to only screenshot what you need ;)

Existing tests are also converted with this new screenshot mechanism.

LucasLefevre avatar Mar 11 '21 11:03 LucasLefevre

renderer-fillstyle-of-merge-will-be-rendered-for-all-cells-in-merge-1-snap.png shows there is an issue: if the merge spans A1:A3, what is the cell selected on A1 alone ? same for the other tests with merges

VincentSchippefilt avatar Mar 12 '21 11:03 VincentSchippefilt

what is the cell selected on A1 alone ?

The merged cells were not "selected" before merging => selection rendering was not correct. I fixed it

LucasLefevre avatar Mar 15 '21 12:03 LucasLefevre

Hmm... runbot generates slightly different screenshots... :thinking:

LucasLefevre avatar Mar 15 '21 12:03 LucasLefevre

Sorry, I didn't know about this PR and had to retrieve its information, you may have to re-approve it.

robodoo avatar Feb 28 '22 14:02 robodoo