Add profile sync policy controls

This commit is contained in:
2026-05-08 03:44:36 -04:00
parent 38a847c27e
commit ada0a82da8
6 changed files with 139 additions and 10 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
use ely_domain::{DownloadPolicy, Profile, ProfileId, ProfileKind, TabId};
use ely_domain::{DownloadPolicy, Profile, ProfileId, ProfileKind, ProfileSyncPolicy, TabId};
use crate::CoreError;
@@ -89,4 +89,19 @@ impl BrowserCore {
let profile_id = self.active_profile_id.clone();
self.set_profile_download_policy(&profile_id, download_policy)
}
pub fn set_profile_sync_policy(
&mut self,
profile_id: &ProfileId,
sync_policy: ProfileSyncPolicy,
) -> Result<(), CoreError> {
let profile = self
.profiles
.iter_mut()
.find(|profile| profile.id() == profile_id)
.ok_or_else(|| CoreError::ProfileNotFound { id: profile_id.clone() })?;
profile.set_sync_policy(sync_policy);
Ok(())
}
}
+25 -1
View File
@@ -1,7 +1,7 @@
use std::error::Error;
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
use ely_domain::{CommandIntent, ProfileKind, UrlText};
use ely_domain::{CommandIntent, ProfileKind, ProfileSyncPolicy, UrlText};
#[test]
fn new_private_profile_command_creates_private_profile() -> Result<(), Box<dyn Error>> {
@@ -45,3 +45,27 @@ fn private_profiles_do_not_record_history() -> Result<(), Box<dyn Error>> {
assert!(private_snapshot.history_entries.is_empty());
Ok(())
}
#[test]
fn profile_sync_policy_can_pause_one_profile() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
let default_profile_id = core.snapshot()?.active_profile_id;
let research_profile_id = core.create_profile("Research", 0x9fc9a2, ProfileKind::Standard)?;
core.set_profile_sync_policy(&research_profile_id, ProfileSyncPolicy::Paused)?;
let snapshot = core.snapshot()?;
let Some(default_profile) =
snapshot.profiles.iter().find(|profile| profile.id() == &default_profile_id)
else {
return Err("missing default profile".into());
};
let Some(research_profile) =
snapshot.profiles.iter().find(|profile| profile.id() == &research_profile_id)
else {
return Err("missing research profile".into());
};
assert_eq!(default_profile.sync_policy(), ProfileSyncPolicy::Enabled);
assert_eq!(research_profile.sync_policy(), ProfileSyncPolicy::Paused);
Ok(())
}