Restore archived tabs from sidebar
This commit is contained in:
@@ -73,6 +73,40 @@ fn restores_last_archived_tab() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restores_archived_tab_by_id() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
let example_tab_id = core.open_tab(UrlText::parse("https://example.com")?);
|
||||
let servo_tab_id = core.open_tab(UrlText::parse("https://servo.org")?);
|
||||
|
||||
core.close_active_tab()?;
|
||||
core.select_tab(&example_tab_id)?;
|
||||
core.close_active_tab()?;
|
||||
|
||||
let restored_tab_id = core.restore_archived_tab(&servo_tab_id)?;
|
||||
let snapshot = core.snapshot()?;
|
||||
|
||||
assert_eq!(restored_tab_id, servo_tab_id);
|
||||
assert_eq!(snapshot.active_tab_id, servo_tab_id);
|
||||
assert_eq!(snapshot.archived_tabs.len(), 1);
|
||||
assert_eq!(snapshot.archived_tabs[0].tab().id(), &example_tab_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restore_archived_tab_by_id_returns_error_for_open_tab() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
let active_tab_id = core.active_tab()?.id().clone();
|
||||
|
||||
let error = match core.restore_archived_tab(&active_tab_id) {
|
||||
Err(error) => error,
|
||||
Ok(_) => return Err("restore should require an archived tab id".into()),
|
||||
};
|
||||
|
||||
assert_eq!(error, CoreError::TabNotFound { id: active_tab_id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restores_matching_archived_tab() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
Reference in New Issue
Block a user