1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Frontend refactor, PascalCase to camelCase, remove unused code (#17365)

* Frontend refactor, PascalCase to camelCase, remove unused code

* fix
This commit is contained in:
wxiaoguang
2021-10-21 15:37:43 +08:00
committed by GitHub
parent 5879ab83b5
commit 2add8fe9be
42 changed files with 162 additions and 182 deletions

View File

@@ -9,7 +9,6 @@ import (
"net/url"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
"github.com/unknwon/i18n"
)
@@ -62,7 +61,7 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
}
req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": getCsrf(t, htmlDoc.doc),
"_csrf": htmlDoc.GetCSRF(),
})
session.MakeRequest(t, req, http.StatusOK)
@@ -73,9 +72,3 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
return NewHTMLParser(t, resp.Body), url.Query().Get("name")
}
func getCsrf(t *testing.T, doc *goquery.Document) string {
csrf, exists := doc.Find("meta[name=\"_csrf\"]").Attr("content")
assert.True(t, exists)
return csrf
}

View File

@@ -44,7 +44,7 @@ func (doc *HTMLDoc) Find(selector string) *goquery.Selection {
return doc.doc.Find(selector)
}
// GetCSRF for get CSRC token value from input
// GetCSRF for getting CSRF token value from input
func (doc *HTMLDoc) GetCSRF() string {
return doc.GetInputValueByName("_csrf")
}

View File

@@ -114,7 +114,7 @@ func testUIDeleteBranch(t *testing.T, session *TestSession, ownerName, repoName,
htmlDoc := NewHTMLParser(t, resp.Body)
req = NewRequestWithValues(t, "POST", relURL+"/delete", map[string]string{
"_csrf": getCsrf(t, htmlDoc.doc),
"_csrf": htmlDoc.GetCSRF(),
"name": branchName,
})
session.MakeRequest(t, req, http.StatusOK)
@@ -127,7 +127,7 @@ func testDeleteRepository(t *testing.T, session *TestSession, ownerName, repoNam
htmlDoc := NewHTMLParser(t, resp.Body)
req = NewRequestWithValues(t, "POST", relURL+"?action=delete", map[string]string{
"_csrf": getCsrf(t, htmlDoc.doc),
"_csrf": htmlDoc.GetCSRF(),
"repo_name": repoName,
})
session.MakeRequest(t, req, http.StatusFound)