Use stable profile for spaces created from private context
This commit is contained in:
@@ -190,7 +190,12 @@ impl BrowserCore {
|
||||
accent_hex: u32,
|
||||
) -> Result<SpaceId, CoreError> {
|
||||
let sort_key = self.next_space_sort_key();
|
||||
let space = Space::new(name, icon, accent_hex, self.active_profile_id.clone(), sort_key);
|
||||
let default_profile_id = if self.active_profile()?.kind() == &ProfileKind::Private {
|
||||
self.active_space()?.default_profile_id().clone()
|
||||
} else {
|
||||
self.active_profile_id.clone()
|
||||
};
|
||||
let space = Space::new(name, icon, accent_hex, default_profile_id, sort_key);
|
||||
let space_id = space.id().clone();
|
||||
let default_profile_id = space.default_profile_id().clone();
|
||||
let tab = self.build_tab_for(space_id.clone(), default_profile_id, self.new_tab_url()?);
|
||||
|
||||
@@ -26,6 +26,25 @@ fn created_space_binds_current_profile_as_default() -> Result<(), Box<dyn Error>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn space_creation_from_private_profile_uses_space_default_profile() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
let default_profile_id = core.snapshot()?.active_profile_id;
|
||||
|
||||
core.create_profile("Private", 0x807d72, ProfileKind::Private)?;
|
||||
let research_space_id = core.create_space("Research", "R", 0x9fc9a2)?;
|
||||
let snapshot = core.snapshot()?;
|
||||
let Some(research_space) =
|
||||
snapshot.spaces.iter().find(|space| space.id() == &research_space_id)
|
||||
else {
|
||||
return Err("missing research space".into());
|
||||
};
|
||||
|
||||
assert_eq!(research_space.default_profile_id(), &default_profile_id);
|
||||
assert_eq!(snapshot.active_profile_id, default_profile_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn created_space_records_creation_timestamps() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
Reference in New Issue
Block a user