fix moving of browser groups and allow to store groups into session

This commit is contained in:
2026-04-09 23:38:00 +02:00
parent eaa86e3f3d
commit c5a4218da0
3 changed files with 226 additions and 21 deletions
+58
View File
@@ -131,3 +131,61 @@ def test_group_tabs_returns_list(browser):
browser("tabs.close", {"tabId": t["id"]})
except Exception:
pass
def test_group_move_forward_swaps_adjacent_group_blocks(browser):
group_a = browser("group.open", {"name": "__move_group_a__"})
group_b = browser("group.open", {"name": "__move_group_b__"})
gid_a = group_a["id"]
gid_b = group_b["id"]
created_tab_ids = set()
try:
extra_a = browser("group.add_tab", {"group": str(gid_a), "url": "https://example.com/?group=a"})
extra_b = browser("group.add_tab", {"group": str(gid_b), "url": "https://example.com/?group=b"})
created_tab_ids.update([extra_a["tabId"], extra_b["tabId"]])
tabs_before = browser("tabs.list")
block_order_before = [
t["groupId"] for t in tabs_before
if t.get("groupId") in {gid_a, gid_b}
]
assert block_order_before
assert block_order_before[0] == gid_a
browser("group.move", {"group": str(gid_a), "forward": True})
tabs_after = browser("tabs.list")
grouped_after = [
t for t in tabs_after
if t.get("groupId") in {gid_a, gid_b}
]
assert grouped_after
assert grouped_after[0]["groupId"] == gid_b
assert grouped_after[-1]["groupId"] == gid_a
group_ids_after = {t["id"]: t["groupId"] for t in grouped_after}
for t in browser("group.tabs", {"groupId": gid_a}):
assert group_ids_after[t["id"]] == gid_a
for t in browser("group.tabs", {"groupId": gid_b}):
assert group_ids_after[t["id"]] == gid_b
finally:
for gid in (gid_a, gid_b):
try:
group_tabs = browser("group.tabs", {"groupId": gid})
except Exception:
group_tabs = []
try:
browser("group.close", {"groupId": gid})
except Exception:
pass
for t in group_tabs:
created_tab_ids.add(t["id"])
for tab_id in created_tab_ids:
try:
browser("tabs.close", {"tabId": tab_id})
except Exception:
pass