@@ -52,14 +52,19 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
52
52
53
53
// Call API to add status for commit
54
54
ctx := NewAPITestContext (t , "user2" , "repo1" , auth_model .AccessTokenScopeRepo )
55
- t .Run ("CreateStatus" , doAPICreateCommitStatus (ctx , path .Base (commitURL ), api .CommitStatusState (state )))
55
+ t .Run ("CreateStatus" , doAPICreateCommitStatus (ctx , path .Base (commitURL ), api.CreateStatusOption {
56
+ State : api .CommitStatusState (state ),
57
+ TargetURL : "http://test.ci/" ,
58
+ Description : "" ,
59
+ Context : "testci" ,
60
+ }))
56
61
57
62
req = NewRequest (t , "GET" , "/user2/repo1/commits/branch/master" )
58
63
resp = session .MakeRequest (t , req , http .StatusOK )
59
64
60
65
doc = NewHTMLParser (t , resp .Body )
61
- // Check if commit status is displayed in message column
62
- sel := doc .doc .Find ("#commits-table tbody tr td.message a.commit-statuses-trigger .commit-status" )
66
+ // Check if commit status is displayed in message column (.tippy-target to ignore the tippy trigger)
67
+ sel := doc .doc .Find ("#commits-table tbody tr td.message .tippy-target .commit-status" )
63
68
assert .Equal (t , 1 , sel .Length ())
64
69
for _ , class := range classes {
65
70
assert .True (t , sel .HasClass (class ))
@@ -145,11 +150,56 @@ func TestRepoCommitsStatusParallel(t *testing.T) {
145
150
go func (parentT * testing.T , i int ) {
146
151
parentT .Run (fmt .Sprintf ("ParallelCreateStatus_%d" , i ), func (t * testing.T ) {
147
152
ctx := NewAPITestContext (t , "user2" , "repo1" , auth_model .AccessTokenScopeRepoStatus )
148
- runBody := doAPICreateCommitStatus (ctx , path .Base (commitURL ), api .CommitStatusState ("pending" ))
153
+ runBody := doAPICreateCommitStatus (ctx , path .Base (commitURL ), api.CreateStatusOption {
154
+ State : api .CommitStatusPending ,
155
+ TargetURL : "http://test.ci/" ,
156
+ Description : "" ,
157
+ Context : "testci" ,
158
+ })
149
159
runBody (t )
150
160
wg .Done ()
151
161
})
152
162
}(t , i )
153
163
}
154
164
wg .Wait ()
155
165
}
166
+
167
+ func TestRepoCommitsStatusMultiple (t * testing.T ) {
168
+ defer tests .PrepareTestEnv (t )()
169
+
170
+ session := loginUser (t , "user2" )
171
+
172
+ // Request repository commits page
173
+ req := NewRequest (t , "GET" , "/user2/repo1/commits/branch/master" )
174
+ resp := session .MakeRequest (t , req , http .StatusOK )
175
+
176
+ doc := NewHTMLParser (t , resp .Body )
177
+ // Get first commit URL
178
+ commitURL , exists := doc .doc .Find ("#commits-table tbody tr td.sha a" ).Attr ("href" )
179
+ assert .True (t , exists )
180
+ assert .NotEmpty (t , commitURL )
181
+
182
+ // Call API to add status for commit
183
+ ctx := NewAPITestContext (t , "user2" , "repo1" , auth_model .AccessTokenScopeRepo )
184
+ t .Run ("CreateStatus" , doAPICreateCommitStatus (ctx , path .Base (commitURL ), api.CreateStatusOption {
185
+ State : api .CommitStatusSuccess ,
186
+ TargetURL : "http://test.ci/" ,
187
+ Description : "" ,
188
+ Context : "testci" ,
189
+ }))
190
+
191
+ t .Run ("CreateStatus" , doAPICreateCommitStatus (ctx , path .Base (commitURL ), api.CreateStatusOption {
192
+ State : api .CommitStatusSuccess ,
193
+ TargetURL : "http://test.ci/" ,
194
+ Description : "" ,
195
+ Context : "other_context" ,
196
+ }))
197
+
198
+ req = NewRequest (t , "GET" , "/user2/repo1/commits/branch/master" )
199
+ resp = session .MakeRequest (t , req , http .StatusOK )
200
+
201
+ doc = NewHTMLParser (t , resp .Body )
202
+ // Check that the data-tippy="commit-statuses" (for trigger) and commit-status (svg) are present
203
+ sel := doc .doc .Find ("#commits-table tbody tr td.message [data-tippy=\" commit-statuses\" ] .commit-status" )
204
+ assert .Equal (t , 1 , sel .Length ())
205
+ }
0 commit comments