Fix tests
This commit is contained in:
parent
c9f767b6de
commit
e5c616b49c
6 changed files with 58 additions and 50 deletions
|
@ -62,38 +62,46 @@ class MapFactory(factory.django.DjangoModelFactory):
|
|||
name = "test map"
|
||||
slug = "test-map"
|
||||
center = DEFAULT_CENTER
|
||||
settings = {
|
||||
"geometry": {
|
||||
"coordinates": [13.447265624999998, 48.94415123418794],
|
||||
"type": "Point",
|
||||
},
|
||||
"properties": {
|
||||
"datalayersControl": True,
|
||||
"description": "Which is just the Danube, at the end",
|
||||
"displayCaptionOnLoad": False,
|
||||
"displayDataBrowserOnLoad": False,
|
||||
"displayPopupFooter": False,
|
||||
"licence": "",
|
||||
"miniMap": False,
|
||||
"moreControl": True,
|
||||
"name": "Cruising on the Donau",
|
||||
"scaleControl": True,
|
||||
"tilelayer": {
|
||||
"attribution": "\xa9 OSM Contributors",
|
||||
"maxZoom": 18,
|
||||
"minZoom": 0,
|
||||
"url_template": "http://{s}.osm.fr/{z}/{x}/{y}.png",
|
||||
settings = factory.Dict(
|
||||
{
|
||||
"geometry": {
|
||||
"coordinates": [13.447265624999998, 48.94415123418794],
|
||||
"type": "Point",
|
||||
},
|
||||
"tilelayersControl": True,
|
||||
"zoom": 7,
|
||||
"zoomControl": True,
|
||||
},
|
||||
"type": "Feature",
|
||||
}
|
||||
"properties": {
|
||||
"datalayersControl": True,
|
||||
"description": "Which is just the Danube, at the end",
|
||||
"displayCaptionOnLoad": False,
|
||||
"displayDataBrowserOnLoad": False,
|
||||
"displayPopupFooter": False,
|
||||
"licence": "",
|
||||
"miniMap": False,
|
||||
"moreControl": True,
|
||||
"name": "Cruising on the Donau",
|
||||
"scaleControl": True,
|
||||
"tilelayer": {
|
||||
"attribution": "\xa9 OSM Contributors",
|
||||
"maxZoom": 18,
|
||||
"minZoom": 0,
|
||||
"url_template": "http://{s}.osm.fr/{z}/{x}/{y}.png",
|
||||
},
|
||||
"tilelayersControl": True,
|
||||
"zoom": 7,
|
||||
"zoomControl": True,
|
||||
},
|
||||
"type": "Feature",
|
||||
}
|
||||
)
|
||||
|
||||
licence = factory.SubFactory(LicenceFactory)
|
||||
owner = factory.SubFactory(UserFactory)
|
||||
|
||||
@classmethod
|
||||
def _adjust_kwargs(cls, **kwargs):
|
||||
# Make sure there is no persistency
|
||||
kwargs["settings"] = copy.deepcopy(kwargs["settings"])
|
||||
return kwargs
|
||||
|
||||
class Meta:
|
||||
model = Map
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ def test_map_load_with_owner(anonymap, live_server, owner_session):
|
|||
owner_session.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
|
||||
map_el = owner_session.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = owner_session.get_by_role("link", name="Edit")
|
||||
enable = owner_session.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_visible()
|
||||
enable.click()
|
||||
disable = owner_session.get_by_role("link", name="Disable editing")
|
||||
disable = owner_session.get_by_role("button", name="View")
|
||||
expect(disable).to_be_visible()
|
||||
save = owner_session.get_by_title("Save current edits (Ctrl+S)")
|
||||
save = owner_session.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
add_marker = owner_session.get_by_title("Draw a marker")
|
||||
expect(add_marker).to_be_visible()
|
||||
|
@ -55,12 +55,12 @@ def test_map_load_with_anonymous_but_editable_layer(
|
|||
page.goto(f"{live_server.url}{anonymap.get_absolute_url()}")
|
||||
map_el = page.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = page.get_by_role("link", name="Edit")
|
||||
enable = page.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_visible()
|
||||
enable.click()
|
||||
disable = page.get_by_role("link", name="Disable editing")
|
||||
disable = page.get_by_role("button", name="View")
|
||||
expect(disable).to_be_visible()
|
||||
save = page.get_by_title("Save current edits (Ctrl+S)")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
add_marker = page.get_by_title("Draw a marker")
|
||||
expect(add_marker).to_be_visible()
|
||||
|
@ -126,7 +126,7 @@ def test_anonymous_can_add_marker_on_editable_layer(
|
|||
|
||||
def test_can_change_perms_after_create(tilelayer, live_server, page):
|
||||
page.goto(f"{live_server.url}/en/map/new")
|
||||
save = page.get_by_title("Save current edits")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
save.click()
|
||||
sleep(1) # Let save ajax go back
|
||||
|
|
|
@ -9,7 +9,7 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
def test_umap_export(map, live_server, datalayer, page):
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}?share")
|
||||
button = page.locator("a").filter(has_text="Download data")
|
||||
button = page.get_by_role("button", name="Download data")
|
||||
expect(button).to_be_visible()
|
||||
with page.expect_download() as download_info:
|
||||
button.click()
|
||||
|
@ -86,7 +86,7 @@ def test_umap_export(map, live_server, datalayer, page):
|
|||
|
||||
def test_csv_export(map, live_server, datalayer, page):
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}?share")
|
||||
button = page.locator("a").filter(has_text="Download data")
|
||||
button = page.get_by_role("button", name="Download data")
|
||||
expect(button).to_be_visible()
|
||||
page.locator('select[name="format"]').select_option("csv")
|
||||
with page.expect_download() as download_info:
|
||||
|
|
|
@ -16,7 +16,7 @@ def test_umap_import(live_server, datalayer, page):
|
|||
file_chooser = fc_info.value
|
||||
path = Path(__file__).parent.parent / "fixtures/display_on_load.umap"
|
||||
file_chooser.set_files(path)
|
||||
button = page.get_by_role("button", name="Import")
|
||||
button = page.get_by_role("button", name="Import", exact=True)
|
||||
expect(button).to_be_visible()
|
||||
button.click()
|
||||
layers = page.locator(".umap-browse-datalayers li")
|
||||
|
|
|
@ -39,7 +39,7 @@ def test_remote_layer_should_not_be_used_as_datalayer_for_created_features(
|
|||
}
|
||||
datalayer.save()
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
||||
toggle = page.get_by_title("See data layers")
|
||||
toggle = page.get_by_role("button", name="See data layers")
|
||||
expect(toggle).to_be_visible()
|
||||
toggle.click()
|
||||
layers = page.locator(".umap-browse-datalayers li")
|
||||
|
|
|
@ -31,12 +31,12 @@ def test_map_update_with_owner(map, live_server, login):
|
|||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
map_el = page.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = page.get_by_role("link", name="Edit")
|
||||
enable = page.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_visible()
|
||||
enable.click()
|
||||
disable = page.get_by_role("link", name="Disable editing")
|
||||
disable = page.get_by_role("button", name="View")
|
||||
expect(disable).to_be_visible()
|
||||
save = page.get_by_title("Save current edits (Ctrl+S)")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
add_marker = page.get_by_title("Draw a marker")
|
||||
expect(add_marker).to_be_visible()
|
||||
|
@ -50,7 +50,7 @@ def test_map_update_with_anonymous(map, live_server, page):
|
|||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
map_el = page.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = page.get_by_role("link", name="Edit")
|
||||
enable = page.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_hidden()
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ def test_map_update_with_anonymous_but_editable_datalayer(
|
|||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
map_el = page.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = page.get_by_role("link", name="Edit")
|
||||
enable = page.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_visible()
|
||||
enable.click()
|
||||
add_marker = page.get_by_title("Draw a marker")
|
||||
|
@ -106,12 +106,12 @@ def test_map_update_with_editor(map, live_server, login, user):
|
|||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
map_el = page.locator("#map")
|
||||
expect(map_el).to_be_visible()
|
||||
enable = page.get_by_role("link", name="Edit")
|
||||
enable = page.get_by_role("button", name="Edit")
|
||||
expect(enable).to_be_visible()
|
||||
enable.click()
|
||||
disable = page.get_by_role("link", name="Disable editing")
|
||||
disable = page.get_by_role("button", name="View")
|
||||
expect(disable).to_be_visible()
|
||||
save = page.get_by_title("Save current edits (Ctrl+S)")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
add_marker = page.get_by_title("Draw a marker")
|
||||
expect(add_marker).to_be_visible()
|
||||
|
@ -150,7 +150,7 @@ def test_owner_has_delete_map_button(map, live_server, login):
|
|||
advanced = page.get_by_text("Advanced actions")
|
||||
expect(advanced).to_be_visible()
|
||||
advanced.click()
|
||||
delete = page.get_by_role("link", name="Delete")
|
||||
delete = page.get_by_role("button", name="Delete", exact=True)
|
||||
expect(delete).to_be_visible()
|
||||
|
||||
|
||||
|
@ -181,7 +181,7 @@ def test_create(tilelayer, live_server, login, user):
|
|||
add_marker.click()
|
||||
map_el.click(position={"x": 100, "y": 100})
|
||||
expect(marker).to_have_count(1)
|
||||
save = page.get_by_title("Save current edits")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
save.click()
|
||||
sleep(1) # Let save ajax go back
|
||||
|
@ -191,7 +191,7 @@ def test_create(tilelayer, live_server, login, user):
|
|||
def test_can_change_perms_after_create(tilelayer, live_server, login, user):
|
||||
page = login(user)
|
||||
page.goto(f"{live_server.url}/en/map/new")
|
||||
save = page.get_by_title("Save current edits")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
save.click()
|
||||
sleep(1) # Let save ajax go back
|
||||
|
@ -226,7 +226,7 @@ def test_can_change_owner(map, live_server, login, user):
|
|||
input = page.locator("input.edit-owner")
|
||||
input.type(user.username)
|
||||
input.press("Tab")
|
||||
save = page.get_by_title("Save current edits")
|
||||
save = page.get_by_role("button", name="Save")
|
||||
expect(save).to_be_visible()
|
||||
save.click()
|
||||
sleep(1) # Let save ajax go
|
||||
|
|
Loading…
Reference in a new issue