mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-29 11:48:56 +03:00
Fix incorrect menu/link on webhook edit page (#29709)
Fix #29699 --------- Co-authored-by: silverwind <me@silverwind.io> (cherry picked from commit 2da13675c0cfdc531044553636c3b74f2fda3eb4)
This commit is contained in:
parent
071d871dcf
commit
2da0628f18
2 changed files with 42 additions and 0 deletions
|
@ -616,6 +616,7 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
ctx.Data["BaseLink"] = orCtx.Link
|
ctx.Data["BaseLink"] = orCtx.Link
|
||||||
|
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
|
||||||
|
|
||||||
var w *webhook.Webhook
|
var w *webhook.Webhook
|
||||||
if orCtx.RepoID > 0 {
|
if orCtx.RepoID > 0 {
|
||||||
|
|
41
tests/integration/repo_webhook_test.go
Normal file
41
tests/integration/repo_webhook_test.go
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewWebHookLink(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
|
||||||
|
baseurl := "/user2/repo1/settings/hooks"
|
||||||
|
tests := []string{
|
||||||
|
// webhook list page
|
||||||
|
baseurl,
|
||||||
|
// new webhook page
|
||||||
|
baseurl + "/gitea/new",
|
||||||
|
// edit webhook page
|
||||||
|
baseurl + "/1",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, url := range tests {
|
||||||
|
resp := session.MakeRequest(t, NewRequest(t, "GET", url), http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
menus := htmlDoc.doc.Find(".ui.top.attached.header .ui.dropdown .menu a")
|
||||||
|
menus.Each(func(i int, menu *goquery.Selection) {
|
||||||
|
url, exist := menu.Attr("href")
|
||||||
|
assert.True(t, exist)
|
||||||
|
assert.True(t, strings.HasPrefix(url, baseurl))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue