chore: move Map.Init.js test to playwright suite
This commit is contained in:
parent
0b65d0dd9d
commit
6b5ecac9c6
3 changed files with 35 additions and 48 deletions
|
@ -1,47 +0,0 @@
|
|||
describe('L.U.Map.initialize', function () {
|
||||
let map
|
||||
afterEach(function () {
|
||||
resetMap()
|
||||
})
|
||||
|
||||
describe('Controls', async function () {
|
||||
it('should not show a minimap by default', function () {
|
||||
map = initMap()
|
||||
assert.notOk(qs('.leaflet-control-minimap'))
|
||||
})
|
||||
|
||||
it('should show a minimap', function () {
|
||||
map = initMap({ miniMap: true })
|
||||
assert.ok(qs('.leaflet-control-minimap'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('DefaultView', function () {
|
||||
it('should set default view in default mode without data', function (done) {
|
||||
map = initMap({ datalayers: [] })
|
||||
// Did not find a better way to wait for tiles to be actually loaded
|
||||
window.setTimeout(() => {
|
||||
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
||||
done()
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
it("should set default view in 'data' mode without data", function (done) {
|
||||
map = initMap({ datalayers: [], defaultView: 'data' })
|
||||
// Did not find a better way to wait for tiles to be actually loaded
|
||||
window.setTimeout(() => {
|
||||
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
||||
done()
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
it("should set default view in 'latest' mode without data", function (done) {
|
||||
map = initMap({ datalayers: [], defaultView: 'latest' })
|
||||
// Did not find a better way to wait for tiles to be actually loaded
|
||||
window.setTimeout(() => {
|
||||
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
||||
done()
|
||||
}, 1000)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -89,7 +89,6 @@
|
|||
</script>
|
||||
<script src="./_pre.js" defer></script>
|
||||
<script src="./Map.js" defer></script>
|
||||
<script src="./Map.Init.js" defer></script>
|
||||
<script src="./Map.Export.js" defer></script>
|
||||
<script src="./DataLayer.js" defer></script>
|
||||
<script src="./TableEditor.js" defer></script>
|
||||
|
|
|
@ -41,6 +41,18 @@ def test_preconnect_for_tilelayer(map, page, live_server, tilelayer):
|
|||
expect(meta).to_have_count(0)
|
||||
|
||||
|
||||
def test_default_view_without_datalayer_should_use_default_center(
|
||||
map, live_server, datalayer, page
|
||||
):
|
||||
datalayer.settings["displayOnLoad"] = False
|
||||
datalayer.save()
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
# Hash is defined, so map is initialized
|
||||
expect(page).to_have_url(re.compile(r".*#7/48\..+/13\..+"))
|
||||
layers = page.locator(".umap-browse-datalayers li")
|
||||
expect(layers).to_have_count(1)
|
||||
|
||||
|
||||
def test_default_view_latest_without_datalayer_should_use_default_center(
|
||||
map, live_server, datalayer, page
|
||||
):
|
||||
|
@ -55,6 +67,20 @@ def test_default_view_latest_without_datalayer_should_use_default_center(
|
|||
expect(layers).to_have_count(1)
|
||||
|
||||
|
||||
def test_default_view_data_without_datalayer_should_use_default_center(
|
||||
map, live_server, datalayer, page
|
||||
):
|
||||
datalayer.settings["displayOnLoad"] = False
|
||||
datalayer.save()
|
||||
map.settings["properties"]["defaultView"] = "data"
|
||||
map.save()
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
# Hash is defined, so map is initialized
|
||||
expect(page).to_have_url(re.compile(r".*#7/48\..+/13\..+"))
|
||||
layers = page.locator(".umap-browse-datalayers li")
|
||||
expect(layers).to_have_count(1)
|
||||
|
||||
|
||||
def test_default_view_latest_with_marker(map, live_server, datalayer, page):
|
||||
map.settings["properties"]["defaultView"] = "latest"
|
||||
map.save()
|
||||
|
@ -193,3 +219,12 @@ def test_basic_choropleth_map(map, live_server, page):
|
|||
# Bretagne, Pays de la Loire, AURA
|
||||
paths = page.locator("path[fill='#eff3ff']")
|
||||
expect(paths).to_have_count(3)
|
||||
|
||||
|
||||
def test_minimap_on_load(map, live_server, datalayer, page):
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
expect(page.locator(".leaflet-control-minimap")).to_be_hidden()
|
||||
map.settings["properties"]["miniMap"] = True
|
||||
map.save()
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
expect(page.locator(".leaflet-control-minimap")).to_be_visible()
|
||||
|
|
Loading…
Reference in a new issue