oficina / calendar Public

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

Plain git — no account needed to clone.

Download

Download this file

1package calendartest
2
3import (
4 "net/http"
5 "strings"
6 "testing"
7)
8
9// Standalone (no Home), signing out lands on a real page: the estilo
10// signed-out door at /signed-out, as Home mode's sign-out does, rather than
11// back on the sign-in form as if nothing happened. /signed-out used to 404
12// without Home (Fable 5.1 follow-up finding 4 on #17).
13func TestStandaloneSignOutLandsOnTheSignedOutPage(t *testing.T) {
14 app, session := signedIn(t, "someone@example.com")
15 h := app.Handler()
16
17 rec := postAs(t, h, session, "/signout", nil)
18 if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/signed-out" {
19 t.Fatalf("POST /signout: %d to %q, want 303 to /signed-out", rec.Code, rec.Header().Get("Location"))
20 }
21 if after := getAs(t, h, session, "/day/2026-09-24"); after.Code != http.StatusSeeOther {
22 t.Fatalf("the session survived sign-out: GET a view answered %d", after.Code)
23 }
24
25 page := get(t, h, "/signed-out")
26 body := page.Body.String()
27 if page.Code != http.StatusOK || !strings.HasPrefix(page.Header().Get("Content-Type"), "text/html") {
28 t.Fatalf("GET /signed-out: %d %s", page.Code, page.Header().Get("Content-Type"))
29 }
30 for _, want := range []string{
31 "<title>Signed out · Calendar</title>",
32 "estilo-door",
33 // The door's words (estilo chrome.English), not the app's.
34 "<h1>You’re signed out</h1>",
35 "You’ve signed out of Calendar on this device.",
36 `<a rst-btn="primary" href="/signin">Sign in</a>`,
37 } {
38 if !strings.Contains(body, want) {
39 t.Errorf("/signed-out is missing %q:\n%s", want, body)
40 }
41 }
42 // The page that IS signing out shows nothing in the bar's corner.
43 if strings.Contains(body, "estilo-bar-signin") || strings.Contains(body, "estilo-account") {
44 t.Error("/signed-out drew a Sign in button or an account menu in the bar")
45 }
46}
47