@@ -18,13 +18,15 @@ import (
18
18
"code.gitea.io/gitea/models/db"
19
19
issues_model "code.gitea.io/gitea/models/issues"
20
20
repo_model "code.gitea.io/gitea/models/repo"
21
+ unit_model "code.gitea.io/gitea/models/unit"
21
22
"code.gitea.io/gitea/models/unittest"
22
23
user_model "code.gitea.io/gitea/models/user"
23
24
"code.gitea.io/gitea/modules/indexer/issues"
24
25
"code.gitea.io/gitea/modules/references"
25
26
"code.gitea.io/gitea/modules/setting"
26
27
api "code.gitea.io/gitea/modules/structs"
27
28
"code.gitea.io/gitea/modules/test"
29
+ files_service "code.gitea.io/gitea/services/repository/files"
28
30
"code.gitea.io/gitea/tests"
29
31
30
32
"github.com/PuerkitoBio/goquery"
@@ -815,3 +817,52 @@ func TestIssueFilterNoFollow(t *testing.T) {
815
817
assert .Equal (t , "nofollow" , rel )
816
818
})
817
819
}
820
+
821
+ func TestIssueForm (t * testing.T ) {
822
+ onGiteaRun (t , func (t * testing.T , u * url.URL ) {
823
+ user2 := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
824
+ session := loginUser (t , user2 .Name )
825
+ repo , _ , f := CreateDeclarativeRepo (t , user2 , "" ,
826
+ []unit_model.Type {unit_model .TypeCode , unit_model .TypeIssues }, nil ,
827
+ []* files_service.ChangeRepoFile {
828
+ {
829
+ Operation : "create" ,
830
+ TreePath : ".forgejo/issue_template/test.yaml" ,
831
+ ContentReader : strings .NewReader (`name: Test
832
+ about: Hello World
833
+ body:
834
+ - type: checkboxes
835
+ id: test
836
+ attributes:
837
+ label: Test
838
+ options:
839
+ - label: This is a label
840
+ ` ),
841
+ },
842
+ },
843
+ )
844
+ defer f ()
845
+
846
+ t .Run ("Choose list" , func (t * testing.T ) {
847
+ defer tests .PrintCurrentTest (t )()
848
+
849
+ req := NewRequest (t , "GET" , repo .Link ()+ "/issues/new/choose" )
850
+ resp := session .MakeRequest (t , req , http .StatusOK )
851
+ htmlDoc := NewHTMLParser (t , resp .Body )
852
+
853
+ htmlDoc .AssertElement (t , "a[href$='/issues/new?template=.forgejo%2fissue_template%2ftest.yaml']" , true )
854
+ })
855
+
856
+ t .Run ("Issue template" , func (t * testing.T ) {
857
+ defer tests .PrintCurrentTest (t )()
858
+
859
+ req := NewRequest (t , "GET" , repo .Link ()+ "/issues/new?template=.forgejo%2fissue_template%2ftest.yaml" )
860
+ resp := session .MakeRequest (t , req , http .StatusOK )
861
+ htmlDoc := NewHTMLParser (t , resp .Body )
862
+
863
+ htmlDoc .AssertElement (t , "#new-issue .field .ui.checkbox input[name='form-field-test-0']" , true )
864
+ checkboxLabel := htmlDoc .Find ("#new-issue .field .ui.checkbox label" ).Text ()
865
+ assert .Contains (t , checkboxLabel , "This is a label" )
866
+ })
867
+ })
868
+ }
0 commit comments