Skip to content

Commit 2da1367

Browse files
yp05327silverwind
andauthored
Fix incorrect menu/link on webhook edit page (#29709)
Fix #29699 --------- Co-authored-by: silverwind <[email protected]>
1 parent 43de021 commit 2da1367

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

routers/web/repo/setting/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
588588
return nil, nil
589589
}
590590
ctx.Data["BaseLink"] = orCtx.Link
591+
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
591592

592593
var w *webhook.Webhook
593594
if orCtx.RepoID > 0 {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package integration
5+
6+
import (
7+
"net/http"
8+
"strings"
9+
"testing"
10+
11+
"code.gitea.io/gitea/tests"
12+
13+
"github.com/PuerkitoBio/goquery"
14+
"github.com/stretchr/testify/assert"
15+
)
16+
17+
func TestNewWebHookLink(t *testing.T) {
18+
defer tests.PrepareTestEnv(t)()
19+
session := loginUser(t, "user2")
20+
21+
baseurl := "/user2/repo1/settings/hooks"
22+
tests := []string{
23+
// webhook list page
24+
baseurl,
25+
// new webhook page
26+
baseurl + "/gitea/new",
27+
// edit webhook page
28+
baseurl + "/1",
29+
}
30+
31+
for _, url := range tests {
32+
resp := session.MakeRequest(t, NewRequest(t, "GET", url), http.StatusOK)
33+
htmlDoc := NewHTMLParser(t, resp.Body)
34+
menus := htmlDoc.doc.Find(".ui.top.attached.header .ui.dropdown .menu a")
35+
menus.Each(func(i int, menu *goquery.Selection) {
36+
url, exist := menu.Attr("href")
37+
assert.True(t, exist)
38+
assert.True(t, strings.HasPrefix(url, baseurl))
39+
})
40+
}
41+
}

0 commit comments

Comments
 (0)