Add client-side user setting for agent commit attribution (#9323)

This commit is contained in:
lucieleblanc
2026-04-28 18:33:15 -04:00
committed by GitHub
parent 929944198c
commit 389716a905
11 changed files with 582 additions and 27 deletions
+93
View File
@@ -0,0 +1,93 @@
use super::{derive_agent_attribution_toggle_state, AgentAttributionToggleState};
use crate::workspaces::workspace::AdminEnablementSetting;
#[test]
fn respect_user_setting_returns_user_pref_unlocked() {
let state = derive_agent_attribution_toggle_state(
&AdminEnablementSetting::RespectUserSetting,
true,
true,
);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: true,
is_forced_by_org: false,
is_disabled: false,
}
);
}
#[test]
fn respect_user_setting_with_user_off_returns_unchecked_unlocked() {
let state = derive_agent_attribution_toggle_state(
&AdminEnablementSetting::RespectUserSetting,
false,
true,
);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: false,
is_forced_by_org: false,
is_disabled: false,
}
);
}
#[test]
fn team_enable_locks_toggle_on_regardless_of_user_pref() {
let state = derive_agent_attribution_toggle_state(&AdminEnablementSetting::Enable, false, true);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: true,
is_forced_by_org: true,
is_disabled: true,
}
);
}
#[test]
fn team_disable_locks_toggle_off_regardless_of_user_pref() {
let state = derive_agent_attribution_toggle_state(&AdminEnablementSetting::Disable, true, true);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: false,
is_forced_by_org: true,
is_disabled: true,
}
);
}
#[test]
fn ai_globally_disabled_marks_toggle_disabled_but_not_forced() {
let state = derive_agent_attribution_toggle_state(
&AdminEnablementSetting::RespectUserSetting,
true,
false,
);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: true,
is_forced_by_org: false,
is_disabled: true,
}
);
}
#[test]
fn team_force_takes_precedence_over_global_ai_disabled() {
let state =
derive_agent_attribution_toggle_state(&AdminEnablementSetting::Enable, false, false);
assert_eq!(
state,
AgentAttributionToggleState {
is_enabled: true,
is_forced_by_org: true,
is_disabled: true,
}
);
}