chore: fix tests after fieldset refactor

This commit is contained in:
Yohan Boniface 2024-05-07 13:29:03 +02:00
parent cd48267cf2
commit 2f3e7d03ab
7 changed files with 34 additions and 29 deletions

View file

@ -87,6 +87,11 @@ L.DomUtil.createFieldset = (container, legend, options) => {
L.DomUtil.add('span', '', summary, legend) L.DomUtil.add('span', '', summary, legend)
const fieldset = L.DomUtil.add('fieldset', '', details) const fieldset = L.DomUtil.add('fieldset', '', details)
details.open = options.on === true details.open = options.on === true
if (options.callback) {
L.DomEvent.on(details, 'toggle', () => {
if (details.open) options.callback.call(options.context || this)
})
}
return fieldset return fieldset
} }

View file

@ -77,7 +77,7 @@ def test_data_browser_should_be_filterable(live_server, page, bootstrap, map):
paths = page.locator(".leaflet-overlay-pane path") paths = page.locator(".leaflet-overlay-pane path")
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect(paths).to_have_count(2) expect(paths).to_have_count(2)
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
filter_ = page.locator("input[name='filter']") filter_ = page.locator("input[name='filter']")
expect(filter_).to_be_visible() expect(filter_).to_be_visible()
filter_.type("poly") filter_.type("poly")
@ -104,7 +104,7 @@ def test_data_browser_should_be_filterable(live_server, page, bootstrap, map):
def test_data_browser_can_show_only_visible_features(live_server, page, bootstrap, map): def test_data_browser_can_show_only_visible_features(live_server, page, bootstrap, map):
# Zoom on France # Zoom on France
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000") page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000")
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
el = page.get_by_text("Current map view") el = page.get_by_text("Current map view")
expect(el).to_be_visible() expect(el).to_be_visible()
el.click() el.click()
@ -116,7 +116,7 @@ def test_data_browser_can_show_only_visible_features(live_server, page, bootstra
def test_data_browser_can_mix_filter_and_bbox(live_server, page, bootstrap, map): def test_data_browser_can_mix_filter_and_bbox(live_server, page, bootstrap, map):
# Zoom on north west # Zoom on north west
page.goto(f"{live_server.url}{map.get_absolute_url()}#4/61.98/-2.68") page.goto(f"{live_server.url}{map.get_absolute_url()}#4/61.98/-2.68")
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
el = page.get_by_text("Current map view") el = page.get_by_text("Current map view")
expect(el).to_be_visible() expect(el).to_be_visible()
el.click() el.click()
@ -134,7 +134,7 @@ def test_data_browser_can_mix_filter_and_bbox(live_server, page, bootstrap, map)
def test_data_browser_bbox_limit_should_be_dynamic(live_server, page, bootstrap, map): def test_data_browser_bbox_limit_should_be_dynamic(live_server, page, bootstrap, map):
# Zoom on Europe # Zoom on Europe
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000") page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000")
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
el = page.get_by_text("Current map view") el = page.get_by_text("Current map view")
expect(el).to_be_visible() expect(el).to_be_visible()
el.click() el.click()
@ -160,7 +160,7 @@ def test_data_browser_bbox_filter_should_be_persistent(
): ):
# Zoom on Europe # Zoom on Europe
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000") page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000")
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
el = page.get_by_text("Current map view") el = page.get_by_text("Current map view")
expect(el).to_be_visible() expect(el).to_be_visible()
el.click() el.click()
@ -186,7 +186,7 @@ def test_data_browser_bbox_filtered_is_clickable(live_server, page, bootstrap, m
popup = page.locator(".leaflet-popup") popup = page.locator(".leaflet-popup")
# Zoom on Europe # Zoom on Europe
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000") page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000")
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
el = page.get_by_text("Current map view") el = page.get_by_text("Current map view")
expect(el).to_be_visible() expect(el).to_be_visible()
el.click() el.click()
@ -208,7 +208,7 @@ def test_data_browser_with_variable_in_name(live_server, page, bootstrap, map):
expect(page.get_by_text("one point in france (point)")).to_be_visible() expect(page.get_by_text("one point in france (point)")).to_be_visible()
expect(page.get_by_text("one line in new zeland (line)")).to_be_visible() expect(page.get_by_text("one line in new zeland (line)")).to_be_visible()
expect(page.get_by_text("one polygon in greenland (polygon)")).to_be_visible() expect(page.get_by_text("one polygon in greenland (polygon)")).to_be_visible()
page.get_by_role("heading", name="filters").click() page.locator(".filters summary").click()
filter_ = page.locator("input[name='filter']") filter_ = page.locator("input[name='filter']")
expect(filter_).to_be_visible() expect(filter_).to_be_visible()
filter_.type("foobar") # Hide all filter_.type("foobar") # Hide all

View file

@ -50,7 +50,7 @@ def test_basic_choropleth_map_with_custom_brewer(openmap, live_server, page):
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(".panel").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_text("Choropleth: settings").click()
page.locator('select[name="brewer"]').select_option("Greens") page.locator('select[name="brewer"]').select_option("Greens")
# Hauts-de-France # Hauts-de-France

View file

@ -80,7 +80,7 @@ def test_can_clone_datalayer(live_server, openmap, login, datalayer, page):
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(".panel.right").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_text("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)
expect(markers).to_have_count(2) expect(markers).to_have_count(2)
@ -104,7 +104,7 @@ def test_can_change_icon_class(live_server, openmap, page):
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(".panel.right").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_text("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()
expect(page.locator(".umap-circle-icon")).to_be_visible() expect(page.locator(".umap-circle-icon")).to_be_visible()
@ -165,14 +165,14 @@ def test_can_restore_version(live_server, openmap, page, datalayer):
marker = page.locator(".leaflet-marker-icon") marker = page.locator(".leaflet-marker-icon")
expect(marker).to_have_class(re.compile(".*umap-ball-icon.*")) expect(marker).to_have_class(re.compile(".*umap-ball-icon.*"))
marker.click(modifiers=["Shift"]) marker.click(modifiers=["Shift"])
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator("#umap-feature-shape-properties").get_by_text("Default").click() page.locator("#umap-feature-shape-properties").get_by_text("Default").click()
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()
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(".panel.right").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_text("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()
expect(marker).to_have_class(re.compile(".*umap-ball-icon.*")) expect(marker).to_have_class(re.compile(".*umap-ball-icon.*"))
@ -182,4 +182,4 @@ def test_can_edit_layer_on_ctrl_shift_click(live_server, openmap, page, datalaye
modifier = "Meta" if platform.system() == "Darwin" else "Control" modifier = "Meta" if platform.system() == "Darwin" else "Control"
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"]) page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"])
expect(page.get_by_role("heading", name="Layer properties")).to_be_visible() expect(page.get_by_text("Layer properties")).to_be_visible()

View file

@ -58,7 +58,7 @@ def test_zoomcontrol_impacts_ui(live_server, page, tilelayer):
expect(zoom_out).to_be_visible() expect(zoom_out).to_be_visible()
# Hide them # Hide them
page.get_by_role("heading", name="User interface options").click() page.get_by_text("User interface options").click()
hide_zoom_controls = ( hide_zoom_controls = (
page.locator("div") page.locator("div")
.filter(has_text=re.compile(r"^Display the zoom control")) .filter(has_text=re.compile(r"^Display the zoom control"))
@ -90,7 +90,7 @@ def test_map_color_impacts_data(live_server, page, tilelayer):
expect(marker_pane_p1).to_have_count(1) expect(marker_pane_p1).to_have_count(1)
# Change the default color # Change the default color
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator("#umap-feature-shape-properties").get_by_text("define").first.click() page.locator("#umap-feature-shape-properties").get_by_text("define").first.click()
page.get_by_title("Lime", exact=True).click() page.get_by_title("Lime", exact=True).click()
@ -108,7 +108,7 @@ def test_limitbounds_impacts_ui(live_server, page, tilelayer):
expect(gear_icon).to_be_visible() expect(gear_icon).to_be_visible()
gear_icon.click() gear_icon.click()
page.get_by_role("heading", name="Limit bounds").click() page.get_by_text("Limit bounds").click()
default_zoom_url = f"{live_server.url}/en/map/new/#5/51.110/7.053" default_zoom_url = f"{live_server.url}/en/map/new/#5/51.110/7.053"
page.goto(default_zoom_url) page.goto(default_zoom_url)
page.get_by_role("button", name="Use current bounds").click() page.get_by_role("button", name="Use current bounds").click()
@ -183,7 +183,7 @@ def test_sortkey_impacts_datalayerindex(map, live_server, page):
# Change the default sortkey to be "key" # Change the default sortkey to be "key"
page.get_by_role("button", name="Edit").click() page.get_by_role("button", name="Edit").click()
page.get_by_role("link", name="Map advanced properties").click() page.get_by_role("link", name="Map advanced properties").click()
page.get_by_role("heading", name="Default properties").click() page.get_by_text("Default properties").click()
# Click "define" # Click "define"
page.locator(".panel .umap-field-sortKey .define").click() page.locator(".panel .umap-field-sortKey .define").click()

View file

@ -36,7 +36,7 @@ def test_can_edit_on_shift_click(live_server, openmap, page, datalayer):
modifier = "Meta" if platform.system() == "Darwin" else "Control" modifier = "Meta" if platform.system() == "Darwin" else "Control"
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"]) page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"])
expect(page.get_by_role("heading", name="Layer properties")).to_be_visible() expect(page.get_by_text("Layer properties")).to_be_visible()
def test_marker_style_should_have_precedence(live_server, openmap, page, bootstrap): def test_marker_style_should_have_precedence(live_server, openmap, page, bootstrap):
@ -45,7 +45,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(".panel").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_text("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(
"background-color", "rgb(0, 0, 139)" "background-color", "rgb(0, 0, 139)"
@ -57,7 +57,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Now change at marker level, it should take precedence # Now change at marker level, it should take precedence
page.locator(".leaflet-marker-icon").click(modifiers=["Shift"]) page.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator("#umap-feature-shape-properties").get_by_text("define").first.click() page.locator("#umap-feature-shape-properties").get_by_text("define").first.click()
page.get_by_title("GoldenRod", exact=True).click() page.get_by_title("GoldenRod", exact=True).click()
expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css( expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css(
@ -67,7 +67,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(".panel").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_text("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()
expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css( expect(page.locator(".leaflet-marker-icon .icon_container")).to_have_css(
@ -87,12 +87,12 @@ def test_should_update_open_popup_on_edit(live_server, openmap, page, bootstrap)
expect(page.locator(".umap-icon-active")).to_be_hidden() expect(page.locator(".umap-icon-active")).to_be_hidden()
page.locator(".leaflet-marker-icon").click() page.locator(".leaflet-marker-icon").click()
expect(page.locator(".leaflet-popup-content-wrapper")).to_be_visible() expect(page.locator(".leaflet-popup-content-wrapper")).to_be_visible()
expect(page.get_by_role("heading", name="test marker")).to_be_visible() expect(page.get_by_text("test marker")).to_be_visible()
expect(page.get_by_text("Some description")).to_be_visible() expect(page.get_by_text("Some description")).to_be_visible()
page.get_by_role("button", name="Edit").click() page.get_by_role("button", name="Edit").click()
page.locator(".leaflet-marker-icon").click(modifiers=["Shift"]) page.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
page.locator('input[name="name"]').fill("test marker edited") page.locator('input[name="name"]').fill("test marker edited")
expect(page.get_by_role("heading", name="test marker edited")).to_be_visible() expect(page.get_by_text("test marker edited")).to_be_visible()
def test_should_follow_datalayer_style_when_changing_datalayer( def test_should_follow_datalayer_style_when_changing_datalayer(

View file

@ -50,7 +50,7 @@ def test_can_edit_on_shift_click(live_server, openmap, page, datalayer):
modifier = "Meta" if platform.system() == "Darwin" else "Control" modifier = "Meta" if platform.system() == "Darwin" else "Control"
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"]) page.locator(".leaflet-marker-icon").click(modifiers=[modifier, "Shift"])
expect(page.get_by_role("heading", name="Layer properties")).to_be_visible() expect(page.get_by_text("Layer properties")).to_be_visible()
def test_marker_style_should_have_precedence(live_server, openmap, page, bootstrap): def test_marker_style_should_have_precedence(live_server, openmap, page, bootstrap):
@ -59,7 +59,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(".panel").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_text("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)
page.get_by_title("DarkRed").first.click() page.get_by_title("DarkRed").first.click()
@ -67,7 +67,7 @@ def test_marker_style_should_have_precedence(live_server, openmap, page, bootstr
# Now change at polygon level, it should take precedence # Now change at polygon level, it should take precedence
page.locator("path").click(modifiers=["Shift"]) page.locator("path").click(modifiers=["Shift"])
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator("#umap-feature-shape-properties").get_by_text("define").first.click() page.locator("#umap-feature-shape-properties").get_by_text("define").first.click()
page.get_by_title("GoldenRod", exact=True).first.click() page.get_by_title("GoldenRod", exact=True).first.click()
expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count( expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count(
@ -77,7 +77,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(".panel").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_text("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()
expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count( expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count(
@ -99,7 +99,7 @@ def test_can_remove_stroke(live_server, openmap, page, bootstrap):
) )
page.locator("path").click() page.locator("path").click()
page.get_by_role("link", name="Toggle edit mode").click() page.get_by_role("link", name="Toggle edit mode").click()
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator(".umap-field-stroke .define").first.click() page.locator(".umap-field-stroke .define").first.click()
page.locator(".umap-field-stroke label").first.click() page.locator(".umap-field-stroke label").first.click()
expect(page.locator(".leaflet-overlay-pane path[stroke='DarkBlue']")).to_have_count( expect(page.locator(".leaflet-overlay-pane path[stroke='DarkBlue']")).to_have_count(
@ -111,7 +111,7 @@ def test_can_remove_stroke(live_server, openmap, page, bootstrap):
def test_should_reset_style_on_cancel(live_server, openmap, page, bootstrap): def test_should_reset_style_on_cancel(live_server, openmap, page, bootstrap):
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
page.locator("path").click(modifiers=["Shift"]) page.locator("path").click(modifiers=["Shift"])
page.get_by_role("heading", name="Shape properties").click() page.get_by_text("Shape properties").click()
page.locator("#umap-feature-shape-properties").get_by_text("define").first.click() page.locator("#umap-feature-shape-properties").get_by_text("define").first.click()
page.get_by_title("GoldenRod", exact=True).first.click() page.get_by_title("GoldenRod", exact=True).first.click()
expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count( expect(page.locator(".leaflet-overlay-pane path[fill='GoldenRod']")).to_have_count(