package webui import ( "encoding/json" "net/http" "net/http/httptest" "strings" "testing" ) func TestWorkRequestRejectsLongTitle(t *testing.T) { for _, title := range []string{strings.Repeat("a", 81), strings.Repeat("界", 81)} { t.Run(title[:3], func(t *testing.T) { body, err := json.Marshal(workRequest{Identity: "operator", Workflow: "implement", Title: title, Instructions: "Full task description"}) if err != nil { t.Fatal(err) } request := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/work-requests", strings.NewReader(string(body))) request.Header.Set("Content-Type", "application/json") request.Header.Set("X-Archie-CSRF", "1") response := httptest.NewRecorder() (&Server{}).handleWorkRequest(response, request) if response.Code != http.StatusBadRequest || !strings.Contains(response.Body.String(), "title must be 80 characters or fewer") { t.Fatalf("response = %d %s", response.Code, response.Body.String()) } }) } }