oficina / calendar Public

Merge main (app switcher lists the suite) into fix/connect-item-when-linked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	go.mod
#	go.sum
Paul Campbell pushed by paul@keymail.dev d7b5731e5498a0c744e5a810ed6daf0d4cb8ee3a parent edd56b9parent 7a2ad04
3 files changed, +54 −16
  • internal/calendar/chrome_calendar.go +4 −1
  • internal/calendar/home_consumer_test.go +46 −15
  • internal/calendar/routes.go +4 −0
diff --git a/internal/calendar/chrome_calendar.go b/internal/calendar/chrome_calendar.go
index b231000..22e0423 100644
--- a/internal/calendar/chrome_calendar.go
+++ b/internal/calendar/chrome_calendar.go
@@ -34,8 +34,11 @@ func calendarChrome(r *http.Request, signedIn bool, address string, mode chrome.
bar.SignIn = &chrome.Link{Href: "/signin?return_to=" + template.URLQueryEscaper(r.URL.RequestURI()), Label: "Sign in"}
return bar
}
+ // The app switcher, only with a hub directory configured: the suite's
+ // six apps as tiles, each at its own host under the directory's
+ // (estilo's chrome.SuiteApps), Calendar marked current, then "All apps".
if directory != "" {
- bar.Switcher = &chrome.Switcher{Label: "Oficina apps", AllApps: estilomenu.Item{Href: strings.TrimSuffix(directory, "/") + "/", Label: "All apps"}}
+ bar.Switcher = &chrome.Switcher{Label: "Oficina apps", CurrentLabel: "(this app)", Apps: chrome.SuiteApps(directory, "calendar"), AllApps: estilomenu.Item{Href: strings.TrimSuffix(directory, "/") + "/", Label: "All apps"}}
}
// A live session whose person could not be resolved (a removed Home
// person on an error page) still gets the menu, to sign out from, but
diff --git a/internal/calendar/home_consumer_test.go b/internal/calendar/home_consumer_test.go
index a371f12..7253e06 100644
--- a/internal/calendar/home_consumer_test.go
+++ b/internal/calendar/home_consumer_test.go
@@ -7,8 +7,8 @@ import (
"io"
"log/slog"
"net/http"
+ "net/http/httptest"
"path/filepath"
- "regexp"
"strings"
"testing"
@@ -70,23 +70,54 @@ func TestHomeSigninWhenSignedInReturnsToPage(t *testing.T) {
}
}
-// "All apps" is the estilo switcher's item (shared-chrome spec §6), linking
-// to the hub directory's root: HOME_DIRECTORY_ORIGIN (an origin, which
-// connect refuses with a path or a trailing slash) plus "/". No directory,
-// no switcher.
-func TestAllAppsLinksToDirectory(t *testing.T) {
- item := regexp.MustCompile(`<details estilo-switcher[\s\S]*?<a estilo-menu-item href="([^"]*)"><span estilo-menu-label>All apps</span></a>`)
- for _, configured := range []string{homeTestDirectory} {
- f := newHomeConsumerFixture(t, configured)
- f.local(t)
- m := item.FindStringSubmatch(f.do("GET", "/day/2026-09-10", "").Body.String())
- if m == nil {
- t.Fatalf("HOME_DIRECTORY_ORIGIN=%s: no All apps item in the estilo switcher", configured)
+// The switcher (shared-chrome spec §6) appears only with a hub directory
+// configured. It shows the suite's six apps as tiles, each at its own host
+// under the directory's, Calendar marked current, then below a divider
+// "All apps", linking to the directory's root: HOME_DIRECTORY_ORIGIN (an
+// origin, which connect refuses with a path or a trailing slash) plus "/".
+// The tiles' icons are served sessionless.
+func TestTheSwitcherShowsTheSuite(t *testing.T) {
+ f := newHomeConsumerFixture(t, homeTestDirectory)
+ f.local(t)
+ body := f.do("GET", "/day/2026-09-10", "").Body.String()
+ start := strings.Index(body, `<details estilo-switcher`)
+ if start < 0 {
+ t.Fatal("no switcher with a directory configured", body)
+ }
+ panel := body[start:]
+ panel = panel[:strings.Index(panel, "</details>")]
+ grid, allApps, ok := strings.Cut(panel, "<hr>")
+ if !ok || !strings.Contains(allApps, `<a estilo-menu-item href="`+homeTestDirectory+`/"><span estilo-menu-label>All apps</span></a>`) {
+ t.Error("the switcher does not offer All apps, at the directory's root, below the tiles", panel)
+ }
+ var tiles []string
+ for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] {
+ tiles = append(tiles, tile[:strings.Index(tile, "</a>")])
+ }
+ slugs := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"}
+ names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"}
+ if len(tiles) != len(slugs) {
+ t.Fatalf("%d tiles, want %d: %s", len(tiles), len(slugs), grid)
+ }
+ for i, slug := range slugs {
+ head := `href="https://` + slug + `.directory.example.test/"`
+ if slug == "calendar" {
+ head += ` aria-current="true"`
}
- if m[1] != homeTestDirectory+"/" {
- t.Errorf("HOME_DIRECTORY_ORIGIN=%s: All apps links to %q, want %q", configured, m[1], homeTestDirectory+"/")
+ head += `><img src="/static/estilo/brand/` + slug + `.svg" alt="" width="32" height="32"><span>` + names[i]
+ if !strings.HasPrefix(tiles[i], head) {
+ t.Errorf("tile %d = %s, want it to start %s", i, tiles[i], head)
}
}
+ if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[3], "<span estilo-visually-hidden> (this app)</span>") {
+ t.Error("Calendar is not the one current tile", grid)
+ }
+
+ icon := httptest.NewRecorder()
+ f.app.mux.ServeHTTP(icon, httptest.NewRequest("GET", homeTestOrigin+"/static/estilo/brand/calls.svg", nil))
+ if icon.Code != http.StatusOK || !strings.Contains(icon.Body.String(), "<svg") {
+ t.Errorf("a tile's icon, with no session, is %d", icon.Code)
+ }
bare := newHomeConsumerFixture(t, "")
bare.local(t)
diff --git a/internal/calendar/routes.go b/internal/calendar/routes.go
index 2ad2dd1..d77014f 100644
--- a/internal/calendar/routes.go
+++ b/internal/calendar/routes.go
@@ -1,6 +1,7 @@
package calendar
import (
+ "amadan.net/oficina/estilo.git/brand"
"amadan.net/oficina/estilo.git/sky"
"amadan.net/oficina/estilo.git/theme"
"amadan.net/oficina/home/connect"
@@ -181,6 +182,9 @@ func (a *App) routes(h *handlers, authPlugin *rauth.Auth, list allowlist, origin
// reachable signed out. More specific than "GET /static/", so the
// app's own asset handler never sees these paths.
mux.Handle("GET "+sky.Prefix, sky.Handler())
+ // The app switcher's tile icons, the suite's own marks: sessionless
+ // for the same reason, and likewise more specific than "GET /static/".
+ mux.Handle("GET "+brand.Prefix, brand.Handler())
mux.HandleFunc("GET /static/credits.css", serveCreditsCSS)
a.mountTick(mux, h)
mux.Handle("/", a.scheduled.middleware(r))