oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

1package home
2
3import (
4 "bytes"
5 "html"
6 "regexp"
7 "testing"
8
9 "amadan.net/oficina/estilo.git/sky"
10 "amadan.net/oficina/estilo.git/theme"
11)
12
13// TestFrontPageLineBreaksKeepTheirSpace: an earlier hero hid its <br> on
14// narrow screens, so a <br> glued to words on both sides ran them together
15// — "Open your newoffice suite." on every phone (polish audit, round 1).
16// The Calma hero wraps by itself and has no <br>; this stays so the next
17// one to come back keeps whitespace on at least one side.
18func TestFrontPageLineBreaksKeepTheirSpace(t *testing.T) {
19 if glued := regexp.MustCompile(`\S<br\s*/?>\S`).FindAll(indexPage, -1); len(glued) > 0 {
20 t.Fatalf("front page has <br> with no whitespace beside it: %q", glued)
21 }
22}
23
24// The front page renders its sky from estilo's template: every layer the
25// pinned estilo draws, the inline placeholders included, and the marker
26// gone.
27func TestFrontPageRendersEstilosSky(t *testing.T) {
28 if !bytes.Contains(indexPage, []byte(skyMarker)) {
29 t.Fatal("index.html has no sky marker")
30 }
31 // Attribute values are HTML-escaped (html/template writes "+" as
32 // "&#43;"); the browser reads them unescaped, so compare that.
33 page := []byte(html.UnescapeString(string(withSky(indexPage))))
34 if bytes.Contains(page, []byte(skyMarker)) {
35 t.Fatal("the sky marker was not replaced")
36 }
37 for _, layer := range sky.For(sky.SuiteSeed).Layers {
38 want := layer.Src
39 if want == "" {
40 want = string(layer.Inline)
41 }
42 if !bytes.Contains(page, []byte(`src="`+want+`"`)) {
43 t.Errorf("front page lacks the %s layer (%s)", layer.Name, layer.Tone)
44 }
45 }
46 if !bytes.Contains(indexPage, []byte(`"`+theme.FontPrefix+`fonts.css"`)) {
47 t.Errorf("front page does not link %sfonts.css", theme.FontPrefix)
48 }
49}
50