mirror of
https://github.com/go-gitea/gitea
synced 2024-11-18 16:01:36 +01:00
Add integration test for issue creating (#2002)
This commit is contained in:
parent
255adc40ae
commit
4d2ea7dc41
1 changed files with 31 additions and 0 deletions
|
@ -6,6 +6,7 @@ package integrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -75,3 +76,33 @@ func TestNoLoginViewIssue(t *testing.T) {
|
||||||
resp := MakeRequest(req)
|
resp := MakeRequest(req)
|
||||||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) {
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", path.Join(user, repo, "issues", "new"))
|
||||||
|
resp := session.MakeRequest(t, req)
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||||
|
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
|
||||||
|
assert.True(t, exists, "The template has changed")
|
||||||
|
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||||
|
"_csrf": htmlDoc.GetCSRF(),
|
||||||
|
"title": title,
|
||||||
|
})
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
resp = session.MakeRequest(t, req)
|
||||||
|
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
|
||||||
|
redirectedURL := resp.Headers["Location"]
|
||||||
|
assert.NotEmpty(t, redirectedURL, "Redirected URL is not found")
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", redirectedURL[0])
|
||||||
|
resp = session.MakeRequest(t, req)
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewIssue(t *testing.T) {
|
||||||
|
prepareTestEnv(t)
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
testNewIssue(t, session, "user2", "repo1", "Title")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue