Add tab group close command

This commit is contained in:
2026-05-08 10:49:45 -04:00
parent a05b662fd6
commit 475be06edc
4 changed files with 88 additions and 1 deletions
+51 -1
View File
@@ -1,7 +1,7 @@
use std::error::Error;
use ely_browser_core::{BrowserCore, CoreError, InitialBrowserConfig};
use ely_domain::{CommandIntent, MAX_SPLIT_PANES, SplitAxis, TabState, UrlText};
use ely_domain::{ArchiveSource, CommandIntent, MAX_SPLIT_PANES, SplitAxis, TabState, UrlText};
#[test]
fn group_active_tab_creates_visible_space_group() -> Result<(), Box<dyn Error>> {
@@ -203,6 +203,56 @@ fn sleep_tab_group_command_preserves_query_without_active_group() -> Result<(),
Ok(())
}
#[test]
fn close_tab_group_command_archives_active_group_tabs() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
let ungrouped_tab_id = core.open_tab(UrlText::parse("https://servo.org")?);
let first_group_tab_id = core.open_tab(UrlText::parse("https://example.com/a")?);
core.group_active_tab("Docs")?;
let second_group_tab_id = core.open_tab(UrlText::parse("https://example.com/b")?);
core.group_active_tab("Docs")?;
core.set_command_query(">close-tab-group");
let intent = core.submit_command()?;
let snapshot = core.snapshot()?;
let archived_tab_ids =
snapshot.archived_tabs.iter().map(|archived| archived.tab().id()).collect::<Vec<_>>();
assert_eq!(intent, Some(CommandIntent::Command("close-tab-group".to_string())));
assert_eq!(snapshot.command_query, "");
assert!(snapshot.tab_groups.is_empty());
assert!(snapshot.tabs.iter().any(|tab| tab.id() == &snapshot.active_tab_id));
assert_ne!(snapshot.active_tab_id, first_group_tab_id);
assert_ne!(snapshot.active_tab_id, second_group_tab_id);
assert_eq!(tab_state(&snapshot, &ungrouped_tab_id), Some(&TabState::Ready));
assert!(archived_tab_ids.contains(&&first_group_tab_id));
assert!(archived_tab_ids.contains(&&second_group_tab_id));
assert!(
snapshot
.archived_tabs
.iter()
.all(|archived| archived.source() == &ArchiveSource::ManualClose)
);
assert!(snapshot.archived_tabs.iter().all(|archived| archived.tab().group_id().is_none()));
Ok(())
}
#[test]
fn close_tab_group_command_preserves_query_without_active_group() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
let active_tab_id = core.open_tab(UrlText::parse("https://example.com")?);
core.set_command_query(">close-tab-group");
let intent = core.submit_command()?;
let snapshot = core.snapshot()?;
assert_eq!(intent, Some(CommandIntent::Command("close-tab-group".to_string())));
assert_eq!(snapshot.command_query, ">close-tab-group");
assert_eq!(snapshot.active_tab_id, active_tab_id);
assert!(snapshot.archived_tabs.is_empty());
Ok(())
}
#[test]
fn tab_group_collapse_commands_update_active_group() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;