fix(erpsetup): name the Frappe webhooks #38

Merged
sharang merged 1 commits from fix/erpsetup-webhook-name into main 2026-09-24 10:34:10 +00:00
2 changed files with 15 additions and 1 deletions

No files matched your search

+11
View File
@@ -182,3 +182,14 @@ func TestWebhookBodiesAreValidJSONShapes(t *testing.T) {
}
}
}
func TestWebhookDocIsNamed(t *testing.T) {
seen := map[string]bool{}
for _, w := range webhooks("https://r.test/hook", "s") {
name, _ := w.doc()["name"].(string)
if name != "breakpilot-"+w.Event || seen[name] {
t.Fatalf("webhook %s: name %q", w.Event, name)
}
seen[name] = true
}
}
+4 -1
View File
@@ -79,7 +79,10 @@ type webhook struct {
func (w webhook) doc() map[string]any {
return map[string]any{
"doctype": "Webhook",
"doctype": "Webhook",
// Frappe names a Webhook by prompt: without a name the insert fails
// with "Please enter the document name".
"name": "breakpilot-" + w.Event,
"webhook_doctype": w.Doctype,
"webhook_docevent": w.DocEvent,
"condition": w.Condition,