Skip to content

Commit 7d53f05

Browse files
committed
fix test
1 parent 3703c2c commit 7d53f05

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/integration/pull_merge_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"path"
1414
"path/filepath"
15+
"regexp"
1516
"strconv"
1617
"strings"
1718
"testing"
@@ -40,6 +41,7 @@ import (
4041
commitstatus_service "code.gitea.io/gitea/services/repository/commitstatus"
4142
files_service "code.gitea.io/gitea/services/repository/files"
4243

44+
"github.com/PuerkitoBio/goquery"
4345
"github.com/stretchr/testify/assert"
4446
"github.com/stretchr/testify/require"
4547
)
@@ -237,7 +239,18 @@ func TestPullSquash(t *testing.T) {
237239
}
238240
}
239241

240-
message := "This a pull description\n--------------------\n* user2 updated the file!\n* user2 updated the file\n* Update README.md\n* Update README.md\n"
242+
resp = session.MakeRequest(t, NewRequest(t, "GET", prURL+"/merge_box"), http.StatusOK)
243+
htmlDoc = NewHTMLParser(t, resp.Body)
244+
message := ""
245+
htmlDoc.doc.Find("script").Each(func(i int, s *goquery.Selection) {
246+
scriptContent := s.Text()
247+
re := regexp.MustCompile(`const\s+defaultSquashMergeMessage\s*=\s*"(.*?)"\s*;`)
248+
matches := re.FindStringSubmatch(scriptContent)
249+
if len(matches) > 1 {
250+
message = matches[1]
251+
}
252+
})
253+
241254
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash, false, message)
242255

243256
req = NewRequest(t, "GET", "/user2/repo1/src/branch/master/")

0 commit comments

Comments
 (0)