Skip to content

Commit

Permalink
Add integration test for textarea import
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Dec 5, 2023
1 parent c62c327 commit 50da2c0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion umap/tests/integration/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pytestmark = pytest.mark.django_db


def test_umap_import(live_server, datalayer, page):
def test_umap_import_from_file(live_server, datalayer, page):
page.goto(f"{live_server.url}/map/new/")
button = page.get_by_title("Import data (Ctrl+I)")
expect(button).to_be_visible()
Expand All @@ -23,3 +23,27 @@ def test_umap_import(live_server, datalayer, page):
expect(layers).to_have_count(3)
nonloaded = page.locator(".umap-browse-datalayers li.off")
expect(nonloaded).to_have_count(1)


def test_umap_import_geojson_from_textarea(live_server, datalayer, page):
page.goto(f"{live_server.url}/map/new/")
layers = page.locator(".umap-browse-datalayers li")
markers = page.locator(".leaflet-marker-icon")
paths = page.locator("path")
expect(markers).to_have_count(0)
expect(paths).to_have_count(0)
expect(layers).to_have_count(1)
button = page.get_by_title("Import data (Ctrl+I)")
expect(button).to_be_visible()
button.click()
textarea = page.locator(".umap-upload textarea")
path = Path(__file__).parent.parent / "fixtures/test_upload_data.json"
textarea.fill(path.read_text())
page.locator('select[name="format"]').select_option("geojson")
button = page.get_by_role("button", name="Import", exact=True)
expect(button).to_be_visible()
button.click()
# No layer has been created
expect(layers).to_have_count(1)
expect(markers).to_have_count(2)
expect(paths).to_have_count(3)

0 comments on commit 50da2c0

Please sign in to comment.