mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 19:29:02 +03:00
Improve testing
This commit is contained in:
parent
4437292622
commit
56a028ec96
1 changed files with 18 additions and 17 deletions
|
@ -4,6 +4,7 @@
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -281,8 +282,8 @@ func TestGetOpenStreetMapLink(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
testLocations := map[string]string{
|
testLocations := map[string]string{
|
||||||
"Αθήνα": "%ce%91%ce%b8%ce%ae%ce%bd%ce%b1",
|
"Αθήνα": "%ce%91%ce%b8%ce%ae%ce%bd%ce%b1",
|
||||||
" Αθήνα": "%20%20%ce%91%ce%b8%ce%ae%ce%bd%ce%b1",
|
" Αθήνα": "%20%20%ce%91%ce%b8%ce%ae%ce%bd%ce%b1",
|
||||||
"Barbarossabrunnen, Düsseldorf": "Barbarossabrunnen%2c%20D%c3%bcsseldorf",
|
"Barbarossabrunnen, Düsseldorf": "Barbarossabrunnen%2c%20D%c3%bcsseldorf",
|
||||||
"39.91025,116.40753": "39.91025%2c116.40753",
|
"39.91025,116.40753": "39.91025%2c116.40753",
|
||||||
// "நியூ யோர்க்": "%e0%ae%a8%e0%ae%bf%e0%ae%af%e0%af%82%20%e0%ae%af%e0%af%8b%e0%ae%b0%e0%af%8d%e0%ae%95%e0%af%8d",
|
// "நியூ யோர்க்": "%e0%ae%a8%e0%ae%bf%e0%ae%af%e0%af%82%20%e0%ae%af%e0%af%8b%e0%ae%b0%e0%af%8d%e0%ae%95%e0%af%8d",
|
||||||
|
@ -290,21 +291,21 @@ func TestGetOpenStreetMapLink(t *testing.T) {
|
||||||
|
|
||||||
session := loginUser(t, "user2")
|
session := loginUser(t, "user2")
|
||||||
for location, encodedLocation := range testLocations {
|
for location, encodedLocation := range testLocations {
|
||||||
t.Logf("Testing location %s", location)
|
t.Run(location, func(t *testing.T) {
|
||||||
req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{
|
req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{
|
||||||
"_csrf": GetCSRF(t, session, "/user/settings"),
|
"_csrf": GetCSRF(t, session, "/user/settings"),
|
||||||
"name": "user2",
|
"name": "user2",
|
||||||
"email": "user@example.com",
|
"email": "user@example.com",
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"location": location,
|
"location": location,
|
||||||
})
|
})
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
|
||||||
req = NewRequest(t, "GET", "/user2/")
|
req = NewRequest(t, "GET", "/user2/")
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
assert.Contains(t,
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
resp.Body.String(),
|
|
||||||
"<a href=\""+"https://www.openstreetmap.org/search?query="+encodedLocation+"\" rel=\"nofollow noreferrer\">",
|
htmlDoc.AssertElement(t, fmt.Sprintf("a[href='https://www.openstreetmap.org/search?query=%s']", encodedLocation), true)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue