oficina / calendar Public

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

Plain git — no account needed to clone.

Download

Download this file

1package calendar
2
3import (
4 "strings"
5 "testing"
6)
7
8// With Home on, the local form (/signin/local) and where sign-out lands
9// (/signed-out) are the Oficina door too. The form still posts to
10// /signin; the signed-out card is the door's own (never naming Home),
11// linking where connect says to sign in.
12func TestHomeSignInPagesAreTheDoor(t *testing.T) {
13 f := newHomeRouterFixture(t)
14 for path, want := range map[string][]string{
15 "/signin/local": {"estilo-door", "<title>Sign in · Calendar</title>", "<span>Calendar</span>", `action="/signin"`, `name="address"`, `type="submit">Sign in</button>`},
16 "/signin/local?sent=1": {"estilo-door", "<title>Check your email · Calendar</title>", "Check your email", `href="/signin/local"`, "Use a different address"},
17 "/signed-out": {"estilo-door", "<title>Signed out · Calendar</title>", "<span>Calendar</span>", "You’re signed out", "You’ve signed out of Calendar on this device.", `href="/signin">Sign in</a>`},
18 } {
19 w := f.do("GET", path, "")
20 if w.Code != 200 {
21 t.Fatalf("GET %s: status %d", path, w.Code)
22 }
23 for _, s := range want {
24 if !strings.Contains(w.Body.String(), s) {
25 t.Errorf("GET %s is missing %q:\n%s", path, s, w.Body.String())
26 }
27 }
28 }
29 if body := f.do("GET", "/signed-out", "").Body.String(); strings.Contains(body, "Home") {
30 t.Errorf("/signed-out names Home to people:\n%s", body)
31 }
32 if got := f.do("GET", "/signed-out", "").Header().Get("Cache-Control"); got != "no-store" {
33 t.Errorf("/signed-out Cache-Control = %q, want no-store", got)
34 }
35}
36
37// Astra's door-copy review: the account-connection start page speaks
38// the suite's words — "your Oficina account", the verb Connect — and
39// never names Home to people (home/connect English since Home #79).
40func TestHomeConnectStartPageNeverNamesHome(t *testing.T) {
41 f := newHomeRouterFixture(t)
42 f.local(t)
43 // A signed-in visit first, as TestHomeRouterRetainsExistingCalendarIdentity
44 // does: without one the connection page answers 403.
45 if w := f.do("GET", "/day/2026-09-10", ""); w.Code != 200 {
46 t.Fatal("local calendar", w.Code)
47 }
48 w := f.do("GET", "/account/home", "")
49 if w.Code != 200 {
50 t.Fatal(w.Code, w.Body.String())
51 }
52 b := w.Body.String()
53 for _, want := range []string{"Connect your Oficina account", ">Connect</button>"} {
54 if !strings.Contains(b, want) {
55 t.Errorf("the start page is missing %q", want)
56 }
57 }
58 for _, never := range []string{"Continue to Home", "Use Home", "to Home"} {
59 if strings.Contains(b, never) {
60 t.Errorf("the start page still says %q", never)
61 }
62 }
63}
64