umap-project 2.1.2__py3-none-any.whl → 2.1.3__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.
- umap/__init__.py +1 -1
- umap/models.py +2 -0
- umap/static/umap/js/umap.controls.js +29 -0
- umap/static/umap/js/umap.features.js +3 -1
- umap/static/umap/js/umap.importer.js +4 -5
- umap/static/umap/js/umap.js +27 -36
- umap/static/umap/js/umap.layer.js +7 -6
- umap/static/umap/test/Map.js +0 -304
- umap/static/umap/test/Polygon.js +0 -256
- umap/static/umap/test/Polyline.js +0 -116
- umap/static/umap/test/index.html +1 -4
- umap/tests/conftest.py +9 -0
- umap/tests/fixtures/test_upload_data.csv +2 -1
- umap/tests/fixtures/test_upload_data.umap +171 -0
- umap/tests/fixtures/test_upload_data_osm.json +33 -0
- umap/tests/integration/conftest.py +5 -0
- umap/tests/integration/test_anonymous_owned_map.py +3 -0
- umap/tests/integration/test_browser.py +4 -11
- umap/tests/integration/test_choropleth.py +89 -0
- umap/tests/integration/test_collaborative_editing.py +30 -1
- umap/tests/integration/test_datalayer.py +130 -0
- umap/tests/integration/test_edit_datalayer.py +134 -0
- umap/tests/integration/test_edit_map.py +15 -0
- umap/tests/integration/test_facets_browser.py +31 -0
- umap/tests/integration/test_import.py +347 -2
- umap/tests/integration/test_map.py +17 -37
- umap/tests/integration/test_owned_map.py +18 -0
- umap/tests/integration/test_picto.py +20 -33
- umap/tests/integration/test_polygon.py +363 -0
- umap/tests/integration/test_polyline.py +325 -0
- umap/tests/integration/test_tableeditor.py +27 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/METADATA +4 -4
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/RECORD +36 -33
- umap/static/umap/test/Choropleth.js +0 -245
- umap/static/umap/test/DataLayer.js +0 -463
- umap/static/umap/test/Permissions.js +0 -74
- umap/static/umap/test/TableEditor.js +0 -104
- umap/tests/integration/test_drawing.py +0 -243
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/WHEEL +0 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/entry_points.txt +0 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
describe('U.DataLayer', () => {
|
|
2
|
-
let path = '/map/99/datalayer/update/62/',
|
|
3
|
-
map,
|
|
4
|
-
datalayer
|
|
5
|
-
|
|
6
|
-
before(async () => {
|
|
7
|
-
fetchMock.mock(/\/datalayer\/62\/\?.*/, JSON.stringify(RESPONSES.datalayer62_GET))
|
|
8
|
-
fetchMock.sticky('/map/99/update/settings/', { id: 99 })
|
|
9
|
-
this.options = {
|
|
10
|
-
umap_id: 99,
|
|
11
|
-
}
|
|
12
|
-
MAP = map = initMap({ umap_id: 99 })
|
|
13
|
-
const datalayer_options = defaultDatalayerData()
|
|
14
|
-
await map.initDataLayers([datalayer_options])
|
|
15
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
16
|
-
enableEdit()
|
|
17
|
-
})
|
|
18
|
-
after(() => {
|
|
19
|
-
fetchMock.restore()
|
|
20
|
-
resetMap()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe('#init()', () => {
|
|
24
|
-
it('should be added in datalayers index', () => {
|
|
25
|
-
assert.notEqual(map.datalayers_index.indexOf(datalayer), -1)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
describe('#edit()', () => {
|
|
30
|
-
var editButton, form, input, forceButton
|
|
31
|
-
|
|
32
|
-
it('row in control should be active', () => {
|
|
33
|
-
assert.notOk(
|
|
34
|
-
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer) + '.off')
|
|
35
|
-
)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should have edit button', () => {
|
|
39
|
-
editButton = qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
|
|
40
|
-
assert.ok(editButton)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should have toggle visibility element', () => {
|
|
44
|
-
assert.ok(qs('.leaflet-control-browse i.layer-toggle'))
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should exist only one datalayer', () => {
|
|
48
|
-
assert.equal(qsa('.leaflet-control-browse i.layer-toggle').length, 1)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should build a form on edit button click', () => {
|
|
52
|
-
happen.click(editButton)
|
|
53
|
-
form = qs('form.umap-form')
|
|
54
|
-
input = qs('form.umap-form input[name="name"]')
|
|
55
|
-
assert.ok(form)
|
|
56
|
-
assert.ok(input)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should update name on input change', () => {
|
|
60
|
-
var new_name = 'This is a new name'
|
|
61
|
-
input.value = new_name
|
|
62
|
-
happen.once(input, { type: 'input' })
|
|
63
|
-
assert.equal(datalayer.options.name, new_name)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should have made datalayer dirty', () => {
|
|
67
|
-
assert.ok(datalayer.isDirty)
|
|
68
|
-
assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('should have made Map dirty', () => {
|
|
72
|
-
assert.ok(map.isDirty)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should call datalayer.save on save button click', (done) => {
|
|
76
|
-
const postDatalayer = fetchMock.post(path, () => {
|
|
77
|
-
return defaultDatalayerData()
|
|
78
|
-
})
|
|
79
|
-
clickSave()
|
|
80
|
-
window.setTimeout(() => {
|
|
81
|
-
assert(fetchMock.called(path))
|
|
82
|
-
done()
|
|
83
|
-
}, 500)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('should show alert if server respond 412', (done) => {
|
|
87
|
-
cleanAlert()
|
|
88
|
-
fetchMock.restore()
|
|
89
|
-
fetchMock.post(path, 412)
|
|
90
|
-
happen.click(editButton)
|
|
91
|
-
input = qs('form.umap-form input[name="name"]')
|
|
92
|
-
input.value = 'a new name'
|
|
93
|
-
happen.once(input, { type: 'input' })
|
|
94
|
-
clickSave()
|
|
95
|
-
window.setTimeout(() => {
|
|
96
|
-
assert(L.DomUtil.hasClass(map._container, 'umap-alert'))
|
|
97
|
-
assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
98
|
-
const forceButton = qs('#umap-alert-container .umap-action')
|
|
99
|
-
assert.ok(forceButton)
|
|
100
|
-
done()
|
|
101
|
-
}, 500)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('should save anyway on force save button click', (done) => {
|
|
105
|
-
const forceButton = qs('#umap-alert-container .umap-action')
|
|
106
|
-
fetchMock.restore()
|
|
107
|
-
fetchMock.post(path, defaultDatalayerData)
|
|
108
|
-
happen.click(forceButton)
|
|
109
|
-
window.setTimeout(() => {
|
|
110
|
-
assert.notOk(qs('#umap-alert-container .umap-action'))
|
|
111
|
-
assert(fetchMock.called(path))
|
|
112
|
-
assert.equal(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
113
|
-
done()
|
|
114
|
-
}, 500)
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
describe('#save() new', () => {
|
|
119
|
-
let newLayerButton, form, input, newDatalayer, editButton, manageButton
|
|
120
|
-
|
|
121
|
-
it('should have a manage datalayers action', () => {
|
|
122
|
-
enableEdit()
|
|
123
|
-
manageButton = qs('.manage-datalayers')
|
|
124
|
-
assert.ok(manageButton)
|
|
125
|
-
happen.click(manageButton)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('should have a new layer button', () => {
|
|
129
|
-
newLayerButton = qs('#umap-ui-container .add-datalayer')
|
|
130
|
-
assert.ok(newLayerButton)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('should build a form on new layer button click', () => {
|
|
134
|
-
happen.click(newLayerButton)
|
|
135
|
-
form = qs('form.umap-form')
|
|
136
|
-
input = qs('form.umap-form input[name="name"]')
|
|
137
|
-
assert.ok(form)
|
|
138
|
-
assert.ok(input)
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
it('should have an empty name', () => {
|
|
142
|
-
assert.notOk(input.value)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('should have created a new datalayer', () => {
|
|
146
|
-
assert.equal(map.datalayers_index.length, 2)
|
|
147
|
-
newDatalayer = map.datalayers_index[1]
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it('should have made Map dirty', () => {
|
|
151
|
-
assert.ok(map.isDirty)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('should update name on input change', () => {
|
|
155
|
-
var new_name = 'This is a new name'
|
|
156
|
-
input.value = new_name
|
|
157
|
-
happen.once(input, { type: 'input' })
|
|
158
|
-
assert.equal(newDatalayer.options.name, new_name)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
it('should set umap_id on save callback', async () => {
|
|
162
|
-
assert.notOk(newDatalayer.umap_id)
|
|
163
|
-
fetchMock.post('/map/99/datalayer/create/', defaultDatalayerData({ id: 63 }))
|
|
164
|
-
clickSave()
|
|
165
|
-
return new Promise((resolve) => {
|
|
166
|
-
window.setTimeout(() => {
|
|
167
|
-
assert.equal(newDatalayer.umap_id, 63)
|
|
168
|
-
resolve()
|
|
169
|
-
}, 1000)
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('should have unset map dirty', () => {
|
|
174
|
-
assert.notOk(map.isDirty)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('should have edit button', () => {
|
|
178
|
-
editButton = qs('#browse_data_toggle_' + L.stamp(newDatalayer) + ' .layer-edit')
|
|
179
|
-
assert.ok(editButton)
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
it('should call update if we edit again', async () => {
|
|
183
|
-
happen.click(editButton)
|
|
184
|
-
assert.notOk(map.isDirty)
|
|
185
|
-
input = qs('form.umap-form input[name="name"]')
|
|
186
|
-
input.value = "a new name again but we don't care which"
|
|
187
|
-
happen.once(input, { type: 'input' })
|
|
188
|
-
assert.ok(map.isDirty)
|
|
189
|
-
var response = () => {
|
|
190
|
-
return defaultDatalayerData({ pk: 63 })
|
|
191
|
-
}
|
|
192
|
-
var spy = sinon.spy(response)
|
|
193
|
-
fetchMock.post('/map/99/datalayer/update/63/', spy)
|
|
194
|
-
return new Promise((resolve) => {
|
|
195
|
-
clickSave()
|
|
196
|
-
window.setTimeout(() => {
|
|
197
|
-
assert.ok(spy.calledOnce)
|
|
198
|
-
resolve()
|
|
199
|
-
}, 1000)
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
describe('#iconClassChange()', () => {
|
|
205
|
-
it('should change icon class', () => {
|
|
206
|
-
happen.click(qs('[data-id="' + datalayer._leaflet_id + '"] .layer-edit'))
|
|
207
|
-
changeSelectValue(
|
|
208
|
-
qs('form#datalayer-advanced-properties select[name=iconClass]'),
|
|
209
|
-
'Circle'
|
|
210
|
-
)
|
|
211
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
212
|
-
assert.ok(qs('div.umap-circle-icon'))
|
|
213
|
-
happen.click(
|
|
214
|
-
qs('form#datalayer-advanced-properties .umap-field-iconClass .undefine')
|
|
215
|
-
)
|
|
216
|
-
assert.notOk(qs('div.umap-circle-icon'))
|
|
217
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
218
|
-
clickCancel()
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
describe('#show/hide', () => {
|
|
223
|
-
it('should hide features on hide', () => {
|
|
224
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
225
|
-
assert.ok(qs('path[fill="none"]'))
|
|
226
|
-
datalayer.hide()
|
|
227
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
228
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
it('should show features on show', () => {
|
|
232
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
233
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
234
|
-
datalayer.show()
|
|
235
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
236
|
-
assert.ok(qs('path[fill="none"]'))
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
describe('#clone()', () => {
|
|
241
|
-
it('should clone everything but the id and the name', () => {
|
|
242
|
-
enableEdit()
|
|
243
|
-
var clone = datalayer.clone()
|
|
244
|
-
assert.notOk(clone.umap_id)
|
|
245
|
-
assert.notEqual(clone.options.name, datalayer.name)
|
|
246
|
-
assert.ok(clone.options.name)
|
|
247
|
-
assert.equal(clone.options.color, datalayer.options.color)
|
|
248
|
-
assert.equal(clone.options.stroke, datalayer.options.stroke)
|
|
249
|
-
clone._delete()
|
|
250
|
-
clickSave()
|
|
251
|
-
})
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
describe('#restore()', () => {
|
|
255
|
-
var oldConfirm,
|
|
256
|
-
newConfirm = () => {
|
|
257
|
-
return true
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
before(() => {
|
|
261
|
-
oldConfirm = window.confirm
|
|
262
|
-
window.confirm = newConfirm
|
|
263
|
-
})
|
|
264
|
-
after(() => {
|
|
265
|
-
window.confirm = oldConfirm
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
it('should restore everything', (done) => {
|
|
269
|
-
enableEdit()
|
|
270
|
-
var geojson = L.Util.CopyJSON(RESPONSES.datalayer62_GET)
|
|
271
|
-
geojson.features.push({
|
|
272
|
-
geometry: {
|
|
273
|
-
type: 'Point',
|
|
274
|
-
coordinates: [-1.274658203125, 50.57634993749885],
|
|
275
|
-
},
|
|
276
|
-
type: 'Feature',
|
|
277
|
-
id: 1807,
|
|
278
|
-
properties: { _umap_options: {}, name: 'new point from restore' },
|
|
279
|
-
})
|
|
280
|
-
geojson._umap_options.color = 'Chocolate'
|
|
281
|
-
fetchMock.get('/datalayer/62/olderversion.geojson', geojson)
|
|
282
|
-
sinon.spy(window, 'confirm')
|
|
283
|
-
datalayer.restore('olderversion.geojson')
|
|
284
|
-
window.setTimeout(() => {
|
|
285
|
-
assert(window.confirm.calledOnce)
|
|
286
|
-
window.confirm.restore()
|
|
287
|
-
assert.equal(datalayer.umap_id, 62)
|
|
288
|
-
assert.ok(datalayer.isDirty)
|
|
289
|
-
assert.equal(datalayer._index.length, 4)
|
|
290
|
-
assert.ok(qs('path[fill="Chocolate"]'))
|
|
291
|
-
done()
|
|
292
|
-
}, 1000)
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
it('should revert anything on cancel click', () => {
|
|
296
|
-
clickCancel()
|
|
297
|
-
assert.equal(datalayer._index.length, 3)
|
|
298
|
-
assert.notOk(qs('path[fill="Chocolate"]'))
|
|
299
|
-
})
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
describe('#smart-options()', () => {
|
|
303
|
-
let poly, marker
|
|
304
|
-
before(() => {
|
|
305
|
-
datalayer.eachLayer(function (layer) {
|
|
306
|
-
if (!poly && layer instanceof L.Polygon) {
|
|
307
|
-
poly = layer
|
|
308
|
-
}
|
|
309
|
-
if (!marker && layer instanceof L.Marker) {
|
|
310
|
-
marker = layer
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
it('should parse color variable', () => {
|
|
316
|
-
let icon = qs('div.umap-div-icon .icon_container')
|
|
317
|
-
poly.properties.mycolor = 'DarkGoldenRod'
|
|
318
|
-
marker.properties.mycolor = 'DarkRed'
|
|
319
|
-
marker.properties._umap_options.color = undefined
|
|
320
|
-
assert.notOk(qs('path[fill="DarkGoldenRod"]'))
|
|
321
|
-
assert.equal(icon.style.backgroundColor, 'olivedrab')
|
|
322
|
-
datalayer.options.color = '{mycolor}'
|
|
323
|
-
datalayer.options.fillColor = '{mycolor}'
|
|
324
|
-
datalayer.indexProperties(poly)
|
|
325
|
-
datalayer.indexProperties(marker)
|
|
326
|
-
datalayer.redraw()
|
|
327
|
-
icon = qs('div.umap-div-icon .icon_container')
|
|
328
|
-
assert.equal(icon.style.backgroundColor, 'darkred')
|
|
329
|
-
assert.ok(qs('path[fill="DarkGoldenRod"]'))
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
describe('#facet-search()', () => {
|
|
334
|
-
before(async () => {
|
|
335
|
-
fetchMock.get(/\/datalayer\/63\/\?.*/, RESPONSES.datalayer63_GET)
|
|
336
|
-
map.options.facetKey = 'name'
|
|
337
|
-
await map.initDataLayers([RESPONSES.datalayer63_GET._umap_options])
|
|
338
|
-
})
|
|
339
|
-
it('should not impact non browsable layer', () => {
|
|
340
|
-
assert.ok(qs('path[fill="SteelBlue"]'))
|
|
341
|
-
})
|
|
342
|
-
it('should allow advanced filter', () => {
|
|
343
|
-
map.openFacet()
|
|
344
|
-
assert.ok(qs('div.umap-facet-search'))
|
|
345
|
-
// This one if from the normal datalayer
|
|
346
|
-
// it's name is "test", so it should be hidden
|
|
347
|
-
// by the filter
|
|
348
|
-
assert.ok(qs('path[fill="none"]'))
|
|
349
|
-
happen.click(qs('input[data-value="name poly"]'))
|
|
350
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
351
|
-
// This one comes from a non browsable layer
|
|
352
|
-
// so it should not be affected by the filter
|
|
353
|
-
assert.ok(qs('path[fill="SteelBlue"]'))
|
|
354
|
-
happen.click(qs('input[data-value="name poly"]')) // Undo
|
|
355
|
-
})
|
|
356
|
-
it('should allow to control facet label', () => {
|
|
357
|
-
map.options.facetKey = 'name|Nom'
|
|
358
|
-
map.openFacet()
|
|
359
|
-
assert.ok(qs('div.umap-facet-search h5'))
|
|
360
|
-
assert.equal(qs('div.umap-facet-search h5').textContent, 'Nom')
|
|
361
|
-
})
|
|
362
|
-
})
|
|
363
|
-
describe('#zoomEnd', () => {
|
|
364
|
-
it('should honour the fromZoom option', () => {
|
|
365
|
-
map.setZoom(6, { animate: false })
|
|
366
|
-
assert.ok(qs('path[fill="none"]'))
|
|
367
|
-
datalayer.options.fromZoom = 6
|
|
368
|
-
map.setZoom(5, { animate: false })
|
|
369
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
370
|
-
map.setZoom(6, { animate: false })
|
|
371
|
-
assert.ok(qs('path[fill="none"]'))
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
it('should honour the toZoom option', () => {
|
|
375
|
-
map.setZoom(6, { animate: false })
|
|
376
|
-
assert.ok(qs('path[fill="none"]'))
|
|
377
|
-
datalayer.options.toZoom = 6
|
|
378
|
-
map.setZoom(7, { animate: false })
|
|
379
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
380
|
-
map.setZoom(6, { animate: false })
|
|
381
|
-
assert.ok(qs('path[fill="none"]'))
|
|
382
|
-
})
|
|
383
|
-
})
|
|
384
|
-
|
|
385
|
-
describe('#displayOnLoad', () => {
|
|
386
|
-
before(() => {
|
|
387
|
-
fetchMock.get(/\/datalayer\/64\/\?.*/, RESPONSES.datalayer64_GET)
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
beforeEach(async () => {
|
|
391
|
-
await map.initDataLayers([RESPONSES.datalayer64_GET._umap_options])
|
|
392
|
-
datalayer = map.getDataLayerByUmapId(64)
|
|
393
|
-
map.setZoom(10, { animate: false })
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
afterEach(() => {
|
|
397
|
-
datalayer._delete()
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
it('should not display layer at load', () => {
|
|
401
|
-
assert.notOk(qs('path[fill="AliceBlue"]'))
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
it('should display on click', (done) => {
|
|
405
|
-
happen.click(qs(`[data-id='${L.stamp(datalayer)}'] .layer-toggle`))
|
|
406
|
-
window.setTimeout(() => {
|
|
407
|
-
assert.ok(qs('path[fill="AliceBlue"]'))
|
|
408
|
-
done()
|
|
409
|
-
}, 500)
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
it('should not display on zoom', (done) => {
|
|
413
|
-
map.setZoom(9, { animate: false })
|
|
414
|
-
window.setTimeout(() => {
|
|
415
|
-
assert.notOk(qs('path[fill="AliceBlue"]'))
|
|
416
|
-
done()
|
|
417
|
-
}, 500)
|
|
418
|
-
})
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
describe('#delete()', () => {
|
|
422
|
-
let deleteLink,
|
|
423
|
-
deletePath = '/map/99/datalayer/delete/62/'
|
|
424
|
-
before(() => {
|
|
425
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
it('should have a delete link in update form', () => {
|
|
429
|
-
enableEdit()
|
|
430
|
-
happen.click(qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit'))
|
|
431
|
-
deleteLink = qs('button.delete_datalayer_button')
|
|
432
|
-
assert.ok(deleteLink)
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
it('should delete features on datalayer delete', () => {
|
|
436
|
-
happen.click(deleteLink)
|
|
437
|
-
assert.notOk(qs('div.icon_container'))
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
it('should have set map dirty', () => {
|
|
441
|
-
assert.ok(map.isDirty)
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
it('should delete layer control row on delete', () => {
|
|
445
|
-
assert.notOk(
|
|
446
|
-
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer))
|
|
447
|
-
)
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
it('should be removed from map.datalayers_index', () => {
|
|
451
|
-
assert.equal(map.datalayers_index.indexOf(datalayer), -1)
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
it('should be removed from map.datalayers', () => {
|
|
455
|
-
assert.notOk(map.datalayers[L.stamp(datalayer)])
|
|
456
|
-
})
|
|
457
|
-
|
|
458
|
-
it('should be visible again on edit cancel', () => {
|
|
459
|
-
clickCancel()
|
|
460
|
-
assert.ok(qs('div.icon_container'))
|
|
461
|
-
})
|
|
462
|
-
})
|
|
463
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
describe('L.Permissions', function () {
|
|
2
|
-
var path = '/map/99/datalayer/edit/62/'
|
|
3
|
-
|
|
4
|
-
before(function () {
|
|
5
|
-
this.server = sinon.fakeServer.create()
|
|
6
|
-
this.server.respondWith(
|
|
7
|
-
/\/datalayer\/62\/\?.*/,
|
|
8
|
-
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
9
|
-
)
|
|
10
|
-
this.map = initMap({ umap_id: 99 })
|
|
11
|
-
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
12
|
-
this.server.respond()
|
|
13
|
-
enableEdit()
|
|
14
|
-
})
|
|
15
|
-
after(function () {
|
|
16
|
-
clickCancel()
|
|
17
|
-
this.server.restore()
|
|
18
|
-
resetMap()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('#open()', function () {
|
|
22
|
-
var button
|
|
23
|
-
|
|
24
|
-
it('should exist update permissions link', function () {
|
|
25
|
-
button = qs('a.update-map-permissions')
|
|
26
|
-
expect(button).to.be.ok
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should open table button click', function () {
|
|
30
|
-
happen.click(button)
|
|
31
|
-
expect(qs('.permissions-panel')).to.be.ok
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
describe('#anonymous with cookie', function () {
|
|
35
|
-
var button
|
|
36
|
-
|
|
37
|
-
it('should not allow share_status nor owner', function () {
|
|
38
|
-
this.map.permissions.options.anonymous_edit_url = 'http://anonymous.url'
|
|
39
|
-
delete this.map.options.permissions.owner
|
|
40
|
-
button = qs('a.update-map-permissions')
|
|
41
|
-
happen.click(button)
|
|
42
|
-
expect(qs('select[name="share_status"]')).not.to.be.ok
|
|
43
|
-
expect(qs('input.edit-owner')).not.to.be.ok
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe('#editor', function () {
|
|
48
|
-
var button
|
|
49
|
-
|
|
50
|
-
it('should only allow editors', function () {
|
|
51
|
-
this.map.options.permissions.owner = { id: 1, url: '/url', name: 'jojo' }
|
|
52
|
-
delete this.map.options.permissions.anonymous_edit_url
|
|
53
|
-
delete this.map.options.user
|
|
54
|
-
button = qs('a.update-map-permissions')
|
|
55
|
-
happen.click(button)
|
|
56
|
-
expect(qs('select[name="share_status"]')).not.to.be.ok
|
|
57
|
-
expect(qs('input.edit-owner')).not.to.be.ok
|
|
58
|
-
expect(qs('input.edit-editors')).to.be.ok
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('#owner', function () {
|
|
63
|
-
var button
|
|
64
|
-
|
|
65
|
-
it('should allow everything', function () {
|
|
66
|
-
this.map.permissions.options.owner = { id: 1, url: '/url', name: 'jojo' }
|
|
67
|
-
this.map.options.user = { id: 1, url: '/url', name: 'jojo' }
|
|
68
|
-
button = qs('a.update-map-permissions')
|
|
69
|
-
happen.click(button)
|
|
70
|
-
expect(qs('input.edit-owner')).to.be.ok
|
|
71
|
-
expect(qs('input.edit-editors')).to.be.ok
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
describe('L.TableEditor', () => {
|
|
2
|
-
let path = '/map/99/datalayer/edit/62/',
|
|
3
|
-
datalayer
|
|
4
|
-
|
|
5
|
-
before(async () => {
|
|
6
|
-
await fetchMock.mock(
|
|
7
|
-
/\/datalayer\/62\/\?.*/,
|
|
8
|
-
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
9
|
-
)
|
|
10
|
-
this.options = {
|
|
11
|
-
umap_id: 99,
|
|
12
|
-
}
|
|
13
|
-
map = initMap({ umap_id: 99 })
|
|
14
|
-
const datalayer_options = defaultDatalayerData()
|
|
15
|
-
await map.initDataLayers([datalayer_options])
|
|
16
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
17
|
-
enableEdit()
|
|
18
|
-
})
|
|
19
|
-
after(() => {
|
|
20
|
-
fetchMock.restore()
|
|
21
|
-
clickCancel()
|
|
22
|
-
resetMap()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
describe('#open()', () => {
|
|
26
|
-
var button
|
|
27
|
-
|
|
28
|
-
it('should exist table click on edit mode', () => {
|
|
29
|
-
button = qs(
|
|
30
|
-
'#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-table-edit'
|
|
31
|
-
)
|
|
32
|
-
expect(button).to.be.ok
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('should open table button click', () => {
|
|
36
|
-
happen.click(button)
|
|
37
|
-
expect(qs('#umap-ui-container div.table')).to.be.ok
|
|
38
|
-
expect(qsa('#umap-ui-container div.table form').length).to.eql(3) // One per feature.
|
|
39
|
-
expect(qsa('#umap-ui-container div.table input').length).to.eql(3) // One per feature and per property.
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
describe('#properties()', () => {
|
|
43
|
-
var feature
|
|
44
|
-
|
|
45
|
-
before(() => {
|
|
46
|
-
var firstIndex = datalayer._index[0]
|
|
47
|
-
feature = datalayer._layers[firstIndex]
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should create new property column', () => {
|
|
51
|
-
var newPrompt = () => {
|
|
52
|
-
return 'newprop'
|
|
53
|
-
}
|
|
54
|
-
var oldPrompt = window.prompt
|
|
55
|
-
window.prompt = newPrompt
|
|
56
|
-
var button = qs('#umap-ui-container .add-property')
|
|
57
|
-
expect(button).to.be.ok
|
|
58
|
-
happen.click(button)
|
|
59
|
-
expect(qsa('#umap-ui-container div.table input').length).to.eql(6) // One per feature and per property.
|
|
60
|
-
window.prompt = oldPrompt
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('should populate feature property on fill', () => {
|
|
64
|
-
var input = qs(
|
|
65
|
-
'form#umap-feature-properties_' + L.stamp(feature) + ' input[name=newprop]'
|
|
66
|
-
)
|
|
67
|
-
changeInputValue(input, 'the value')
|
|
68
|
-
expect(feature.properties.newprop).to.eql('the value')
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('should update property name on update click', () => {
|
|
72
|
-
var newPrompt = () => {
|
|
73
|
-
return 'newname'
|
|
74
|
-
}
|
|
75
|
-
var oldPrompt = window.prompt
|
|
76
|
-
window.prompt = newPrompt
|
|
77
|
-
var button = qs('#umap-ui-container div.thead div.tcell:last-of-type .umap-edit')
|
|
78
|
-
expect(button).to.be.ok
|
|
79
|
-
happen.click(button)
|
|
80
|
-
expect(qsa('#umap-ui-container div.table input').length).to.eql(6)
|
|
81
|
-
expect(feature.properties.newprop).to.be.undefined
|
|
82
|
-
expect(feature.properties.newname).to.eql('the value')
|
|
83
|
-
window.prompt = oldPrompt
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('should update property on delete click', () => {
|
|
87
|
-
var oldConfirm,
|
|
88
|
-
newConfirm = () => {
|
|
89
|
-
return true
|
|
90
|
-
}
|
|
91
|
-
oldConfirm = window.confirm
|
|
92
|
-
window.confirm = newConfirm
|
|
93
|
-
var button = qs(
|
|
94
|
-
'#umap-ui-container div.thead div.tcell:last-of-type .umap-delete'
|
|
95
|
-
)
|
|
96
|
-
expect(button).to.be.ok
|
|
97
|
-
happen.click(button)
|
|
98
|
-
FEATURE = feature
|
|
99
|
-
expect(qsa('#umap-ui-container div.table input').length).to.eql(3)
|
|
100
|
-
expect(feature.properties.newname).to.be.undefined
|
|
101
|
-
window.confirm = oldConfirm
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
})
|