chore: fix tests

This commit is contained in:
Yohan Boniface 2024-04-15 11:59:06 +02:00
parent 573a33df5a
commit e615e0926a
9 changed files with 55 additions and 47 deletions

View file

@ -49,7 +49,7 @@ def test_basic_choropleth_map_with_custom_brewer(openmap, live_server, page):
# Now change brewer from UI # Now change brewer from UI
page.get_by_role("button", name="Edit").click() page.get_by_role("button", name="Edit").click()
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Choropleth: settings").click() page.get_by_role("heading", name="Choropleth: settings").click()
page.locator('select[name="brewer"]').select_option("Greens") page.locator('select[name="brewer"]').select_option("Greens")

View file

@ -20,14 +20,14 @@ def set_options(datalayer, **options):
def test_honour_displayOnLoad_false(map, live_server, datalayer, page): def test_honour_displayOnLoad_false(map, live_server, datalayer, page):
set_options(datalayer, displayOnLoad=False) set_options(datalayer, displayOnLoad=False)
page.goto(f"{live_server.url}{map.get_absolute_url()}") page.goto(f"{live_server.url}{map.get_absolute_url()}?onLoadPanel=datalayers")
expect(page.locator(".leaflet-marker-icon")).to_be_hidden() expect(page.locator(".leaflet-marker-icon")).to_be_hidden()
layers = page.locator(".umap-browse-datalayers li") layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
layers_off = page.locator(".umap-browse-datalayers li.off") layers_off = page.locator(".umap-browser .datalayer.off")
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(layers_off).to_have_count(1) expect(layers_off).to_have_count(1)
page.get_by_role("button", name="See data layers").click() page.get_by_role("button", name="See layers").click()
page.get_by_label("Zoom in").click() page.get_by_label("Zoom in").click()
expect(markers).to_be_hidden() expect(markers).to_be_hidden()
page.get_by_title("Show/hide layer").click() page.get_by_title("Show/hide layer").click()
@ -109,10 +109,12 @@ def test_should_honour_color_variable(live_server, map, page):
def test_datalayers_in_query_string(live_server, datalayer, map, page): def test_datalayers_in_query_string(live_server, datalayer, map, page):
map.settings["properties"]["onLoadPanel"] = "datalayers"
map.save()
with_old_id = DataLayerFactory(old_id=134, map=map, name="with old id") with_old_id = DataLayerFactory(old_id=134, map=map, name="with old id")
set_options(with_old_id, name="with old id") set_options(with_old_id, name="with old id")
visible = page.locator(".leaflet-control-browse li:not(.off) span") visible = page.locator(".umap-browser .datalayer:not(.off) .datalayer-name")
hidden = page.locator(".leaflet-control-browse li.off span") hidden = page.locator(".umap-browser .datalayer.off .datalayer-name")
page.goto(f"{live_server.url}{map.get_absolute_url()}") page.goto(f"{live_server.url}{map.get_absolute_url()}")
expect(visible).to_have_count(2) expect(visible).to_have_count(2)
expect(hidden).to_have_count(0) expect(hidden).to_have_count(0)

View file

@ -54,32 +54,32 @@ def test_cancel_deleting_datalayer_should_restore(
live_server, openmap, datalayer, page live_server, openmap, datalayer, page
): ):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.once("dialog", lambda dialog: dialog.accept()) page.once("dialog", lambda dialog: dialog.accept())
page.locator("#umap-ui-container").get_by_title("Delete layer").click() page.locator(".panel.right").get_by_title("Delete layer").click()
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
page.get_by_role("button", name="See data layers").click() page.get_by_role("button", name="See layers").click()
expect(page.get_by_text("test datalayer")).to_be_hidden() expect(page.get_by_text("test datalayer")).to_be_hidden()
page.once("dialog", lambda dialog: dialog.accept()) page.once("dialog", lambda dialog: dialog.accept())
page.get_by_role("button", name="Cancel edits").click() page.get_by_role("button", name="Cancel edits").click()
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect( expect(page.locator(".umap-browser").get_by_text("test datalayer")).to_be_visible()
page.locator(".leaflet-control-browse").get_by_text("test datalayer")
).to_be_visible()
def test_can_clone_datalayer(live_server, openmap, login, datalayer, page): def test_can_clone_datalayer(live_server, openmap, login, datalayer, page):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel.right").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Advanced actions").click() page.get_by_role("heading", name="Advanced actions").click()
page.get_by_role("button", name="Clone").click() page.get_by_role("button", name="Clone").click()
expect(layers).to_have_count(2) expect(layers).to_have_count(2)
@ -103,7 +103,7 @@ def test_can_change_icon_class(live_server, openmap, page):
expect(page.locator(".umap-div-icon")).to_be_visible() expect(page.locator(".umap-div-icon")).to_be_visible()
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
expect(page.locator(".umap-circle-icon")).to_be_hidden() expect(page.locator(".umap-circle-icon")).to_be_hidden()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel.right").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_role("heading", name="Shape properties").click()
page.locator(".umap-field-iconClass a.define").click() page.locator(".umap-field-iconClass a.define").click()
page.get_by_text("Circle").click() page.get_by_text("Circle").click()
@ -116,12 +116,12 @@ def test_can_change_name(live_server, openmap, page, datalayer):
f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded" f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded"
) )
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel.right").get_by_title("Edit", exact=True).click()
expect(page.locator(".umap-is-dirty")).to_be_hidden() expect(page.locator(".umap-is-dirty")).to_be_hidden()
page.locator('input[name="name"]').click() page.locator('input[name="name"]').click()
page.locator('input[name="name"]').press("Control+a") page.locator('input[name="name"]').press("Control+a")
page.locator('input[name="name"]').fill("new name") page.locator('input[name="name"]').fill("new name")
expect(page.locator(".leaflet-control-browse li span")).to_contain_text("new name") expect(page.locator(".umap-browser .datalayer")).to_contain_text("new name")
expect(page.locator(".umap-is-dirty")).to_be_visible() expect(page.locator(".umap-is-dirty")).to_be_visible()
with page.expect_response(re.compile(".*/datalayer/update/.*")): with page.expect_response(re.compile(".*/datalayer/update/.*")):
page.get_by_role("button", name="Save").click() page.get_by_role("button", name="Save").click()
@ -147,7 +147,7 @@ def test_can_create_new_datalayer(live_server, openmap, page, datalayer):
expect(page.locator(".umap-is-dirty")).to_be_hidden() expect(page.locator(".umap-is-dirty")).to_be_hidden()
# Edit again, it should not create a new datalayer # Edit again, it should not create a new datalayer
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).first.click() page.locator(".panel.right").get_by_title("Edit", exact=True).first.click()
page.locator('input[name="name"]').click() page.locator('input[name="name"]').click()
page.locator('input[name="name"]').fill("my new layer with a new name") page.locator('input[name="name"]').fill("my new layer with a new name")
expect(page.get_by_text("my new layer with a new name")).to_be_visible() expect(page.get_by_text("my new layer with a new name")).to_be_visible()
@ -171,7 +171,7 @@ def test_can_restore_version(live_server, openmap, page, datalayer):
page.get_by_role("button", name="Save").click() page.get_by_role("button", name="Save").click()
expect(marker).to_have_class(re.compile(".*umap-div-icon.*")) expect(marker).to_have_class(re.compile(".*umap-div-icon.*"))
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel.right").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Versions").click() page.get_by_role("heading", name="Versions").click()
page.once("dialog", lambda dialog: dialog.accept()) page.once("dialog", lambda dialog: dialog.accept())
page.get_by_role("button", name="Restore this version").last.click() page.get_by_role("button", name="Restore this version").last.click()

View file

@ -10,7 +10,7 @@ from ..base import DataLayerFactory
def test_can_edit_name(page, live_server, tilelayer): def test_can_edit_name(page, live_server, tilelayer):
page.goto(f"{live_server.url}/en/map/new/") page.goto(f"{live_server.url}/en/map/new/")
page.get_by_title("Edit map properties").click() page.get_by_title("Edit map name and caption").click()
name_input = page.locator('.map-metadata input[name="name"]') name_input = page.locator('.map-metadata input[name="name"]')
expect(name_input).to_be_visible() expect(name_input).to_be_visible()
name_input.click() name_input.click()

View file

@ -44,7 +44,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Change colour at layer level # Change colour at layer level
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_role("heading", name="Shape properties").click()
page.locator(".umap-field-color .define").click() page.locator(".umap-field-color .define").click()
expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css( expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css(
@ -66,7 +66,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Now change again at layer level again, it should not change the marker color # Now change again at layer level again, it should not change the marker color
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_role("heading", name="Shape properties").click()
page.locator(".umap-field-color input").click() page.locator(".umap-field-color input").click()
page.get_by_title("DarkViolet").first.click() page.get_by_title("DarkViolet").first.click()

View file

@ -58,7 +58,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Change colour at layer level # Change colour at layer level
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_role("heading", name="Shape properties").click()
page.locator(".umap-field-color .define").click() page.locator(".umap-field-color .define").click()
expect(page.locator(".leaflet-overlay-pane path[fill='DarkBlue']")).to_have_count(1) expect(page.locator(".leaflet-overlay-pane path[fill='DarkBlue']")).to_have_count(1)
@ -76,7 +76,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Now change again at layer level again, it should not change the marker color # Now change again at layer level again, it should not change the marker color
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click() page.locator(".panel").get_by_title("Edit", exact=True).click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_role("heading", name="Shape properties").click()
page.locator(".umap-field-color input").click() page.locator(".umap-field-color input").click()
page.get_by_title("DarkViolet").first.click() page.get_by_title("DarkViolet").first.click()

View file

@ -43,18 +43,18 @@ def test_umap_import_from_file(live_server, tilelayer, page):
def test_umap_import_from_textarea(live_server, tilelayer, page, settings): def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
settings.UMAP_ALLOW_ANONYMOUS = True settings.UMAP_ALLOW_ANONYMOUS = True
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
page.get_by_role("button", name="See layers").click()
page.get_by_title("Import data").click() page.get_by_title("Import data").click()
textarea = page.locator(".umap-upload textarea") textarea = page.locator(".umap-upload textarea")
path = Path(__file__).parent.parent / "fixtures/test_upload_data.umap" path = Path(__file__).parent.parent / "fixtures/test_upload_data.umap"
textarea.fill(path.read_text()) textarea.fill(path.read_text())
page.locator('select[name="format"]').select_option("umap") page.locator('select[name="format"]').select_option("umap")
page.get_by_role("button", name="Import", exact=True).click() page.get_by_role("button", name="Import", exact=True).click()
layers = page.locator(".umap-browse-datalayers li") layers = page.locator(".umap-browser .datalayer")
expect(layers).to_have_count(2) expect(layers).to_have_count(2)
expect(page.locator(".umap-main-edit-toolbox .map-name")).to_have_text( expect(page.locator(".umap-main-edit-toolbox .map-name")).to_have_text(
"Imported map" "Imported map"
) )
page.get_by_role("button", name="See data layers").click()
expect(page.get_by_text("Tunnels")).to_be_visible() expect(page.get_by_text("Tunnels")).to_be_visible()
expect(page.get_by_text("Cities")).to_be_visible() expect(page.get_by_text("Cities")).to_be_visible()
expect(page.locator(".leaflet-control-minimap")).to_be_visible() expect(page.locator(".leaflet-control-minimap")).to_be_visible()
@ -70,6 +70,7 @@ def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
def test_import_geojson_from_textarea(tilelayer, live_server, page): def test_import_geojson_from_textarea(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer") layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
paths = page.locator("path") paths = page.locator("path")
@ -87,7 +88,6 @@ def test_import_geojson_from_textarea(tilelayer, live_server, page):
expect(button).to_be_visible() expect(button).to_be_visible()
button.click() button.click()
# A layer has been created # A layer has been created
page.get_by_title("See layers").click()
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(markers).to_have_count(2) expect(markers).to_have_count(2)
expect(paths).to_have_count(3) expect(paths).to_have_count(3)
@ -95,7 +95,8 @@ def test_import_geojson_from_textarea(tilelayer, live_server, page):
def test_import_kml_from_textarea(tilelayer, live_server, page): def test_import_kml_from_textarea(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
paths = page.locator("path") paths = page.locator("path")
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
@ -119,7 +120,8 @@ def test_import_kml_from_textarea(tilelayer, live_server, page):
def test_import_gpx_from_textarea(tilelayer, live_server, page): def test_import_gpx_from_textarea(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
paths = page.locator("path") paths = page.locator("path")
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
@ -143,7 +145,8 @@ def test_import_gpx_from_textarea(tilelayer, live_server, page):
def test_import_osm_from_textarea(tilelayer, live_server, page): def test_import_osm_from_textarea(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
expect(layers).to_have_count(0) expect(layers).to_have_count(0)
@ -162,7 +165,8 @@ def test_import_osm_from_textarea(tilelayer, live_server, page):
def test_import_csv_from_textarea(tilelayer, live_server, page): def test_import_csv_from_textarea(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
expect(layers).to_have_count(0) expect(layers).to_have_count(0)
@ -181,7 +185,8 @@ def test_import_csv_from_textarea(tilelayer, live_server, page):
def test_can_import_in_existing_datalayer(live_server, datalayer, page, openmap): def test_can_import_in_existing_datalayer(live_server, datalayer, page, openmap):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}") page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
@ -199,7 +204,8 @@ def test_can_import_in_existing_datalayer(live_server, datalayer, page, openmap)
def test_can_replace_datalayer_data(live_server, datalayer, page, openmap): def test_can_replace_datalayer_data(live_server, datalayer, page, openmap):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}") page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
@ -218,7 +224,8 @@ def test_can_replace_datalayer_data(live_server, datalayer, page, openmap):
def test_can_import_in_new_datalayer(live_server, datalayer, page, openmap): def test_can_import_in_new_datalayer(live_server, datalayer, page, openmap):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}") page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
@ -321,7 +328,8 @@ def test_import_geometry_collection(live_server, page, tilelayer):
], ],
} }
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
paths = page.locator("path") paths = page.locator("path")
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
@ -356,7 +364,8 @@ def test_import_multipolygon(live_server, page, tilelayer):
}, },
} }
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
paths = page.locator("path") paths = page.locator("path")
expect(paths).to_have_count(0) expect(paths).to_have_count(0)
expect(layers).to_have_count(0) expect(layers).to_have_count(0)
@ -387,7 +396,8 @@ def test_import_multipolyline(live_server, page, tilelayer):
], ],
} }
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
paths = page.locator("path") paths = page.locator("path")
expect(paths).to_have_count(0) expect(paths).to_have_count(0)
expect(layers).to_have_count(0) expect(layers).to_have_count(0)

View file

@ -236,16 +236,16 @@ def test_can_change_owner(map, live_server, login, user):
def test_can_delete_datalayer(live_server, map, login, datalayer): def test_can_delete_datalayer(live_server, map, login, datalayer):
page = login(map.owner) page = login(map.owner)
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit") page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
layers = page.locator(".umap-browse-datalayers li") page.get_by_title("See layers").click()
layers = page.locator(".umap-browser .datalayer")
markers = page.locator(".leaflet-marker-icon") markers = page.locator(".leaflet-marker-icon")
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.once("dialog", lambda dialog: dialog.accept()) page.once("dialog", lambda dialog: dialog.accept())
page.locator("#umap-ui-container").get_by_title("Delete layer").click() page.locator(".panel.right").get_by_title("Delete layer").click()
with page.expect_response(re.compile(r".*/datalayer/delete/.*")): with page.expect_response(re.compile(r".*/datalayer/delete/.*")):
page.get_by_role("button", name="Save").click() page.get_by_role("button", name="Save").click()
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
# FIXME does not work, resolve to 1 element, even if this command is empty: # FIXME does not work, resolve to 1 element, even if this command is empty:
# document.querySelectorAll(".umap-browse-datalayers li") expect(layers).to_have_count(0)
# expect(layers).to_have_count(0)

View file

@ -2,17 +2,13 @@ import json
import re import re
from pathlib import Path from pathlib import Path
from playwright.sync_api import expect
from umap.models import DataLayer from umap.models import DataLayer
def test_table_editor(live_server, openmap, datalayer, page): def test_table_editor(live_server, openmap, datalayer, page):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
page.get_by_role("link", name="Manage layers").click() page.get_by_role("link", name="Manage layers").click()
page.locator("#umap-ui-container").get_by_title( page.locator(".panel").get_by_title("Edit properties in a table").click()
"Edit properties in a table"
).click()
page.once("dialog", lambda dialog: dialog.accept(prompt_text="newprop")) page.once("dialog", lambda dialog: dialog.accept(prompt_text="newprop"))
page.get_by_text("Add a new property").click() page.get_by_text("Add a new property").click()
page.locator('input[name="newprop"]').fill("newvalue") page.locator('input[name="newprop"]').fill("newvalue")