From f211a13dc2e5dd82eaba49222171d6f29d858eb5 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 30 Sep 2026 13:22:17 +0200 Subject: 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 --- packages/meshbay-hub/tests/test_transfers.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'packages/meshbay-hub/tests/test_transfers.py') 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)]) -- cgit v1.2.3