Merge pull request '[v7.0/forgejo] [TESTS] pull review deletion (partial port of gitea#29888)' (#2992) from bp-v7.0/forgejo-6b85719 into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2992 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
This commit is contained in:
commit
0e2e21b584
|
@ -75,3 +75,11 @@
|
||||||
content: "comment in private pository"
|
content: "comment in private pository"
|
||||||
created_unix: 946684811
|
created_unix: 946684811
|
||||||
updated_unix: 946684811
|
updated_unix: 946684811
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 9
|
||||||
|
type: 22 # review
|
||||||
|
poster_id: 2
|
||||||
|
issue_id: 2 # in repo_id 1
|
||||||
|
review_id: 20
|
||||||
|
created_unix: 946684810
|
||||||
|
|
|
@ -170,3 +170,12 @@
|
||||||
content: "review request for user15"
|
content: "review request for user15"
|
||||||
updated_unix: 946684835
|
updated_unix: 946684835
|
||||||
created_unix: 946684835
|
created_unix: 946684835
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 20
|
||||||
|
type: 22
|
||||||
|
reviewer_id: 1
|
||||||
|
issue_id: 2
|
||||||
|
content: "Review Comment"
|
||||||
|
updated_unix: 946684810
|
||||||
|
created_unix: 946684810
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -75,4 +76,30 @@ func TestRenderConversation(t *testing.T) {
|
||||||
renderConversation(ctx, preparedComment, "timeline")
|
renderConversation(ctx, preparedComment, "timeline")
|
||||||
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
|
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
|
||||||
})
|
})
|
||||||
|
run("diff non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
ctx.Data["ShowOutdatedComments"] = true
|
||||||
|
renderConversation(ctx, preparedComment, "diff")
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
assert.NotContains(t, resp.Body.String(), `status-page-500`)
|
||||||
|
})
|
||||||
|
run("timeline non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
ctx.Data["ShowOutdatedComments"] = true
|
||||||
|
renderConversation(ctx, preparedComment, "timeline")
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
assert.NotContains(t, resp.Body.String(), `status-page-500`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
repo_service "code.gitea.io/gitea/services/repository"
|
repo_service "code.gitea.io/gitea/services/repository"
|
||||||
files_service "code.gitea.io/gitea/services/repository/files"
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
|
@ -30,10 +31,24 @@ func TestPullView_ReviewerMissed(t *testing.T) {
|
||||||
session := loginUser(t, "user1")
|
session := loginUser(t, "user1")
|
||||||
|
|
||||||
req := NewRequest(t, "GET", "/pulls")
|
req := NewRequest(t, "GET", "/pulls")
|
||||||
session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
|
|
||||||
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
|
||||||
session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
|
|
||||||
|
// if some reviews are missing, the page shouldn't fail
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/2")
|
||||||
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadComment(t *testing.T, commentID string) *issues_model.Comment {
|
func loadComment(t *testing.T, commentID string) *issues_model.Comment {
|
||||||
|
|
Loading…
Reference in a new issue