Test that sign-in is the door
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+37
−0
internal/slidestest/signin_door_test.go+37 −0
CI passed — run details
diff --git a/internal/slidestest/signin_door_test.go b/internal/slidestest/signin_door_test.go| new file mode 100644 |
| index 0000000..8557cf0 |
| --- /dev/null |
| +++ b/internal/slidestest/signin_door_test.go |
| @@ -0,0 +1,37 @@ |
| +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", "<span>Slides</span>", `name="address"`, " autofocus"} { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("sign-in page lacks %q", want) |
| + } |
| + } |
| + if !regexp.MustCompile(`<img estilo-sky-layer="placeholder"[^>]*src="data:image/png;base64,`).MatchString(body) { |
| + t.Error("sign-in page has no inline sky placeholder") |
| + } |
| + layer := regexp.MustCompile(`<img estilo-sky-layer="[a-z]+"[^>]*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") |
| + } |
| +} |