Skip to content

Commit 5a3ae36

Browse files
authored
feat(webhook): enhance BugComment events with additional fields and tests (#55)
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
1 parent 2dd688d commit 5a3ae36

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed

features.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ API 文档:https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/
298298
- [ ] `task_comment::add`
299299
- [ ] `task_comment::update`
300300
- [ ] `task_comment::delete`
301-
- [ ] `bug_comment::add`
302-
- [ ] `bug_comment::update`
303-
- [ ] `bug_comment::delete`
301+
- [x] `bug_comment::add`
302+
- [x] `bug_comment::update`
303+
- [x] `bug_comment::delete`
304304
- [x] 迭代
305305
- [x] `iteration::create`
306306
- [x] `iteration::update`

webhook/event_bug_comment.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,21 @@ type BugCommentAddEvent struct {
2020
}
2121

2222
type BugCommentUpdateEvent struct {
23-
Event EventType `json:"event,omitempty"`
23+
Event EventType `json:"event,omitempty"`
24+
EventFrom string `json:"event_from,omitempty"`
25+
Referer string `json:"referer,omitempty"`
26+
WorkspaceID string `json:"workspace_id,omitempty"`
27+
CurrentUser string `json:"current_user,omitempty"`
28+
ID string `json:"id,omitempty"`
29+
Description string `json:"description,omitempty"`
30+
Author string `json:"author,omitempty"`
31+
EntityID string `json:"entity_id,omitempty"`
32+
Secret string `json:"secret,omitempty"`
33+
RioToken string `json:"rio_token,omitempty"`
34+
DevProxyHost string `json:"devproxy_host,omitempty"`
35+
QueueID string `json:"queue_id,omitempty"`
36+
EventID string `json:"event_id,omitempty"`
37+
Created string `json:"created,omitempty"`
2438
}
2539

2640
type BugCommentDeleteEvent struct {

webhook/event_bug_comment_test.go

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package webhook
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestBugCommentEvent_BugCommentAddEvent(t *testing.T) {
10+
var event BugCommentAddEvent
11+
loadAndParseWebhookData(t, "bug_comment/add.json", &event)
12+
13+
assert.Equal(t, event, BugCommentAddEvent{
14+
Event: EventTypeBugCommentAdd,
15+
EventFrom: "web",
16+
Referer: "https://www.tapd.cn/tapd_fe/111222/bug/list?confId=11111222001048467&dialog_preview_id=bug_11111222001037212",
17+
WorkspaceID: "111222",
18+
CurrentUser: "张三",
19+
ID: "11111222001036001",
20+
Title: "在状态 [新] 添加",
21+
Description: "<p>123123</p>",
22+
Author: "张三",
23+
EntityID: "11111222001037212",
24+
Secret: "",
25+
RioToken: "",
26+
DevProxyHost: "http://websocket-proxy",
27+
QueueID: "318928285",
28+
EventID: "183722797",
29+
Created: "2024-12-30 17:41:02",
30+
})
31+
}
32+
33+
func TestBugCommentEvent_BugCommentUpdateEvent(t *testing.T) {
34+
var event BugCommentUpdateEvent
35+
loadAndParseWebhookData(t, "bug_comment/update.json", &event)
36+
37+
assert.Equal(t, event, BugCommentUpdateEvent{
38+
Event: EventTypeBugCommentUpdate,
39+
EventFrom: "web",
40+
Referer: "https://www.tapd.cn/tapd_fe/111222333/bug/list?confId=11111222333001048467&dialog_preview_id=bug_11111222333001037212",
41+
WorkspaceID: "111222333",
42+
CurrentUser: "张三",
43+
ID: "11111222333001036001",
44+
Description: "<p>12312323</p>",
45+
Author: "张三",
46+
EntityID: "11111222333001037212",
47+
Secret: "",
48+
RioToken: "",
49+
DevProxyHost: "http://websocket-proxy",
50+
QueueID: "318963935",
51+
EventID: "183737413",
52+
Created: "2024-12-30 18:30:02",
53+
})
54+
}
55+
56+
func TestBugCommentEvent_BugCommentDeleteEvent(t *testing.T) {
57+
var event BugCommentDeleteEvent
58+
loadAndParseWebhookData(t, "bug_comment/delete.json", &event)
59+
60+
assert.Equal(t, event, BugCommentDeleteEvent{
61+
Event: EventTypeBugCommentDelete,
62+
EventFrom: "web",
63+
Referer: "https://www.tapd.cn/111111/comments/delete_comment/",
64+
WorkspaceID: "111111",
65+
CurrentUser: "李四",
66+
ID: "11111111001035977",
67+
Description: "<p>這個可能是需求</p>",
68+
Author: "李四",
69+
EntityID: "11111111001039882",
70+
Secret: "",
71+
RioToken: "",
72+
DevProxyHost: "http://websocket-proxy",
73+
QueueID: "318938077",
74+
EventID: "183726824",
75+
Created: "2024-12-30 17:55:19",
76+
})
77+
}

0 commit comments

Comments
 (0)