-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show commit status icon in commits table #1688
Merged
appleboy
merged 8 commits into
go-gitea:master
from
lafriks-fork:status_display_commit_log
May 7, 2017
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ff1f20
Show commit status icon in commits table
lafriks 8bd7ffe
Add comments
lafriks d066ec8
Fix icons
lafriks d066d05
Few more places where commit table is displayed
lafriks f1a4bd4
Change integration test to use goquery for parsing html
lafriks 2cbf059
Add integration tests for commit table and status icons
lafriks 77092f9
Fix status to return lates status correctly on all databases
lafriks 05b845f
Rewrote lates commit status selects
lafriks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add integration tests for commit table and status icons
- Loading branch information
commit 2cbf059c9856e83d43b4e04c373b92208010bbb5
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"bytes" | ||
"net/http" | ||
"path" | ||
"testing" | ||
|
||
//"fmt" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRepoCommits(t *testing.T) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user2", "password") | ||
|
||
// Request repository commits page | ||
req, err := http.NewRequest("GET", "/user2/repo1/commits/master", nil) | ||
assert.NoError(t, err) | ||
resp := session.MakeRequest(t, req) | ||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode) | ||
|
||
doc, err := NewHtmlParser(resp.Body) | ||
assert.NoError(t, err) | ||
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href") | ||
assert.True(t, exists) | ||
assert.NotEmpty(t, commitURL) | ||
} | ||
|
||
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user2", "password") | ||
|
||
// Request repository commits page | ||
req, err := http.NewRequest("GET", "/user2/repo1/commits/master", nil) | ||
assert.NoError(t, err) | ||
resp := session.MakeRequest(t, req) | ||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode) | ||
|
||
doc, err := NewHtmlParser(resp.Body) | ||
assert.NoError(t, err) | ||
// 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 | ||
req, err = http.NewRequest("POST", "/api/v1/repos/user2/repo1/statuses/"+path.Base(commitURL), | ||
bytes.NewBufferString("{\"state\":\""+state+"\", \"target_url\": \"http://test.ci/\", \"description\": \"\", \"context\": \"testci\"}")) | ||
|
||
assert.NoError(t, err) | ||
req.Header.Add("Content-Type", "application/json") | ||
resp = session.MakeRequest(t, req) | ||
assert.EqualValues(t, http.StatusCreated, resp.HeaderCode) | ||
|
||
req, err = http.NewRequest("GET", "/user2/repo1/commits/master", nil) | ||
assert.NoError(t, err) | ||
resp = session.MakeRequest(t, req) | ||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode) | ||
|
||
doc, err = NewHtmlParser(resp.Body) | ||
assert.NoError(t, err) | ||
// Check if commit status is displayed in message column | ||
sel := doc.doc.Find("#commits-table tbody tr td.message i.commit-status") | ||
assert.Equal(t, sel.Length(), 1) | ||
for _, class := range classes { | ||
assert.True(t, sel.HasClass(class)) | ||
} | ||
} | ||
|
||
func TestRepoCommitsWithStatusPending(t *testing.T) { | ||
doTestRepoCommitWithStatus(t, "pending", "circle", "yellow") | ||
} | ||
|
||
func TestRepoCommitsWithStatusSuccess(t *testing.T) { | ||
doTestRepoCommitWithStatus(t, "success", "check", "green") | ||
} | ||
|
||
func TestRepoCommitsWithStatusError(t *testing.T) { | ||
doTestRepoCommitWithStatus(t, "error", "warning", "red") | ||
} | ||
|
||
func TestRepoCommitsWithStatusFailure(t *testing.T) { | ||
doTestRepoCommitWithStatus(t, "failure", "remove", "red") | ||
} | ||
|
||
func TestRepoCommitsWithStatusWarning(t *testing.T) { | ||
doTestRepoCommitWithStatus(t, "warning", "warning", "sign", "yellow") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused comment