mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-25 14:53:15 +01:00
Add integration test for downloading a patch/diff file in compare page
This commit is contained in:
parent
a302506095
commit
4b69aa5c10
1 changed files with 27 additions and 0 deletions
|
@ -23,6 +23,7 @@ import (
|
|||
files_service "code.gitea.io/gitea/services/repository/files"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -67,6 +68,32 @@ func inspectCompare(t *testing.T, htmlDoc *HTMLDoc, diffCount int, diffChanges [
|
|||
}
|
||||
}
|
||||
|
||||
func TestComparePatchAndDiffMenuEntries(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
session := loginUser(t, "user2")
|
||||
req := NewRequest(t, "GET", "/user2/repo-release/compare/v1.0...v2.0")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
diffOptions := htmlDoc.doc.Find("[data-tooltip-content=\"Diff options\"]")
|
||||
|
||||
var patchDownloadEntryPresent bool
|
||||
var diffDownloadEntryPresent bool
|
||||
diffOptions.Children().Each(func (idx int, c *goquery.Selection) {
|
||||
value, exists := c.Attr("download")
|
||||
if exists && strings.HasSuffix(value, ".patch") {
|
||||
patchDownloadEntryPresent = true
|
||||
}
|
||||
|
||||
if exists && strings.HasSuffix(value, ".diff") {
|
||||
diffDownloadEntryPresent = true
|
||||
}
|
||||
})
|
||||
|
||||
assert.True(t, patchDownloadEntryPresent, "Patch file download entry should be present")
|
||||
assert.True(t, diffDownloadEntryPresent, "Diff file download entry should be present")
|
||||
}
|
||||
|
||||
// Git commit graph for repo20
|
||||
// * 8babce9 (origin/remove-files-b) Add a dummy file
|
||||
// * b67e43a Delete test.csv and link_hi
|
||||
|
|
Loading…
Reference in a new issue