From 2410e71006cbf21b24db9e1de8afee732a5c5785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 8 May 2026 11:39:16 -0400 Subject: [PATCH] Add tab group archive command coverage --- .../tests/tab_group_archive_commands.rs | 58 +++++++++++++++++++ docs/ui-shell.md | 14 +++++ 2 files changed, 72 insertions(+) create mode 100644 crates/ely_browser_core/tests/tab_group_archive_commands.rs diff --git a/crates/ely_browser_core/tests/tab_group_archive_commands.rs b/crates/ely_browser_core/tests/tab_group_archive_commands.rs new file mode 100644 index 0000000..c234d6d --- /dev/null +++ b/crates/ely_browser_core/tests/tab_group_archive_commands.rs @@ -0,0 +1,58 @@ +use std::error::Error; + +use ely_browser_core::{BrowserCore, InitialBrowserConfig}; +use ely_domain::{ArchiveSource, CommandIntent, TabState, UrlText}; + +#[test] +fn archive_tab_group_command_archives_active_group_tabs() -> Result<(), Box> { + 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(">archive-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::>(); + + assert_eq!(intent, Some(CommandIntent::Command("archive-tab-group".to_string()))); + assert_eq!(snapshot.command_query, ""); + assert!(snapshot.tab_groups.is_empty()); + 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 archive_tab_group_command_preserves_query_without_active_group() -> Result<(), Box> { + let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?; + let active_tab_id = core.open_tab(UrlText::parse("https://example.com")?); + + core.set_command_query(">archive-tab-group"); + let intent = core.submit_command()?; + let snapshot = core.snapshot()?; + + assert_eq!(intent, Some(CommandIntent::Command("archive-tab-group".to_string()))); + assert_eq!(snapshot.command_query, ">archive-tab-group"); + assert_eq!(snapshot.active_tab_id, active_tab_id); + assert!(snapshot.archived_tabs.is_empty()); + Ok(()) +} + +fn tab_state<'a>( + snapshot: &'a ely_browser_core::BrowserSnapshot, + tab_id: &ely_domain::TabId, +) -> Option<&'a TabState> { + snapshot.tabs.iter().find(|tab| tab.id() == tab_id).map(|tab| tab.state()) +} diff --git a/docs/ui-shell.md b/docs/ui-shell.md index 129ca27..1a24dfd 100644 --- a/docs/ui-shell.md +++ b/docs/ui-shell.md @@ -180,3 +180,17 @@ Group close archives every tab in the active group and removes the empty group r │ example.com │ │ └──────────────────────────────┴───────────────────────────────────────────────┘ ``` + +Group archive uses the explicit archive command for the same active group flow: + +```text +┌──────────────────────────────────────────────────────────────────────────────┐ +│ ELY Browser [ >archive-tab-group.......................... ] [pin] [*] [+] │ +├──────────────────────────────┬───────────────────────────────────────────────┤ +│ Tabs │ servo.org │ +│ New Tab │ https://servo.org │ +│ Archive │ Docs tabs archived as ManualClose │ +│ example.com │ │ +│ example.com │ │ +└──────────────────────────────┴───────────────────────────────────────────────┘ +```