package server import ( "context" "encoding/json" "net/http" "net/http/httptest" "os" "os/exec" "pageswiki/internal/calendar" "testing" "time" ) func TestCalendarMobileChromium(t *testing.T) { if os.Getenv("PAGESWIKI_BROWSER_TEST") != "1" { t.Skip("opt-in Chromium mobile fixture") } s, token, domain := configFixture(t) s.registerCalendarRoutes() if err := s.store.SetConfigInDomain(domain, "timezone", "Asia/Tokyo"); err != nil { t.Fatal(err) } w := calendarRequest(s, token, "POST", calendarAPI+"calendars", `{"name":"Mobile fixture calendar","pretty_name":"mobile"}`, "") if w.Code != 201 { t.Fatal(w.Body.String()) } var c calendar.Calendar json.Unmarshal(w.Body.Bytes(), &c) for _, title := range []string{"Mobile meeting with a readable title", "Overlapping meeting"} { raw, _ := json.Marshal(map[string]string{"summary": title, "start": "2026-09-22T09:00:00Z", "end": "2026-09-22T10:00:00Z"}) if w = calendarRequest(s, token, "POST", calendarAPI+"calendars/"+c.ID+"/events", string(raw), ""); w.Code != 201 { t.Fatal(w.Body.String()) } } srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.Host = "localhost" r.Header.Set("Authorization", "Bearer "+token) s.withAuthorization(s.mux).ServeHTTP(w, r) })) defer srv.Close() ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() cmd := exec.CommandContext(ctx, "node", "internal/server/testdata/calendar-mobile-smoke.mjs", srv.URL, t.TempDir()) if out, e := cmd.CombinedOutput(); e != nil { t.Fatalf("mobile calendar: %v %s", e, out) } else { t.Log(string(out)) } }