loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request '[TESTS] pull review deletion (partial port of gitea#29888)' (#2796) from oliverpool/forgejo:port_29888 into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2796
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+61 -2
+8
models/fixtures/comment.yml
··· 75 75 content: "comment in private pository" 76 76 created_unix: 946684811 77 77 updated_unix: 946684811 78 + 79 + - 80 + id: 9 81 + type: 22 # review 82 + poster_id: 2 83 + issue_id: 2 # in repo_id 1 84 + review_id: 20 85 + created_unix: 946684810
+9
models/fixtures/review.yml
··· 170 170 content: "review request for user15" 171 171 updated_unix: 946684835 172 172 created_unix: 946684835 173 + 174 + - 175 + id: 20 176 + type: 22 177 + reviewer_id: 1 178 + issue_id: 2 179 + content: "Review Comment" 180 + updated_unix: 946684810 181 + created_unix: 946684810
+27
routers/web/repo/pull_review_test.go
··· 4 4 package repo 5 5 6 6 import ( 7 + "net/http" 7 8 "net/http/httptest" 8 9 "testing" 9 10 ··· 74 75 ctx.Data["ShowOutdatedComments"] = false 75 76 renderConversation(ctx, preparedComment, "timeline") 76 77 assert.Contains(t, resp.Body.String(), `<div id="code-comments-`) 78 + }) 79 + run("diff non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) { 80 + reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{ 81 + IssueID: 2, 82 + }) 83 + assert.NoError(t, err) 84 + for _, r := range reviews { 85 + assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r)) 86 + } 87 + ctx.Data["ShowOutdatedComments"] = true 88 + renderConversation(ctx, preparedComment, "diff") 89 + assert.Equal(t, http.StatusOK, resp.Code) 90 + assert.NotContains(t, resp.Body.String(), `status-page-500`) 91 + }) 92 + run("timeline non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) { 93 + reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{ 94 + IssueID: 2, 95 + }) 96 + assert.NoError(t, err) 97 + for _, r := range reviews { 98 + assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r)) 99 + } 100 + ctx.Data["ShowOutdatedComments"] = true 101 + renderConversation(ctx, preparedComment, "timeline") 102 + assert.Equal(t, http.StatusOK, resp.Code) 103 + assert.NotContains(t, resp.Body.String(), `status-page-500`) 77 104 }) 78 105 }
+17 -2
tests/integration/pull_review_test.go
··· 16 16 "code.gitea.io/gitea/models/unittest" 17 17 user_model "code.gitea.io/gitea/models/user" 18 18 "code.gitea.io/gitea/modules/git" 19 + "code.gitea.io/gitea/modules/test" 19 20 issue_service "code.gitea.io/gitea/services/issue" 20 21 repo_service "code.gitea.io/gitea/services/repository" 21 22 files_service "code.gitea.io/gitea/services/repository/files" ··· 30 31 session := loginUser(t, "user1") 31 32 32 33 req := NewRequest(t, "GET", "/pulls") 33 - session.MakeRequest(t, req, http.StatusOK) 34 + resp := session.MakeRequest(t, req, http.StatusOK) 35 + assert.True(t, test.IsNormalPageCompleted(resp.Body.String())) 34 36 35 37 req = NewRequest(t, "GET", "/user2/repo1/pulls/3") 36 - session.MakeRequest(t, req, http.StatusOK) 38 + resp = session.MakeRequest(t, req, http.StatusOK) 39 + assert.True(t, test.IsNormalPageCompleted(resp.Body.String())) 40 + 41 + // if some reviews are missing, the page shouldn't fail 42 + reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{ 43 + IssueID: 2, 44 + }) 45 + assert.NoError(t, err) 46 + for _, r := range reviews { 47 + assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r)) 48 + } 49 + req = NewRequest(t, "GET", "/user2/repo1/pulls/2") 50 + resp = session.MakeRequest(t, req, http.StatusOK) 51 + assert.True(t, test.IsNormalPageCompleted(resp.Body.String())) 37 52 } 38 53 39 54 func loadComment(t *testing.T, commentID string) *issues_model.Comment {