@@ -6,6 +6,7 @@ package integrations
6
6
7
7
import (
8
8
"net/http"
9
+ "path"
9
10
"strconv"
10
11
"strings"
11
12
"testing"
@@ -75,3 +76,33 @@ func TestNoLoginViewIssue(t *testing.T) {
75
76
resp := MakeRequest (req )
76
77
assert .EqualValues (t , http .StatusOK , resp .HeaderCode )
77
78
}
79
+
80
+ func testNewIssue (t * testing.T , session * TestSession , user , repo , title string ) {
81
+
82
+ req := NewRequest (t , "GET" , path .Join (user , repo , "issues" , "new" ))
83
+ resp := session .MakeRequest (t , req )
84
+ assert .EqualValues (t , http .StatusOK , resp .HeaderCode )
85
+
86
+ htmlDoc := NewHTMLParser (t , resp .Body )
87
+ link , exists := htmlDoc .doc .Find ("form.ui.form" ).Attr ("action" )
88
+ assert .True (t , exists , "The template has changed" )
89
+ req = NewRequestWithValues (t , "POST" , link , map [string ]string {
90
+ "_csrf" : htmlDoc .GetCSRF (),
91
+ "title" : title ,
92
+ })
93
+ req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
94
+ resp = session .MakeRequest (t , req )
95
+ assert .EqualValues (t , http .StatusFound , resp .HeaderCode )
96
+ redirectedURL := resp .Headers ["Location" ]
97
+ assert .NotEmpty (t , redirectedURL , "Redirected URL is not found" )
98
+
99
+ req = NewRequest (t , "GET" , redirectedURL [0 ])
100
+ resp = session .MakeRequest (t , req )
101
+ assert .EqualValues (t , http .StatusOK , resp .HeaderCode )
102
+ }
103
+
104
+ func TestNewIssue (t * testing.T ) {
105
+ prepareTestEnv (t )
106
+ session := loginUser (t , "user2" )
107
+ testNewIssue (t , session , "user2" , "repo1" , "Title" )
108
+ }
0 commit comments