umap-project 3.3.5__py3-none-any.whl → 3.4.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (218) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/cs_CZ/LC_MESSAGES/django.po +43 -33
  4. umap/locale/da/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/da/LC_MESSAGES/django.po +43 -33
  6. umap/locale/de/LC_MESSAGES/django.mo +0 -0
  7. umap/locale/de/LC_MESSAGES/django.po +35 -29
  8. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  9. umap/locale/el/LC_MESSAGES/django.po +35 -29
  10. umap/locale/en/LC_MESSAGES/django.po +34 -28
  11. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  12. umap/locale/es/LC_MESSAGES/django.po +43 -33
  13. umap/locale/et/LC_MESSAGES/django.mo +0 -0
  14. umap/locale/et/LC_MESSAGES/django.po +58 -54
  15. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  16. umap/locale/eu/LC_MESSAGES/django.po +43 -33
  17. umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
  18. umap/locale/fa_IR/LC_MESSAGES/django.po +43 -33
  19. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  20. umap/locale/fr/LC_MESSAGES/django.po +36 -30
  21. umap/locale/gl/LC_MESSAGES/django.mo +0 -0
  22. umap/locale/gl/LC_MESSAGES/django.po +43 -33
  23. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  24. umap/locale/hu/LC_MESSAGES/django.po +35 -29
  25. umap/locale/is/LC_MESSAGES/django.mo +0 -0
  26. umap/locale/is/LC_MESSAGES/django.po +43 -33
  27. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  28. umap/locale/it/LC_MESSAGES/django.po +43 -33
  29. umap/locale/nl/LC_MESSAGES/django.mo +0 -0
  30. umap/locale/nl/LC_MESSAGES/django.po +35 -29
  31. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  32. umap/locale/pl/LC_MESSAGES/django.po +43 -33
  33. umap/locale/pt/LC_MESSAGES/django.mo +0 -0
  34. umap/locale/pt/LC_MESSAGES/django.po +43 -33
  35. umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
  36. umap/locale/th_TH/LC_MESSAGES/django.po +310 -109
  37. umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  38. umap/locale/zh_TW/LC_MESSAGES/django.po +80 -70
  39. umap/management/commands/switch_user.py +2 -2
  40. umap/static/umap/base.css +89 -32
  41. umap/static/umap/content.css +129 -33
  42. umap/static/umap/css/bar.css +82 -20
  43. umap/static/umap/css/browser.css +163 -0
  44. umap/static/umap/css/contextmenu.css +15 -0
  45. umap/static/umap/css/dialog.css +36 -16
  46. umap/static/umap/css/form.css +122 -32
  47. umap/static/umap/css/icon.css +46 -3
  48. umap/static/umap/css/panel.css +7 -3
  49. umap/static/umap/css/popup.css +34 -8
  50. umap/static/umap/css/tooltip.css +8 -4
  51. umap/static/umap/img/16-white.svg +26 -8
  52. umap/static/umap/img/16.svg +1 -1
  53. umap/static/umap/img/source/16-white.svg +36 -18
  54. umap/static/umap/img/source/16.svg +1 -1
  55. umap/static/umap/js/components/alerts/alert.css +69 -31
  56. umap/static/umap/js/components/alerts/alert.js +20 -2
  57. umap/static/umap/js/modules/browser.js +64 -56
  58. umap/static/umap/js/modules/caption.js +10 -7
  59. umap/static/umap/js/modules/data/features.js +82 -59
  60. umap/static/umap/js/modules/data/layer.js +75 -166
  61. umap/static/umap/js/modules/domutils.js +109 -0
  62. umap/static/umap/js/modules/filters.js +807 -0
  63. umap/static/umap/js/modules/form/builder.js +8 -5
  64. umap/static/umap/js/modules/form/fields.js +110 -220
  65. umap/static/umap/js/modules/formatter.js +24 -1
  66. umap/static/umap/js/modules/help.js +3 -2
  67. umap/static/umap/js/modules/importers/opendata.js +5 -0
  68. umap/static/umap/js/modules/importers/openrouteservice.js +6 -1
  69. umap/static/umap/js/modules/managers.js +265 -0
  70. umap/static/umap/js/modules/permissions.js +35 -31
  71. umap/static/umap/js/modules/rendering/controls.js +7 -7
  72. umap/static/umap/js/modules/rendering/icon.js +3 -8
  73. umap/static/umap/js/modules/rendering/layers/base.js +1 -1
  74. umap/static/umap/js/modules/rendering/layers/classified.js +17 -10
  75. umap/static/umap/js/modules/rendering/layers/cluster.js +2 -2
  76. umap/static/umap/js/modules/rendering/template.js +44 -8
  77. umap/static/umap/js/modules/rendering/ui.js +29 -23
  78. umap/static/umap/js/modules/rules.js +4 -3
  79. umap/static/umap/js/modules/schema.js +3 -6
  80. umap/static/umap/js/modules/share.js +4 -3
  81. umap/static/umap/js/modules/tableeditor.js +50 -38
  82. umap/static/umap/js/modules/templates.js +2 -3
  83. umap/static/umap/js/modules/ui/bar.js +42 -18
  84. umap/static/umap/js/modules/ui/dialog.js +33 -31
  85. umap/static/umap/js/modules/ui/panel.js +21 -7
  86. umap/static/umap/js/modules/ui/tooltip.js +6 -5
  87. umap/static/umap/js/modules/umap.js +155 -46
  88. umap/static/umap/js/modules/utils.js +23 -1
  89. umap/static/umap/js/umap.core.js +1 -110
  90. umap/static/umap/locale/am_ET.js +40 -14
  91. umap/static/umap/locale/am_ET.json +40 -14
  92. umap/static/umap/locale/ar.js +40 -14
  93. umap/static/umap/locale/ar.json +40 -14
  94. umap/static/umap/locale/ast.js +40 -14
  95. umap/static/umap/locale/ast.json +40 -14
  96. umap/static/umap/locale/bg.js +40 -14
  97. umap/static/umap/locale/bg.json +40 -14
  98. umap/static/umap/locale/br.js +47 -21
  99. umap/static/umap/locale/br.json +47 -21
  100. umap/static/umap/locale/ca.js +40 -14
  101. umap/static/umap/locale/ca.json +40 -14
  102. umap/static/umap/locale/cs_CZ.js +40 -14
  103. umap/static/umap/locale/cs_CZ.json +40 -14
  104. umap/static/umap/locale/da.js +40 -14
  105. umap/static/umap/locale/da.json +40 -14
  106. umap/static/umap/locale/de.js +39 -13
  107. umap/static/umap/locale/de.json +39 -13
  108. umap/static/umap/locale/el.js +40 -14
  109. umap/static/umap/locale/el.json +40 -14
  110. umap/static/umap/locale/en.js +39 -13
  111. umap/static/umap/locale/en.json +39 -13
  112. umap/static/umap/locale/en_US.json +40 -14
  113. umap/static/umap/locale/es.js +40 -14
  114. umap/static/umap/locale/es.json +40 -14
  115. umap/static/umap/locale/et.js +79 -53
  116. umap/static/umap/locale/et.json +79 -53
  117. umap/static/umap/locale/eu.js +72 -46
  118. umap/static/umap/locale/eu.json +72 -46
  119. umap/static/umap/locale/fa_IR.js +40 -14
  120. umap/static/umap/locale/fa_IR.json +40 -14
  121. umap/static/umap/locale/fi.js +40 -14
  122. umap/static/umap/locale/fi.json +40 -14
  123. umap/static/umap/locale/fr.js +39 -13
  124. umap/static/umap/locale/fr.json +39 -13
  125. umap/static/umap/locale/gl.js +40 -14
  126. umap/static/umap/locale/gl.json +40 -14
  127. umap/static/umap/locale/he.js +40 -14
  128. umap/static/umap/locale/he.json +40 -14
  129. umap/static/umap/locale/hr.js +40 -14
  130. umap/static/umap/locale/hr.json +40 -14
  131. umap/static/umap/locale/hu.js +40 -14
  132. umap/static/umap/locale/hu.json +40 -14
  133. umap/static/umap/locale/id.js +40 -14
  134. umap/static/umap/locale/id.json +40 -14
  135. umap/static/umap/locale/is.js +40 -14
  136. umap/static/umap/locale/is.json +40 -14
  137. umap/static/umap/locale/it.js +40 -14
  138. umap/static/umap/locale/it.json +40 -14
  139. umap/static/umap/locale/ja.js +40 -14
  140. umap/static/umap/locale/ja.json +40 -14
  141. umap/static/umap/locale/ko.js +40 -14
  142. umap/static/umap/locale/ko.json +40 -14
  143. umap/static/umap/locale/lt.js +40 -14
  144. umap/static/umap/locale/lt.json +40 -14
  145. umap/static/umap/locale/ms.js +40 -14
  146. umap/static/umap/locale/ms.json +40 -14
  147. umap/static/umap/locale/nl.js +40 -14
  148. umap/static/umap/locale/nl.json +40 -14
  149. umap/static/umap/locale/no.js +40 -14
  150. umap/static/umap/locale/no.json +40 -14
  151. umap/static/umap/locale/pl.js +40 -14
  152. umap/static/umap/locale/pl.json +40 -14
  153. umap/static/umap/locale/pl_PL.json +40 -14
  154. umap/static/umap/locale/pt.js +40 -14
  155. umap/static/umap/locale/pt.json +40 -14
  156. umap/static/umap/locale/pt_BR.js +40 -14
  157. umap/static/umap/locale/pt_BR.json +40 -14
  158. umap/static/umap/locale/pt_PT.js +40 -14
  159. umap/static/umap/locale/pt_PT.json +40 -14
  160. umap/static/umap/locale/ro.js +40 -14
  161. umap/static/umap/locale/ro.json +40 -14
  162. umap/static/umap/locale/ru.js +40 -14
  163. umap/static/umap/locale/ru.json +40 -14
  164. umap/static/umap/locale/sk_SK.js +40 -14
  165. umap/static/umap/locale/sk_SK.json +40 -14
  166. umap/static/umap/locale/sl.js +40 -14
  167. umap/static/umap/locale/sl.json +40 -14
  168. umap/static/umap/locale/sr.js +40 -14
  169. umap/static/umap/locale/sr.json +40 -14
  170. umap/static/umap/locale/sv.js +40 -14
  171. umap/static/umap/locale/sv.json +40 -14
  172. umap/static/umap/locale/th_TH.js +40 -14
  173. umap/static/umap/locale/th_TH.json +40 -14
  174. umap/static/umap/locale/tr.js +40 -14
  175. umap/static/umap/locale/tr.json +40 -14
  176. umap/static/umap/locale/uk_UA.js +40 -14
  177. umap/static/umap/locale/uk_UA.json +40 -14
  178. umap/static/umap/locale/vi.js +40 -14
  179. umap/static/umap/locale/vi.json +40 -14
  180. umap/static/umap/locale/vi_VN.json +40 -14
  181. umap/static/umap/locale/zh.js +40 -14
  182. umap/static/umap/locale/zh.json +40 -14
  183. umap/static/umap/locale/zh_CN.json +40 -14
  184. umap/static/umap/locale/zh_TW.Big5.json +40 -14
  185. umap/static/umap/locale/zh_TW.js +40 -14
  186. umap/static/umap/locale/zh_TW.json +40 -14
  187. umap/static/umap/map.css +60 -223
  188. umap/static/umap/unittests/utils.js +18 -0
  189. umap/static/umap/vars.css +23 -5
  190. umap/templates/umap/components/alerts/alert.html +32 -29
  191. umap/templates/umap/css.html +2 -1
  192. umap/templates/umap/login_popup_end.html +18 -9
  193. umap/templates/umap/user_map_table.html +7 -2
  194. umap/tests/integration/conftest.py +2 -6
  195. umap/tests/integration/test_anonymous_owned_map.py +89 -36
  196. umap/tests/integration/test_basics.py +25 -1
  197. umap/tests/integration/test_browser.py +37 -0
  198. umap/tests/integration/test_datalayer.py +9 -16
  199. umap/tests/integration/test_draw_polygon.py +2 -0
  200. umap/tests/integration/test_edit_marker.py +1 -1
  201. umap/tests/integration/test_export_map.py +19 -0
  202. umap/tests/integration/test_fields.py +522 -0
  203. umap/tests/integration/test_filters.py +617 -0
  204. umap/tests/integration/test_import.py +15 -42
  205. umap/tests/integration/test_remote_data.py +60 -4
  206. umap/tests/integration/test_share.py +4 -4
  207. umap/tests/integration/test_tableeditor.py +31 -7
  208. umap/tests/integration/test_websocket_sync.py +3 -1
  209. umap/tests/test_dashboard.py +10 -0
  210. umap/urls.py +1 -0
  211. umap/views.py +5 -0
  212. {umap_project-3.3.5.dist-info → umap_project-3.4.0b0.dist-info}/METADATA +12 -12
  213. {umap_project-3.3.5.dist-info → umap_project-3.4.0b0.dist-info}/RECORD +216 -213
  214. umap/static/umap/js/modules/facets.js +0 -164
  215. umap/tests/integration/test_facets_browser.py +0 -279
  216. {umap_project-3.3.5.dist-info → umap_project-3.4.0b0.dist-info}/WHEEL +0 -0
  217. {umap_project-3.3.5.dist-info → umap_project-3.4.0b0.dist-info}/entry_points.txt +0 -0
  218. {umap_project-3.3.5.dist-info → umap_project-3.4.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -18,25 +18,24 @@ def owner_session(anonymap, context, live_server):
18
18
  key, value = anonymap.signed_cookie_elements
19
19
  signed = get_cookie_signer(salt=key).sign(value)
20
20
  context.add_cookies([{"name": key, "value": signed, "url": live_server.url}])
21
- return context.new_page()
22
21
 
23
22
 
24
- def test_map_load_with_owner(anonymap, live_server, owner_session):
25
- owner_session.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
26
- map_el = owner_session.locator("#map")
23
+ def test_map_load_with_owner(anonymap, live_server, owner_session, page):
24
+ page.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
25
+ map_el = page.locator("#map")
27
26
  expect(map_el).to_be_visible()
28
- enable = owner_session.get_by_role("button", name="Edit")
27
+ enable = page.get_by_role("button", name="Edit")
29
28
  expect(enable).to_be_visible()
30
29
  enable.click()
31
- disable = owner_session.get_by_role("button", name="View")
30
+ disable = page.get_by_role("button", name="View")
32
31
  expect(disable).to_be_visible()
33
- save = owner_session.get_by_role("button", name="Save")
32
+ save = page.get_by_role("button", name="Save")
34
33
  expect(save).to_be_visible()
35
- add_marker = owner_session.get_by_title("Draw a marker")
34
+ add_marker = page.get_by_title("Draw a marker")
36
35
  expect(add_marker).to_be_visible()
37
- edit_settings = owner_session.get_by_title("Map advanced properties")
36
+ edit_settings = page.get_by_title("Map advanced properties")
38
37
  expect(edit_settings).to_be_visible()
39
- edit_permissions = owner_session.get_by_title("Update permissions and editors")
38
+ edit_permissions = page.get_by_title("Update permissions and editors")
40
39
  expect(edit_permissions).to_be_visible()
41
40
 
42
41
 
@@ -71,35 +70,31 @@ def test_map_load_with_anonymous_but_editable_layer(
71
70
  expect(edit_permissions).to_be_hidden()
72
71
 
73
72
 
74
- def test_owner_permissions_form(map, datalayer, live_server, owner_session):
75
- owner_session.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
76
- edit_permissions = owner_session.get_by_title("Update permissions and editors")
73
+ def test_owner_permissions_form(map, datalayer, live_server, owner_session, page):
74
+ page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
75
+ edit_permissions = page.get_by_title("Update permissions and editors")
77
76
  expect(edit_permissions).to_be_visible()
78
77
  edit_permissions.click()
79
- owner_field = owner_session.locator(".umap-field-owner")
78
+ owner_field = page.locator(".umap-field-owner")
80
79
  expect(owner_field).to_be_hidden()
81
- editors_field = owner_session.locator(".umap-field-editors input")
80
+ editors_field = page.locator(".umap-field-editors input")
82
81
  expect(editors_field).to_be_hidden()
83
- datalayer_label = owner_session.get_by_text('Who can edit "test datalayer"')
82
+ datalayer_label = page.get_by_text('Who can edit "test datalayer"')
84
83
  expect(datalayer_label).to_be_visible()
85
- options = owner_session.locator(
86
- ".datalayer-permissions select[name='edit_status'] option"
87
- )
84
+ options = page.locator(".datalayer-permissions select[name='edit_status'] option")
88
85
  expect(options).to_have_count(3)
89
- option = owner_session.locator(
86
+ option = page.locator(
90
87
  ".datalayer-permissions select[name='edit_status'] option:checked"
91
88
  )
92
89
  expect(option).to_have_text("Inherit")
93
- expect(owner_session.locator(".umap-field-share_status select")).to_be_visible()
90
+ expect(page.locator(".umap-field-share_status select")).to_be_visible()
94
91
  options = [
95
92
  int(option.get_attribute("value"))
96
- for option in owner_session.locator(
97
- ".umap-field-share_status select option"
98
- ).all()
93
+ for option in page.locator(".umap-field-share_status select option").all()
99
94
  ]
100
95
  assert options == [Map.DRAFT, Map.PUBLIC]
101
96
  # This field should not be present in anonymous maps
102
- expect(owner_session.locator(".umap-field-owner")).to_be_hidden()
97
+ expect(page.locator(".umap-field-owner")).to_be_hidden()
103
98
 
104
99
 
105
100
  def test_anonymous_can_add_marker_on_editable_layer(
@@ -180,7 +175,7 @@ def test_alert_message_after_create(
180
175
  new_map = Map.objects.last()
181
176
  expect(alert).to_be_visible()
182
177
  expect(
183
- alert.get_by_text("Your map has been created with an anonymous account!")
178
+ alert.get_by_text("Hey, you created a map without an account!")
184
179
  ).to_be_visible()
185
180
  expect(alert.get_by_role("button", name="Copy")).to_be_visible()
186
181
  expect(alert.get_by_role("button", name="Send me the link")).to_be_visible()
@@ -224,22 +219,22 @@ def test_alert_message_after_create_show_link_even_without_mail(
224
219
  alert = page.locator('umap-alert-creation div[role="dialog"]')
225
220
  expect(alert).to_be_visible()
226
221
  expect(
227
- alert.get_by_text("Your map has been created with an anonymous account!")
222
+ alert.get_by_text("Hey, you created a map without an account!")
228
223
  ).to_be_visible()
229
224
  expect(alert.get_by_role("button", name="Copy")).to_be_visible()
230
225
  expect(alert.get_by_role("button", name="Send me the link")).to_be_hidden()
231
226
 
232
227
 
233
- def test_anonymous_owner_can_delete_the_map(anonymap, live_server, owner_session):
228
+ def test_anonymous_owner_can_delete_the_map(anonymap, live_server, owner_session, page):
234
229
  assert Map.objects.count() == 1
235
- owner_session.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
236
- owner_session.get_by_role("button", name="Edit").click()
237
- owner_session.get_by_role("button", name="Map advanced properties").click()
238
- owner_session.get_by_text("Advanced actions").click()
239
- expect(owner_session.get_by_role("button", name="Delete")).to_be_visible()
240
- owner_session.get_by_role("button", name="Delete").click()
241
- with owner_session.expect_response(re.compile(r".*/update/delete/.*")):
242
- owner_session.get_by_role("button", name="OK").click()
230
+ page.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
231
+ page.get_by_role("button", name="Edit").click()
232
+ page.get_by_role("button", name="Map advanced properties").click()
233
+ page.get_by_text("Advanced actions").click()
234
+ expect(page.get_by_role("button", name="Delete")).to_be_visible()
235
+ page.get_by_role("button", name="Delete").click()
236
+ with page.expect_response(re.compile(r".*/update/delete/.*")):
237
+ page.get_by_role("button", name="OK").click()
243
238
  assert Map.objects.get(pk=anonymap.pk).share_status == Map.DELETED
244
239
 
245
240
 
@@ -251,3 +246,61 @@ def test_non_owner_cannot_see_delete_button(anonymap, live_server, page):
251
246
  page.get_by_role("button", name="Map advanced properties").click()
252
247
  page.get_by_text("Advanced actions").click()
253
248
  expect(page.get_by_role("button", name="Delete")).to_be_hidden()
249
+
250
+
251
+ def test_logged_in_user_should_have_a_message_to_attach_map(
252
+ anonymap, live_server, login, user, page, owner_session
253
+ ):
254
+ page.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
255
+ page.get_by_role("button", name="Edit").click()
256
+ expect(
257
+ page.get_by_text(
258
+ "This map is anonymous, do you want to attach it to your account?"
259
+ )
260
+ ).to_be_hidden()
261
+
262
+ page = login(user)
263
+ page.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
264
+ page.get_by_role("button", name="Edit").click()
265
+ expect(
266
+ page.get_by_text(
267
+ "This map is anonymous, do you want to attach it to your account?"
268
+ )
269
+ ).to_be_visible()
270
+ with page.expect_response(re.compile(r".*/update/owner/.*")):
271
+ page.get_by_role("button", name="OK").click()
272
+ saved = Map.objects.get(pk=anonymap.pk)
273
+ assert saved.owner
274
+
275
+
276
+ def test_can_attach_map_after_save(
277
+ live_server, user, page, tilelayer, context, settings
278
+ ):
279
+ settings.ENABLE_ACCOUNT_LOGIN = True
280
+ page.goto(f"{live_server.url}/en/map/new")
281
+ expect(page.get_by_role("button", name="Anonymous")).to_be_visible()
282
+ expect(page.get_by_role("button", name="Visibility: Draft")).to_have_class(
283
+ re.compile(r".*anonymous.*")
284
+ )
285
+ assert not Map.objects.count()
286
+ with page.expect_response(re.compile(r".*/map/create/")):
287
+ page.get_by_role("button", name="Save draft", exact=True).click()
288
+ assert Map.objects.count() == 1
289
+ saved = Map.objects.last()
290
+ assert not saved.owner
291
+ with context.expect_page() as login_page_info:
292
+ page.get_by_role("link", name="log in").click()
293
+ login_page = login_page_info.value
294
+ expect(login_page).to_have_title("Login - Online map creator")
295
+ login_page.get_by_placeholder("Username").fill(user.username)
296
+ login_page.get_by_placeholder("Password").fill("123123")
297
+ with page.expect_response(re.compile(r".*/update/owner/")):
298
+ login_page.locator('#login_form input[type="submit"]').click()
299
+ expect(page.get_by_text("Map has been attached to your account")).to_be_visible()
300
+ saved = Map.objects.last()
301
+ assert saved.owner == user
302
+ expect(page.get_by_role("button", name="Anonymous")).to_be_hidden()
303
+ expect(page.get_by_role("button", name=user.username)).to_be_visible()
304
+ expect(page.get_by_role("button", name="Visibility: Draft")).not_to_have_class(
305
+ re.compile(r".*anonymous.*")
306
+ )
@@ -79,7 +79,9 @@ def test_cannot_put_script_tag_in_datalayer_name_or_description(
79
79
  expect(page.get_by_text("before after")).to_be_visible()
80
80
 
81
81
 
82
- def test_login_from_map_page(live_server, page, tilelayer, settings, user, context):
82
+ def test_login_from_map_page_after_save(
83
+ live_server, page, tilelayer, settings, user, context
84
+ ):
83
85
  settings.ENABLE_ACCOUNT_LOGIN = True
84
86
  assert Map.objects.count() == 0
85
87
  page.goto(f"{live_server.url}/en/map/new/")
@@ -102,3 +104,25 @@ def test_login_from_map_page(live_server, page, tilelayer, settings, user, conte
102
104
  assert Map.objects.count() == 1
103
105
  # Use name should now appear on the header toolbar
104
106
  expect(page.get_by_role("button", name="Joe")).to_be_visible()
107
+
108
+
109
+ def test_login_from_unsaved_map_page(
110
+ live_server, page, tilelayer, settings, user, context
111
+ ):
112
+ settings.ENABLE_ACCOUNT_LOGIN = True
113
+ assert Map.objects.count() == 0
114
+ page.goto(f"{live_server.url}/en/map/new/")
115
+ page.locator('[data-ref="user"]').click()
116
+ with context.expect_page() as login_page_info:
117
+ page.get_by_role("button", name="Login").click()
118
+ login_page = login_page_info.value
119
+ expect(login_page).to_have_title("Login - Online map creator")
120
+ login_page.get_by_placeholder("Username").fill(user.username)
121
+ login_page.get_by_placeholder("Password").fill("123123")
122
+ login_page.locator('#login_form input[type="submit"]').click()
123
+ # Login page should be closed
124
+ page.wait_for_timeout(500) # Seems needed from time to time…
125
+ assert len(context.pages) == 1
126
+ # Save should have proceed
127
+ # Use name should now appear on the header toolbar
128
+ expect(page.get_by_role("button", name="Joe")).to_be_visible()
@@ -353,6 +353,43 @@ def test_should_redraw_list_on_feature_delete(live_server, openmap, page, bootst
353
353
  expect(buttons).to_have_count(3)
354
354
 
355
355
 
356
+ def test_should_change_feature_title_and_color_on_edit(
357
+ live_server, openmap, page, bootstrap
358
+ ):
359
+ page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit#2/19/-2")
360
+ expect(page.locator(".umap-browser .feature.marker")).to_contain_text(
361
+ "one point in france"
362
+ )
363
+ page.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
364
+ page.locator('input[name="name"]').fill("changed name")
365
+ expect(page.locator(".umap-browser .feature.marker")).to_contain_text(
366
+ "changed name"
367
+ )
368
+
369
+ # Change color
370
+ expect(
371
+ page.get_by_role("listitem").filter(has_text="changed name").locator("i")
372
+ ).to_have_css("background-color", "rgb(0, 0, 139)")
373
+ page.get_by_role("heading", name="Shape properties").click()
374
+ page.locator(".umap-field-color").get_by_role("button", name="define").first.click()
375
+ page.get_by_title("Crimson").click()
376
+ expect(
377
+ page.get_by_role("listitem").filter(has_text="changed name").locator("i")
378
+ ).to_have_css("background-color", "rgb(220, 20, 60)")
379
+
380
+ # Undo color
381
+ page.locator(".edit-undo").click()
382
+ expect(
383
+ page.get_by_role("listitem").filter(has_text="changed name").locator("i")
384
+ ).to_have_css("background-color", "rgb(0, 0, 139)")
385
+
386
+ # Undo title change
387
+ page.locator(".edit-undo").click()
388
+ expect(page.locator(".umap-browser .feature.marker")).to_contain_text(
389
+ "one point in france"
390
+ )
391
+
392
+
356
393
  def test_should_show_header_for_display_on_load_false(
357
394
  live_server, page, bootstrap, map, datalayer
358
395
  ):
@@ -1,8 +1,6 @@
1
- import json
2
1
  import re
3
2
 
4
3
  import pytest
5
- from django.core.files.base import ContentFile
6
4
  from playwright.sync_api import expect
7
5
 
8
6
  from ..base import DataLayerFactory
@@ -10,17 +8,9 @@ from ..base import DataLayerFactory
10
8
  pytestmark = pytest.mark.django_db
11
9
 
12
10
 
13
- def set_options(datalayer, **options):
14
- # For now we need to change both the DB and the FS…
15
- datalayer.settings.update(options)
16
- data = json.load(datalayer.geojson.file)
17
- data["_umap_options"].update(**options)
18
- datalayer.geojson = ContentFile(json.dumps(data), "foo.json")
19
- datalayer.save()
20
-
21
-
22
11
  def test_honour_displayOnLoad_false(map, live_server, datalayer, page):
23
- set_options(datalayer, displayOnLoad=False)
12
+ datalayer.settings.update(displayOnLoad=False)
13
+ datalayer.save()
24
14
  page.goto(f"{live_server.url}{map.get_absolute_url()}?onLoadPanel=datalayers")
25
15
  expect(page.locator(".leaflet-marker-icon")).to_be_hidden()
26
16
  layers = page.locator(".umap-browser .datalayer")
@@ -30,14 +20,17 @@ def test_honour_displayOnLoad_false(map, live_server, datalayer, page):
30
20
  expect(layers_off).to_have_count(1)
31
21
  page.get_by_role("button", name="Open browser").click()
32
22
  page.get_by_label("Zoom in").click()
23
+ page.wait_for_timeout(300)
33
24
  expect(markers).to_be_hidden()
34
- page.get_by_title("Show/hide layer").click()
25
+ with page.expect_response(re.compile(rf".*/datalayer/{map.pk}/{datalayer.pk}/.*")):
26
+ page.get_by_title("Show/hide layer").click()
35
27
  expect(layers_off).to_have_count(0)
36
28
  expect(markers).to_be_visible()
37
29
 
38
30
 
39
31
  def test_should_honour_fromZoom(live_server, map, datalayer, page):
40
- set_options(datalayer, displayOnLoad=True, fromZoom=6)
32
+ datalayer.settings.update(displayOnLoad=True, fromZoom=6)
33
+ datalayer.save()
41
34
  page.goto(f"{live_server.url}{map.get_absolute_url()}#5/48.55/14.68")
42
35
  markers = page.locator(".leaflet-marker-icon")
43
36
  expect(markers).to_be_hidden()
@@ -55,7 +48,8 @@ def test_should_honour_fromZoom(live_server, map, datalayer, page):
55
48
 
56
49
 
57
50
  def test_should_honour_toZoom(live_server, map, datalayer, page, new_page):
58
- set_options(datalayer, displayOnLoad=True, toZoom=6)
51
+ datalayer.settings.update(displayOnLoad=True, toZoom=6)
52
+ datalayer.save()
59
53
  # Loading at zoom 7 should not show the marker
60
54
  page.goto(f"{live_server.url}{map.get_absolute_url()}#7/48.55/14.68")
61
55
  markers = page.locator(".leaflet-marker-icon")
@@ -123,7 +117,6 @@ def test_datalayers_in_query_string(live_server, datalayer, map, page):
123
117
  map.settings["properties"]["onLoadPanel"] = "datalayers"
124
118
  map.save()
125
119
  with_old_id = DataLayerFactory(old_id=134, map=map, name="with old id")
126
- set_options(with_old_id, name="with old id")
127
120
  visible = page.locator(".umap-browser .datalayer:not(.off) .datalayer-name")
128
121
  hidden = page.locator(".umap-browser .datalayer.off .datalayer-name")
129
122
  page.goto(f"{live_server.url}{map.get_absolute_url()}")
@@ -426,6 +426,8 @@ def test_can_draw_a_polygon_and_invert_it(live_server, page, tilelayer, settings
426
426
  page.get_by_text("Advanced properties").click()
427
427
  page.get_by_text("Display the polygon inverted").click()
428
428
  data = save_and_get_json(page)
429
+ # Close save message
430
+ page.get_by_role("dialog").get_by_role("button", name="Close").click()
429
431
  assert len(data["features"]) == 1
430
432
  assert data["features"][0]["geometry"]["type"] == "Polygon"
431
433
  assert data["features"][0]["geometry"]["coordinates"] == [
@@ -137,6 +137,6 @@ def test_add_property_from_feature_properties_panel(
137
137
  page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
138
138
  page.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
139
139
  page.get_by_role("button", name="Add a new field").click()
140
- page.locator('input[name="prompt"]').fill("newprop")
140
+ page.locator('input[name="key"]').fill("newprop")
141
141
  page.get_by_role("button", name="OK").click()
142
142
  expect(page.locator(".panel.right").get_by_text("newprop")).to_be_visible()
@@ -215,6 +215,25 @@ test two,53.725145179688646,2.9700064980570517,"""
215
215
  )
216
216
 
217
217
 
218
+ def test_wkt_export(map, live_server, bootstrap, page):
219
+ page.goto(f"{live_server.url}{map.get_absolute_url()}?share")
220
+ button = page.get_by_role("button", name="wkt")
221
+ expect(button).to_be_visible()
222
+ with page.expect_download() as download_info:
223
+ button.click()
224
+ download = download_info.value
225
+ assert download.suggested_filename == "test_map.csv"
226
+ path = Path("/tmp/") / download.suggested_filename
227
+ download.save_as(path)
228
+ assert (
229
+ path.read_text()
230
+ == """name,geometry,description
231
+ name poly,"POLYGON ((11.25 53.585984,10.151367 52.975108,12.689209 52.167194,14.084473 53.199452,12.634277 53.618579,11.25 53.585984,11.25 53.585984))",
232
+ test one,POINT (-0.274658 52.57635),Some description
233
+ test two,"LINESTRING (-0.571289 54.476422,0.439453 54.610255,1.724854 53.448807,4.163818 53.988395,5.306396 53.533778,6.591797 53.709714,7.042236 53.350551)","""
234
+ )
235
+
236
+
218
237
  def test_gpx_export(map, live_server, bootstrap, page):
219
238
  page.goto(f"{live_server.url}{map.get_absolute_url()}?share")
220
239
  button = page.get_by_role("button", name="gpx")