diff options
Diffstat (limited to 'packages/meshbay-cli/tests/test_e2e_local.py')
| -rw-r--r-- | packages/meshbay-cli/tests/test_e2e_local.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/packages/meshbay-cli/tests/test_e2e_local.py b/packages/meshbay-cli/tests/test_e2e_local.py index 9cac392..988fb38 100644 --- a/packages/meshbay-cli/tests/test_e2e_local.py +++ b/packages/meshbay-cli/tests/test_e2e_local.py @@ -529,12 +529,14 @@ def test_a_machine_with_no_identity_there_is_linked_as_a_device(world): async def test_the_interactive_mode_against_the_real_node(world, monkeypatch, tmp_path): - """The panes, opened on a real group, and F5 bringing a file back.""" + """The panes, opened on a real group: F5 bringing a file back, F5 sending one, + and Delete taking that one away again.""" from meshbay_cli import __main__ as main_module from meshbay_cli.commands.context import Context from meshbay_cli.tui.app import MeshBayApp - from meshbay_cli.tui.panes import RemotePane + from meshbay_cli.tui.panes import LocalPane, RemotePane from meshbay_cli.tui.screens import MainScreen + from meshbay_cli.tui.widgets import Choice # Browser access off, whichever test ran before: this machine must be linked. await world["app"].withdraw_bundle() @@ -585,6 +587,26 @@ async def test_the_interactive_mode_against_the_real_node(world, monkeypatch, tm await until(pilot, lambda: (tmp_path / "notes.txt").exists() and (tmp_path / "notes.txt").read_text() == "hello\n") + # Sent from the left, then deleted from the right: it was this + # account's upload, so the node lets it go, from its disk too. + (tmp_path / "tui-upload.txt").write_text("sent from the panes\n") + local = app.screen.query_one(LocalPane) + local.action_refresh() + await until(pilot, lambda: "tui-upload.txt" in names(local)) + local.table.move_cursor(row=names(local).index("tui-upload.txt")) + local.table.focus() + await pilot.press("f5") + await until(pilot, lambda: "tui-upload.txt" in names(remote)) + assert (world["share"] / "tui-upload.txt").exists() + remote.table.move_cursor(row=names(remote).index("tui-upload.txt")) + remote.table.focus() + await pilot.press("delete") + await until(pilot, lambda: isinstance(app.screen, Choice)) + await pilot.click("#choice-delete") + await until(pilot, lambda: "tui-upload.txt" not in names(remote)) + assert not (world["share"] / "tui-upload.txt").exists() + assert (world["share"] / "notes.txt").exists() + # ── The application's half of linking, in a real Chrome ────────────────────── # @@ -833,6 +855,24 @@ def test_a_member_joins_links_devices_shares_with_browsers_and_leaves(world): assert r.returncode == 0, r.stderr assert bob(world, "bob3", "ls", group).returncode == 5 # a stranger again + # rm: what bob uploaded, from another of his machines too; nothing of the + # owner's, whose share bob did not upload. + up = world["root"] / "bob-upload.txt" + up.write_text("from bob\n") + assert bob(world, "bob1", "put", str(up), f"{group}/share").returncode == 0 + deadline = time.monotonic() + 30 # indexed once the node has written it + while "bob-upload.txt" not in bob(world, "bob1", "ls", f"{group}/share").stdout: + assert time.monotonic() < deadline, "the upload never reached the index" + time.sleep(1) + r = bob(world, "bob1", "rm", f"{group}/share/bob-upload.txt") + assert r.returncode == 1 and "--yes" in r.stderr # no terminal to ask on + r = bob(world, "bob1", "rm", "--yes", f"{group}/share/notes.txt") + assert r.returncode == 8 and "did not upload" in r.stderr, r.stderr + r = bob(world, "bob2", "rm", "--yes", f"{group}/share/bob-upload.txt") + assert r.returncode == 0, r.stderr + assert "bob-upload.txt" not in bob(world, "bob1", "ls", f"{group}/share").stdout + assert (world["share"] / "notes.txt").exists() + # Leaving: asked first, then the group is gone from the account. assert bob(world, "bob1", "leave", group).returncode == 1 r = bob(world, "bob1", "leave", "--yes", group) |