- commit
- f9a45d4a8b3bb6ecf6037e10abd8104778bcf424
- parent
- bfff293ba096514f6bbe21dd0b9c033221c9b805
- author
- Dami <dami.etoile@gmail.com>
- kind
- test risk score 0.5 of 3, Jev's estimate
| M | e2e/ | 22 | +++++++++++++++++++++- |
@@ -59,7 +59,7 @@ func TestScreens(t *testing.T) {
5959 if got != string(want) {6060 actual := filepath.Join(t.TempDir(), sc.name+".html")6161 os.WriteFile(actual, []byte(got), 0o644)62- t.Errorf("screen %s changed; if intended, run make screens and review the gallery.\nplain text now:\n%s", sc.name, s.screen())62+ t.Errorf("screen %s changed; if intended, run make screens and review the gallery.\n%s\nplain text now:\n%s", sc.name, firstDiff(string(want), got), s.screen())6363 }6464 })6565 }@@ -194,3 +194,23 @@ h2{font:500 13px ui-monospace,monospace;color:#aaa;margin:0 0 8px}
194194 b.WriteString("</div>\n")195195 return os.WriteFile(filepath.Join(dir, "gallery.html"), []byte(b.String()), 0o644)196196 }197+198+// firstDiff shows the first line where a golden screen's HTML and the199+// screen now part, which the plain text can't show when only a color or200+// style changed.201+func firstDiff(want, got string) string {202+ w, g := strings.Split(want, "\n"), strings.Split(got, "\n")203+ for i := 0; i < len(w) || i < len(g); i++ {204+ var a, b string205+ if i < len(w) {206+ a = w[i]207+ }208+ if i < len(g) {209+ b = g[i]210+ }211+ if a != b {212+ return fmt.Sprintf("first difference, line %d:\n want %s\n got %s", i+1, a, b)213+ }214+ }215+ return "no line differs"216+}