From 64de4e02f9ed776bc751354d39fc652ea5c2ef19 Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Wed, 19 Jul 2023 21:29:19 +0200 Subject: [PATCH 01/18] [FEAT] Add OpenStreetMap URL to Location field in profile Not too important, but I think that it'd be a pretty neat touch. --- templates/shared/user/profile_big_avatar.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index 5a1e43b88e..2336b5b2f3 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -24,7 +24,7 @@
- +
From 2c94e6d56f6444946bcdff3f24776e4532903b8c Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 20 Jul 2023 13:33:24 +0200 Subject: [PATCH 03/18] Add test for OSM feature (doesn't work yet) --- tests/integration/user_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 3e4d967686..5ea62ec9b7 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -276,3 +276,35 @@ func TestListStopWatches(t *testing.T) { assert.Greater(t, apiWatches[0].Seconds, int64(0)) } } + +func TestGetOpenStreetMapLink(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + testLocations := map[string]string{ + "Αθήνα": "%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", + "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", + } + + session := loginUser(t, "user2") + for location, encodedLocation := range testLocations { + t.Logf("Testing location %s", location) + req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{ + "_csrf": GetCSRF(t, session, "/user/settings"), + "name": "user2", + "email": "user@example.com", + "language": "en-US", + "location": location, + }) + resp := session.MakeRequest(t, req, http.StatusSeeOther) + + req = NewRequest(t, "GET", "/user2/") + resp = session.MakeRequest(t, req, http.StatusOK) + assert.Contains(t, + resp.Body.String(), + "", + ) + } +} From 5731fbb4a4f800e1f38eba34a9db98913287928e Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 20 Jul 2023 15:30:22 +0200 Subject: [PATCH 04/18] Lint tests (sorry, I'm a bit tired) --- tests/integration/user_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 5ea62ec9b7..b70f3314b3 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -284,7 +284,7 @@ func TestGetOpenStreetMapLink(t *testing.T) { "Αθήνα": "%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", - "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", } @@ -304,7 +304,7 @@ func TestGetOpenStreetMapLink(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Body.String(), - "", + "", ) } } From 4437292622e689ae7afbada9bcc84186560c1cf9 Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 20 Jul 2023 15:52:14 +0200 Subject: [PATCH 05/18] It finally works, will add more tests later. --- tests/integration/user_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index b70f3314b3..ecdd2db284 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -282,9 +282,9 @@ func TestGetOpenStreetMapLink(t *testing.T) { testLocations := map[string]string{ "Αθήνα": "%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", - "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", } @@ -298,10 +298,10 @@ func TestGetOpenStreetMapLink(t *testing.T) { "language": "en-US", "location": location, }) - resp := session.MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusSeeOther) req = NewRequest(t, "GET", "/user2/") - resp = session.MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Body.String(), "", From 56a028ec96e232cfec32956f7c9908f6a059513d Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 20 Jul 2023 15:54:19 +0200 Subject: [PATCH 06/18] Improve testing --- tests/integration/user_test.go | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index ecdd2db284..2bec409023 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -4,6 +4,7 @@ package integration import ( + "fmt" "net/http" "testing" @@ -281,8 +282,8 @@ func TestGetOpenStreetMapLink(t *testing.T) { defer tests.PrepareTestEnv(t)() testLocations := map[string]string{ - "Αθήνα": "%ce%91%ce%b8%ce%ae%ce%bd%ce%b1", - " Αθήνα": "%20%20%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", "Barbarossabrunnen, Düsseldorf": "Barbarossabrunnen%2c%20D%c3%bcsseldorf", "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", @@ -290,21 +291,21 @@ func TestGetOpenStreetMapLink(t *testing.T) { session := loginUser(t, "user2") for location, encodedLocation := range testLocations { - t.Logf("Testing location %s", location) - req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{ - "_csrf": GetCSRF(t, session, "/user/settings"), - "name": "user2", - "email": "user@example.com", - "language": "en-US", - "location": location, - }) - session.MakeRequest(t, req, http.StatusSeeOther) + t.Run(location, func(t *testing.T) { + req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{ + "_csrf": GetCSRF(t, session, "/user/settings"), + "name": "user2", + "email": "user@example.com", + "language": "en-US", + "location": location, + }) + session.MakeRequest(t, req, http.StatusSeeOther) - req = NewRequest(t, "GET", "/user2/") - resp := session.MakeRequest(t, req, http.StatusOK) - assert.Contains(t, - resp.Body.String(), - "", - ) + req = NewRequest(t, "GET", "/user2/") + resp := session.MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + htmlDoc.AssertElement(t, fmt.Sprintf("a[href='https://www.openstreetmap.org/search?query=%s']", encodedLocation), true) + }) } } From 852317b46734ca5c929b4b12fb067c14e51d0f1b Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 20 Jul 2023 16:46:25 +0200 Subject: [PATCH 07/18] Introduce new button for OpenStreetMap URL --- templates/shared/user/profile_big_avatar.tmpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index 2336b5b2f3..9e83e3b2e0 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -24,7 +24,15 @@