mirror of
https://github.com/go-gitea/gitea
synced 2025-07-12 21:47:19 +00:00
fix(issue): Replace stopwatch toggle with explicit start/stop actions (#34818)
This PR fixes a state de-synchronization bug with the issue stopwatch, it resolves the issue by replacing the ambiguous `/toggle` endpoint with two explicit endpoints: `/start` and `/stop`. - The "Start timer" button now exclusively calls the `/start` endpoint. - The "Stop timer" button now exclusively calls the `/stop` endpoint. This ensures the user's intent is clearly communicated to the server, eliminating the state inconsistency and fixing the bug. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@ -46,11 +46,11 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo
|
||||
AssertHTMLElement(t, htmlDoc, ".issue-add-time", canTrackTime)
|
||||
|
||||
issueLink := path.Join(user, repo, "issues", issue)
|
||||
req = NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "toggle"), map[string]string{
|
||||
reqStart := NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "start"), map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
if canTrackTime {
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
session.MakeRequest(t, reqStart, http.StatusOK)
|
||||
|
||||
req = NewRequest(t, "GET", issueLink)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
@ -65,10 +65,10 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo
|
||||
// Sleep for 1 second to not get wrong order for stopping timer
|
||||
time.Sleep(time.Second)
|
||||
|
||||
req = NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "toggle"), map[string]string{
|
||||
reqStop := NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "stop"), map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
session.MakeRequest(t, reqStop, http.StatusOK)
|
||||
|
||||
req = NewRequest(t, "GET", issueLink)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
@ -77,6 +77,6 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo
|
||||
events = htmlDoc.doc.Find(".event > span.text")
|
||||
assert.Contains(t, events.Last().Text(), "worked for ")
|
||||
} else {
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
session.MakeRequest(t, reqStart, http.StatusNotFound)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user