aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_transfers.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-30 13:22:17 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-30 13:22:17 +0200
commitf211a13dc2e5dd82eaba49222171d6f29d858eb5 (patch)
tree222b9d55116179e35c3013239b7f8e1120907e91 /packages/meshbay-hub/tests/test_transfers.py
parent87725dc7a2da27c2ca3b9e58af751f0e6f8c9de7 (diff)
downloadmeshbay-f211a13dc2e5dd82eaba49222171d6f29d858eb5.tar.gz
fix(hub): a downloaded file opens in a tab only under a type that runs nothing
Open is offered for PDFs, raster images, audio, video and plain text, typed from the name; HTML, SVG and the rest are not opened in the hub's origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_transfers.py')
-rw-r--r--packages/meshbay-hub/tests/test_transfers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_transfers.py b/packages/meshbay-hub/tests/test_transfers.py
index 1d0c0f0..c7a9dc5 100644
--- a/packages/meshbay-hub/tests/test_transfers.py
+++ b/packages/meshbay-hub/tests/test_transfers.py
@@ -918,3 +918,23 @@ def test_the_reason_is_translated_everywhere():
`transfers.not_pausable` in a tooltip rather than a sentence."""
for path in sorted((STATIC / "locales").glob("*.js")):
assert "'transfers.not_pausable'" in path.read_text(encoding="utf-8"), path.name
+
+
+def test_open_is_offered_only_when_the_target_says_it_can_be(tmp_path):
+ """A row whose file cannot be opened (a type that could run in the hub's
+ origin, an archive, a stream the page cannot read back) has no Open button,
+ rather than one that does nothing."""
+ result = _run("""
+const store = new TransferStore();
+const done = (openable) => store.start({
+ kind: 'download', name: 'f', total: 1,
+ prepare: async () => (openable === undefined ? {} : { openable }),
+ open: () => {},
+ run: async ({ onProgress }) => { onProgress(1, 1); },
+});
+done(false); done(true); done(undefined);
+await new Promise(r => setTimeout(r, 30));
+say(...store.list().map(it => [it.status, it.canOpen]));
+""", tmp_path)
+ assert sorted(map(tuple, result)) == sorted([
+ ("done", False), ("done", True), ("done", True)])