Files
pages/internal/server/calendar_mobile_test.go
T
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

51 lines
1.6 KiB
Go

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))
}
}