mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 06:04:25 +00:00
42 lines
952 B
Go
42 lines
952 B
Go
|
// 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))
|
||
|
})
|
||
|
}
|
||
|
}
|