oficina / docs Public

Test that sign-in and its Keymail continuation are the door

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 5b888d860c85d5f3a6d4df31317bd73f964530d7 parent 5b000ca
1 file changed, +42 −0
  • internal/docs/signin_door_test.go +42 −0

CI cancelled — superseded by a newer push — run details

diff --git a/internal/docs/signin_door_test.go b/internal/docs/signin_door_test.go
new file mode 100644
index 0000000..7554dde
--- /dev/null
+++ b/internal/docs/signin_door_test.go
@@ -0,0 +1,42 @@
+package docs
+
+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) {
+ app, err := NewForTest(t)
+ if err != nil {
+ t.Fatal(err)
+ }
+ GET := func(p string) *httptest.ResponseRecorder {
+ return serve(app, httptest.NewRequest(http.MethodGet, p, nil))
+ }
+ rec := GET("/signin")
+ body := rec.Body.String()
+ for _, want := range []string{"estilo-door", "<span>Docs</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")
+ }
+}