From 5feabd4c14fa2993b7d06a06227276aa94705bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 15 May 2024 11:29:35 +0200 Subject: [PATCH] test(sync): Marker drag-n-drop and delete are synced --- umap/tests/integration/conftest.py | 6 ++-- umap/tests/integration/test_websocket_sync.py | 30 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/umap/tests/integration/conftest.py b/umap/tests/integration/conftest.py index 756cc44d..386e7a97 100644 --- a/umap/tests/integration/conftest.py +++ b/umap/tests/integration/conftest.py @@ -37,16 +37,18 @@ def login(context, settings, live_server): return do_login -@pytest.fixture(scope="session") +@pytest.fixture() def websocket_server(xprocess): class Starter(ProcessStarter): settings_path = ( (Path(__file__).parent.parent / "settings.py").absolute().as_posix() ) os.environ["UMAP_SETTINGS"] = settings_path + # env = {"UMAP_SETTINGS": settings_path} pattern = "Waiting for connections*" args = ["python", "-m", "umap.ws"] - timeout = 5 + timeout = 3 + terminate_on_interrupt = True logfile = xprocess.ensure("websocket_server", Starter) print(logfile) diff --git a/umap/tests/integration/test_websocket_sync.py b/umap/tests/integration/test_websocket_sync.py index 0d66b269..53922303 100644 --- a/umap/tests/integration/test_websocket_sync.py +++ b/umap/tests/integration/test_websocket_sync.py @@ -31,13 +31,39 @@ def test_websocket_connection_can_sync_markers( expect(a_marker_pane).to_have_count(0) expect(b_marker_pane).to_have_count(0) - # Click on the Draw a marker button on a new map. + # Add a marker from peer A a_create_marker = peerA.get_by_title("Draw a marker") expect(a_create_marker).to_be_visible() a_create_marker.click() - # Click on the map, it will place a marker at the given position. a_map_el = peerA.locator("#map") a_map_el.click(position={"x": 220, "y": 220}) expect(a_marker_pane).to_have_count(1) expect(b_marker_pane).to_have_count(1) + + # Add a second marker from peer B + b_create_marker = peerB.get_by_title("Draw a marker") + expect(b_create_marker).to_be_visible() + b_create_marker.click() + + b_map_el = peerB.locator("#map") + b_map_el.click(position={"x": 225, "y": 225}) + expect(a_marker_pane).to_have_count(2) + expect(b_marker_pane).to_have_count(2) + + b_first_marker = peerB.locator("div:nth-child(4) > div:nth-child(2)").first + a_first_marker = peerA.locator("div:nth-child(4) > div:nth-child(2)").first + + # Drag a marker on peer B and check that it moved on peer A + a_first_marker.bounding_box() == b_first_marker.bounding_box() + b_old_bbox = b_first_marker.bounding_box() + b_first_marker.drag_to(b_map_el, target_position={"x": 250, "y": 250}) + + assert b_old_bbox is not b_first_marker.bounding_box() + a_first_marker.bounding_box() == b_first_marker.bounding_box() + + a_first_marker.click(button="right") + peerA.on("dialog", lambda dialog: dialog.accept()) + peerA.get_by_role("link", name="Delete this feature").click() + expect(a_marker_pane).to_have_count(1) + expect(b_marker_pane).to_have_count(1)