-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Issue content should not be updated when closing with comment #2833
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ func TestNoLoginViewIssue(t *testing.T) { | |
MakeRequest(t, req, http.StatusOK) | ||
} | ||
|
||
func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) { | ||
func testNewIssue(t *testing.T, session *TestSession, user, repo, title, content string) string { | ||
|
||
req := NewRequest(t, "GET", path.Join(user, repo, "issues", "new")) | ||
resp := session.MakeRequest(t, req, http.StatusOK) | ||
|
@@ -116,17 +116,70 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) | |
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action") | ||
assert.True(t, exists, "The template has changed") | ||
req = NewRequestWithValues(t, "POST", link, map[string]string{ | ||
"_csrf": htmlDoc.GetCSRF(), | ||
"title": title, | ||
"_csrf": htmlDoc.GetCSRF(), | ||
"title": title, | ||
"content": content, | ||
}) | ||
resp = session.MakeRequest(t, req, http.StatusFound) | ||
|
||
issueURL := RedirectURL(t, resp) | ||
req = NewRequest(t, "GET", issueURL) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
|
||
htmlDoc = NewHTMLParser(t, resp.Body) | ||
val := htmlDoc.doc.Find("#issue-title").Text() | ||
assert.Equal(t, title, val) | ||
val = htmlDoc.doc.Find(".comment-list .comments .comment .render-content p").First().Text() | ||
assert.Equal(t, content, val) | ||
|
||
return issueURL | ||
} | ||
|
||
func testIssueAddComment(t *testing.T, session *TestSession, issueURL, content, status string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it's not obvious what values are valid for Could we instead do:
I think this will make it easier for future tests to reuse these helpers, and will make tests more readable. |
||
|
||
req := NewRequest(t, "GET", issueURL) | ||
resp := session.MakeRequest(t, req, http.StatusOK) | ||
|
||
htmlDoc := NewHTMLParser(t, resp.Body) | ||
link, exists := htmlDoc.doc.Find("#comment-form").Attr("action") | ||
assert.True(t, exists, "The template has changed") | ||
|
||
commentCount := htmlDoc.doc.Find(".comment-list .comments .comment .render-content").Length() | ||
|
||
req = NewRequestWithValues(t, "POST", link, map[string]string{ | ||
"_csrf": htmlDoc.GetCSRF(), | ||
"content": content, | ||
"status": status, | ||
}) | ||
resp = session.MakeRequest(t, req, http.StatusFound) | ||
|
||
req = NewRequest(t, "GET", RedirectURL(t, resp)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
|
||
htmlDoc = NewHTMLParser(t, resp.Body) | ||
|
||
val := htmlDoc.doc.Find(".comment-list .comments .comment .render-content p").Eq(commentCount).Text() | ||
assert.Equal(t, content, val) | ||
} | ||
|
||
func TestNewIssue(t *testing.T) { | ||
prepareTestEnv(t) | ||
session := loginUser(t, "user2") | ||
testNewIssue(t, session, "user2", "repo1", "Title") | ||
testNewIssue(t, session, "user2", "repo1", "Title", "Description") | ||
} | ||
|
||
func TestIssueCommentClose(t *testing.T) { | ||
prepareTestEnv(t) | ||
session := loginUser(t, "user2") | ||
issueURL := testNewIssue(t, session, "user2", "repo1", "Title", "Description") | ||
testIssueAddComment(t, session, issueURL, "Test comment 1", "") | ||
testIssueAddComment(t, session, issueURL, "Test comment 2", "") | ||
testIssueAddComment(t, session, issueURL, "Test comment 3", "close") | ||
|
||
// Validate that issue content has not been updated | ||
req := NewRequest(t, "GET", issueURL) | ||
resp := session.MakeRequest(t, req, http.StatusOK) | ||
htmlDoc := NewHTMLParser(t, resp.Body) | ||
val := htmlDoc.doc.Find(".comment-list .comments .comment .render-content p").First().Text() | ||
assert.Equal(t, "Description", val) | ||
} |
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.
nit: from the signature, it's not obvious what the function returns. Could we add a brief comment specifying that the created issue's URL is returned?