@@ -57,6 +57,70 @@ func Test_ReposGitCommitListNotMaster(t *testing.T) {
57
57
userHrefs = append (userHrefs , userHref )
58
58
})
59
59
assert .Equal (t , []string {"/user2" , "/user21" , "/user2" }, userHrefs )
60
+
61
+ // check last commit author wrapper
62
+ req = NewRequest (t , "GET" , "/user2/repo16" )
63
+ resp = session .MakeRequest (t , req , http .StatusOK )
64
+
65
+ doc = NewHTMLParser (t , resp .Body )
66
+ commits = []string {}
67
+ doc .doc .Find (".latest-commit .commit-id-short" ).Each (func (i int , s * goquery.Selection ) {
68
+ commitURL , _ := s .Attr ("href" )
69
+ commits = append (commits , path .Base (commitURL ))
70
+ })
71
+ assert .Equal (t , []string {"69554a64c1e6030f051e5c3f94bfbd773cd6a324" }, commits )
72
+
73
+ userHrefs = []string {}
74
+ doc .doc .Find (".latest-commit .author-wrapper" ).Each (func (i int , s * goquery.Selection ) {
75
+ userHref , _ := s .Attr ("href" )
76
+ userHrefs = append (userHrefs , userHref )
77
+ })
78
+ assert .Equal (t , []string {"/user2" }, userHrefs )
79
+ }
80
+
81
+ func Test_ReposGitCommitListNoGiteaUser (t * testing.T ) {
82
+ // Commits list with Gitea User has been tested in Test_ReposGitCommitListNotMaster
83
+ defer tests .PrepareTestEnv (t )()
84
+ session := loginUser (t , "user2" )
85
+
86
+ // check commits list for a repository with no gitea user
87
+ req := NewRequest (t , "GET" , "/user2/repo1/commits/branch/master" )
88
+ resp := session .MakeRequest (t , req , http .StatusOK )
89
+
90
+ doc := NewHTMLParser (t , resp .Body )
91
+ var commits []string
92
+ doc .doc .Find ("#commits-table .commit-id-short" ).Each (func (i int , s * goquery.Selection ) {
93
+ commitURL , _ := s .Attr ("href" )
94
+ commits = append (commits , path .Base (commitURL ))
95
+ })
96
+ assert .Equal (t , []string {"65f1bf27bc3bf70f64657658635e66094edbcb4d" }, commits )
97
+
98
+ var gitUsers []string
99
+ doc .doc .Find ("#commits-table .author-wrapper" ).Each (func (i int , s * goquery.Selection ) {
100
+ assert .Equal (t , "span" , goquery .NodeName (s ))
101
+ gitUser := s .Text ()
102
+ gitUsers = append (gitUsers , gitUser )
103
+ })
104
+ assert .Equal (t , []string {"user1" }, gitUsers )
105
+
106
+ // check last commit author wrapper
107
+ req = NewRequest (t , "GET" , "/user2/repo1" )
108
+ resp = session .MakeRequest (t , req , http .StatusOK )
109
+
110
+ doc = NewHTMLParser (t , resp .Body )
111
+ commits = []string {}
112
+ doc .doc .Find (".latest-commit .commit-id-short" ).Each (func (i int , s * goquery.Selection ) {
113
+ commitURL , _ := s .Attr ("href" )
114
+ commits = append (commits , path .Base (commitURL ))
115
+ })
116
+ assert .Equal (t , []string {"65f1bf27bc3bf70f64657658635e66094edbcb4d" }, commits )
117
+
118
+ gitUsers = []string {}
119
+ doc .doc .Find (".latest-commit .author-wrapper" ).Each (func (i int , s * goquery.Selection ) {
120
+ assert .Equal (t , "span" , goquery .NodeName (s ))
121
+ gitUsers = append (gitUsers , s .Text ())
122
+ })
123
+ assert .Equal (t , []string {"user1" }, gitUsers )
60
124
}
61
125
62
126
func doTestRepoCommitWithStatus (t * testing.T , state string , classes ... string ) {
0 commit comments