numberscope / frontscope

Numberscope's front end and user interface: responsible for specifying sequences and defining and displaying visualizers
MIT License
7 stars 15 forks source link

Consider adding an end-to-end image test of the text layout/UI #458

Closed gwhitney closed 1 month ago

gwhitney commented 2 months ago

In #420, we decided to go with image testing just the visualizer canvas, for the sake of not having to worry about text layout reproducibility in testing specimens. There was definitely an issue of layout differing in different situations, that seemed to be that the headless firefox/chromium on Glen's machine was not using the proper fonts or at least font metrics, whereas those on Kate/Aaron's machines were. Should we track this down and control it tightly enough to have at least one or more text layout/UI image tests? (Note that we do test that various interactions work.)

gwhitney commented 2 months ago

Well, here's a very likely source of my problems. If I turn on console output in the "Polyfactors" featured gallery test, I see among the messages:

[chromium] ...
Failed to decode downloaded font: http://localhost:5050/src/assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf
OTS parsing error: invalid sfntVersion: 1008813135
Error: Unsupported OpenType signature <!DO
    at Va (http://localhost:5050/assets/index-BO37ah4e.js:86:265557)
    at http://localhost:5050/assets/index-BO37ah4e.js:86:268798
    at z.onload (http://localhost:5050/assets/index-BO37ah4e.js:86:264548) /src/assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf
...
[firefox] ...
[JavaScript Error: "downloadable font: rejected by sanitizer (font-family: "Inter" style:normal weight:400 stretch:100 src index:0) source: http://localhost:5050/src/assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf"]
...
Error /src/assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf
...

And it turns out that to get the Histogram test to pass, I will need to fix this issue, so it might just fix the font non-matching problem altogether.

gwhitney commented 2 months ago

Aha, I found the issue with locating font resources in the build version of numberscope, and have fixed it in a commit about to come to #420. (Makes me wonder how this was possibly working for Kate/Aaron, but whatever...) So bumping this up to alpha because we should be able to deal with it. In fact, I have left one end-to-end test with a full snapshot to make sure this is working.

gwhitney commented 1 month ago

In the form it was eventually merged, #420 indeed included such a test, so closing.