forked from kevadesu/forgejo
Make wiki pages visit fast (#32732)
(cherry picked from commit b32f0cdfa05c3a0e34425e1b8a5dfa8b63914a01) Conflicts: tests/integration/wiki_test.go "Long-Page" is missing as well as the tests package
This commit is contained in:
parent
6ac88eab0f
commit
6f2875d3c6
2 changed files with 45 additions and 10 deletions
|
@ -6,14 +6,18 @@ package integration
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -47,3 +51,23 @@ func TestRepoCloneWiki(t *testing.T) {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_RepoWikiPages(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
url := "/user2/repo1/wiki/?action=_pages"
|
||||
req := NewRequest(t, "GET", url)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
expectedPagePaths := []string{
|
||||
"Home", "Long-Page", "Page-With-Image", "Page-With-Spaced-Name", "Unescaped-File",
|
||||
}
|
||||
doc.Find("tr").Each(func(i int, s *goquery.Selection) {
|
||||
firstAnchor := s.Find("a").First()
|
||||
href, _ := firstAnchor.Attr("href")
|
||||
pagePath := strings.TrimPrefix(href, "/user2/repo1/wiki/")
|
||||
|
||||
assert.EqualValues(t, expectedPagePaths[i], pagePath)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue