@ -52,14 +52,19 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
// Call API to add status for commit
ctx := NewAPITestContext ( t , "user2" , "repo1" , auth_model . AccessTokenScopeRepo )
t . Run ( "CreateStatus" , doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CommitStatusState ( state ) ) )
t . Run ( "CreateStatus" , doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CreateStatusOption {
State : api . CommitStatusState ( state ) ,
TargetURL : "http://test.ci/" ,
Description : "" ,
Context : "testci" ,
} ) )
req = NewRequest ( t , "GET" , "/user2/repo1/commits/branch/master" )
resp = session . MakeRequest ( t , req , http . StatusOK )
doc = NewHTMLParser ( t , resp . Body )
// Check if commit status is displayed in message column
sel := doc . doc . Find ( "#commits-table tbody tr td.message a.commit-statuses-trigger .commit-status" )
// Check if commit status is displayed in message column (.tippy-target to ignore the tippy trigger)
sel := doc . doc . Find ( "#commits-table tbody tr td.message .tippy-target .commit-status" )
assert . Equal ( t , 1 , sel . Length ( ) )
for _ , class := range classes {
assert . True ( t , sel . HasClass ( class ) )
@ -145,7 +150,12 @@ func TestRepoCommitsStatusParallel(t *testing.T) {
go func ( parentT * testing . T , i int ) {
parentT . Run ( fmt . Sprintf ( "ParallelCreateStatus_%d" , i ) , func ( t * testing . T ) {
ctx := NewAPITestContext ( t , "user2" , "repo1" , auth_model . AccessTokenScopeRepoStatus )
runBody := doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CommitStatusState ( "pending" ) )
runBody := doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CreateStatusOption {
State : api . CommitStatusPending ,
TargetURL : "http://test.ci/" ,
Description : "" ,
Context : "testci" ,
} )
runBody ( t )
wg . Done ( )
} )
@ -153,3 +163,43 @@ func TestRepoCommitsStatusParallel(t *testing.T) {
}
wg . Wait ( )
}
func TestRepoCommitsStatusMultiple ( t * testing . T ) {
defer tests . PrepareTestEnv ( t ) ( )
session := loginUser ( t , "user2" )
// Request repository commits page
req := NewRequest ( t , "GET" , "/user2/repo1/commits/branch/master" )
resp := session . MakeRequest ( t , req , http . StatusOK )
doc := NewHTMLParser ( t , resp . Body )
// Get first commit URL
commitURL , exists := doc . doc . Find ( "#commits-table tbody tr td.sha a" ) . Attr ( "href" )
assert . True ( t , exists )
assert . NotEmpty ( t , commitURL )
// Call API to add status for commit
ctx := NewAPITestContext ( t , "user2" , "repo1" , auth_model . AccessTokenScopeRepo )
t . Run ( "CreateStatus" , doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CreateStatusOption {
State : api . CommitStatusSuccess ,
TargetURL : "http://test.ci/" ,
Description : "" ,
Context : "testci" ,
} ) )
t . Run ( "CreateStatus" , doAPICreateCommitStatus ( ctx , path . Base ( commitURL ) , api . CreateStatusOption {
State : api . CommitStatusSuccess ,
TargetURL : "http://test.ci/" ,
Description : "" ,
Context : "other_context" ,
} ) )
req = NewRequest ( t , "GET" , "/user2/repo1/commits/branch/master" )
resp = session . MakeRequest ( t , req , http . StatusOK )
doc = NewHTMLParser ( t , resp . Body )
// Check that the data-tippy="commit-statuses" (for trigger) and commit-status (svg) are present
sel := doc . doc . Find ( "#commits-table tbody tr td.message [data-tippy=\"commit-statuses\"] .commit-status" )
assert . Equal ( t , 1 , sel . Length ( ) )
}