mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 09:09:02 +00:00
add issue checklist integration test
This commit is contained in:
parent
b2bbf48c18
commit
58c60ec11c
|
@ -10,6 +10,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -236,9 +237,13 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo, title, content
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
val := htmlDoc.doc.Find("#issue-title-display").Text()
|
val := htmlDoc.doc.Find("#issue-title-display").Text()
|
||||||
assert.Contains(t, val, title)
|
assert.Contains(t, val, title)
|
||||||
val = htmlDoc.doc.Find(".comment .render-content p").First().Text()
|
// test for first line only and if it contains only letters and spaces
|
||||||
assert.Equal(t, content, val)
|
contentFirstLine := strings.Split(content, "\n")[0]
|
||||||
|
patNotLetterOrSpace, _ := regexp.Compile("[^\\p{L}\\s]")
|
||||||
|
if len(contentFirstLine) != 0 && !patNotLetterOrSpace.MatchString(contentFirstLine) {
|
||||||
|
val = htmlDoc.doc.Find(".comment .render-content p").First().Text()
|
||||||
|
assert.Equal(t, contentFirstLine, val)
|
||||||
|
}
|
||||||
return issueURL
|
return issueURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +286,36 @@ func TestNewIssue(t *testing.T) {
|
||||||
testNewIssue(t, session, "user2", "repo1", "Title", "Description")
|
testNewIssue(t, session, "user2", "repo1", "Title", "Description")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssueCheckboxes(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
issueURL := testNewIssue(t, session, "user2", "repo1", "Title", `- [x] small x
|
||||||
|
- [X] capital X
|
||||||
|
- [ ] empty
|
||||||
|
- [x]x without gap
|
||||||
|
- [ ]empty without gap
|
||||||
|
- [x]
|
||||||
|
x on new line
|
||||||
|
- [ ]
|
||||||
|
empty on new line
|
||||||
|
- [ ] tabs instead of spaces
|
||||||
|
Description`)
|
||||||
|
req := NewRequest(t, "GET", issueURL)
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
issueContent := NewHTMLParser(t, resp.Body).doc.Find(".comment .render-content").First()
|
||||||
|
isCheckBox := func(i int, s *goquery.Selection) bool {
|
||||||
|
typeVal, typeExists := s.Attr("type")
|
||||||
|
return typeExists && typeVal == "checkbox"
|
||||||
|
}
|
||||||
|
isChecked := func(i int, s *goquery.Selection) bool {
|
||||||
|
_, checkedExists := s.Attr("checked")
|
||||||
|
return checkedExists
|
||||||
|
}
|
||||||
|
checkBoxes := issueContent.Find("input").FilterFunction(isCheckBox)
|
||||||
|
assert.Equal(t, 8, checkBoxes.Length())
|
||||||
|
assert.Equal(t, 4, checkBoxes.FilterFunction(isChecked).Length())
|
||||||
|
}
|
||||||
|
|
||||||
func TestIssueDependencies(t *testing.T) {
|
func TestIssueDependencies(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue