package slidestest import ( "net/http" "net/http/httptest" "regexp" "strings" "testing" ) // The sign-in page is the Oficina door (estilo chrome): a card on the // suite sky with this app's mark and name, its sky layers served signed // out by estilo's handler rather than shadowed by the app's /static/. func TestSignInPageIsTheDoor(t *testing.T) { h := newApp(t) GET := func(p string) *httptest.ResponseRecorder { return get(t, h, p) } rec := GET("/signin") body := rec.Body.String() for _, want := range []string{"estilo-door", "Slides", `name="address"`, " autofocus"} { if !strings.Contains(body, want) { t.Errorf("sign-in page lacks %q", want) } } if !regexp.MustCompile(`]*src="data:image/png;base64,`).MatchString(body) { t.Error("sign-in page has no inline sky placeholder") } layer := regexp.MustCompile(`]*src="(/static/estilo/sky/v1/[^"]+)"`).FindStringSubmatch(body) if layer == nil { t.Fatal("sign-in page links no served sky layer") } if got := GET(layer[1]); got.Code != http.StatusOK || got.Header().Get("Content-Type") != "image/svg+xml" { t.Errorf("GET %s signed out: %d %q, want 200 image/svg+xml", layer[1], got.Code, got.Header().Get("Content-Type")) } if !regexp.MustCompile(`/static/estilo/sky\.[0-9a-f]{16}\.css`).MatchString(body) { t.Error("sign-in page does not link sky.css") } } // TestDoorCopyIsEstilos pins the door's words, which are estilo's, not // this app's: the submit reads "Sign in" and never "Email me a link" // (Paul, 2026-10-01), the hub is never named, and the three tab titles // are " · Slides". func TestDoorCopyIsEstilos(t *testing.T) { h := newApp(t) title := regexp.MustCompile(`([^<]*)`) for _, tc := range []struct { path, title string want []string }{ {"/signin", "Sign in · Slides", []string{ "Email address", "We’ll email you a link that signs you in. It works once and expires in 15 minutes.", ">Sign in", }}, {"/signin?sent=1", "Check your email · Slides", []string{ "Check your email", "If that address can sign in here, we’ve sent it a link. It works once and expires in 15 minutes.", ">Use a different address", }}, {"/signed-out", "Signed out · Slides", []string{ "You’re signed out", "You’ve signed out of Slides on this device.", `href="/signin"`, }}, } { rec := get(t, h, tc.path) body := rec.Body.String() if rec.Code != http.StatusOK { t.Fatalf("GET %s: %d", tc.path, rec.Code) } if m := title.FindStringSubmatch(body); m == nil || m[1] != tc.title { t.Errorf("GET %s: title %v, want %q", tc.path, m, tc.title) } for _, w := range tc.want { if !strings.Contains(body, w) { t.Errorf("GET %s lacks %q", tc.path, w) } } for _, bad := range []string{"Email me a link", "Home"} { if strings.Contains(body, bad) { t.Errorf("GET %s says %q", tc.path, bad) } } } }