mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
test(sync): Marker drag-n-drop and delete are synced
This commit is contained in:
parent
80f7efc810
commit
5feabd4c14
2 changed files with 32 additions and 4 deletions
|
@ -37,16 +37,18 @@ def login(context, settings, live_server):
|
||||||
return do_login
|
return do_login
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture()
|
||||||
def websocket_server(xprocess):
|
def websocket_server(xprocess):
|
||||||
class Starter(ProcessStarter):
|
class Starter(ProcessStarter):
|
||||||
settings_path = (
|
settings_path = (
|
||||||
(Path(__file__).parent.parent / "settings.py").absolute().as_posix()
|
(Path(__file__).parent.parent / "settings.py").absolute().as_posix()
|
||||||
)
|
)
|
||||||
os.environ["UMAP_SETTINGS"] = settings_path
|
os.environ["UMAP_SETTINGS"] = settings_path
|
||||||
|
# env = {"UMAP_SETTINGS": settings_path}
|
||||||
pattern = "Waiting for connections*"
|
pattern = "Waiting for connections*"
|
||||||
args = ["python", "-m", "umap.ws"]
|
args = ["python", "-m", "umap.ws"]
|
||||||
timeout = 5
|
timeout = 3
|
||||||
|
terminate_on_interrupt = True
|
||||||
|
|
||||||
logfile = xprocess.ensure("websocket_server", Starter)
|
logfile = xprocess.ensure("websocket_server", Starter)
|
||||||
print(logfile)
|
print(logfile)
|
||||||
|
|
|
@ -31,13 +31,39 @@ def test_websocket_connection_can_sync_markers(
|
||||||
expect(a_marker_pane).to_have_count(0)
|
expect(a_marker_pane).to_have_count(0)
|
||||||
expect(b_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")
|
a_create_marker = peerA.get_by_title("Draw a marker")
|
||||||
expect(a_create_marker).to_be_visible()
|
expect(a_create_marker).to_be_visible()
|
||||||
a_create_marker.click()
|
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 = peerA.locator("#map")
|
||||||
a_map_el.click(position={"x": 220, "y": 220})
|
a_map_el.click(position={"x": 220, "y": 220})
|
||||||
expect(a_marker_pane).to_have_count(1)
|
expect(a_marker_pane).to_have_count(1)
|
||||||
expect(b_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)
|
||||||
|
|
Loading…
Reference in a new issue