first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,22 +1,4 @@
|
||||
use super::{
|
||||
EnvironmentFormInitArgs, EnvironmentFormValues, GithubAuthRedirectTarget, SuggestImageState,
|
||||
UpdateEnvironmentForm, UpdateEnvironmentFormAction,
|
||||
};
|
||||
use crate::ai::ambient_agents::github_auth_notifier::GitHubAuthNotifier;
|
||||
use crate::ai::cloud_environments::GithubRepo;
|
||||
use crate::auth::AuthStateProvider;
|
||||
use crate::cloud_object::model::persistence::CloudModel;
|
||||
use crate::network::NetworkStatus;
|
||||
use crate::server::ids::{ClientId, SyncId};
|
||||
use crate::server::server_api::ServerApiProvider;
|
||||
use crate::server::{cloud_objects::update_manager::UpdateManager, sync_queue::SyncQueue};
|
||||
use crate::settings::PrivacySettings;
|
||||
use crate::settings_view::keybindings::KeybindingChangedNotifier;
|
||||
use crate::test_util::settings::initialize_settings_for_tests;
|
||||
use crate::workspaces::team::Team;
|
||||
use crate::workspaces::team_tester::TeamTesterStatus;
|
||||
use crate::workspaces::user_workspaces::UserWorkspaces;
|
||||
use crate::workspaces::workspace::Workspace;
|
||||
use url::Url;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxyui::elements::{Empty, MouseStateHandle};
|
||||
use galaxyui::platform::WindowStyle;
|
||||
@@ -24,7 +6,28 @@ use galaxyui::{
|
||||
AddSingletonModel, App, AppContext, Element, Entity, SingletonEntity, TypedActionView, View,
|
||||
WindowId,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use super::{
|
||||
EnvironmentFormCopy, EnvironmentFormInitArgs, EnvironmentFormValues, SuggestImageState,
|
||||
UpdateEnvironmentForm, UpdateEnvironmentFormAction,
|
||||
};
|
||||
use crate::ai::ambient_agents::github_auth_notifier::GitHubAuthNotifier;
|
||||
use crate::ai::ambient_agents::github_auth_url::{self, AuthSource, GithubAuthRedirectTarget};
|
||||
use crate::ai::cloud_environments::GithubRepo;
|
||||
use crate::auth::AuthStateProvider;
|
||||
use crate::cloud_object::model::persistence::CloudModel;
|
||||
use crate::network::NetworkStatus;
|
||||
use crate::server::cloud_objects::update_manager::UpdateManager;
|
||||
use crate::server::ids::{ClientId, SyncId};
|
||||
use crate::server::server_api::ServerApiProvider;
|
||||
use crate::server::sync_queue::SyncQueue;
|
||||
use crate::settings::PrivacySettings;
|
||||
use crate::settings_view::keybindings::KeybindingChangedNotifier;
|
||||
use crate::test_util::settings::initialize_settings_for_tests;
|
||||
use crate::workspaces::team::Team;
|
||||
use crate::workspaces::team_tester::TeamTesterStatus;
|
||||
use crate::workspaces::user_workspaces::UserWorkspaces;
|
||||
use crate::workspaces::workspace::Workspace;
|
||||
|
||||
#[test]
|
||||
fn test_parse_repo_input_owner_repo() {
|
||||
@@ -108,6 +111,25 @@ fn test_build_auth_url_with_next_focus_cloud_mode() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_auth_url_with_next_cloud_setup_source() {
|
||||
let base_url = "https://example.com/oauth/connect/github";
|
||||
let result = github_auth_url::build_auth_url_with_next(
|
||||
base_url,
|
||||
GithubAuthRedirectTarget::FocusCloudMode,
|
||||
"warpdev",
|
||||
AuthSource::CloudSetup,
|
||||
);
|
||||
let parsed = Url::parse(&result).expect("result should be valid url");
|
||||
let next_value = parsed
|
||||
.query_pairs()
|
||||
.find(|(key, _)| key == "next")
|
||||
.map(|(_, value)| value.into_owned());
|
||||
assert_eq!(
|
||||
next_value,
|
||||
Some("warpdev://action/focus_cloud_mode?source=cloud_setup".to_string())
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_build_auth_url_with_next_uses_scheme_param() {
|
||||
let base_url = "https://example.com/oauth/connect/github?scheme=warp";
|
||||
@@ -244,6 +266,7 @@ fn workspace_for_test(team: &Team) -> Workspace {
|
||||
teams: vec![team.clone()],
|
||||
billing_metadata: Default::default(),
|
||||
bonus_grants_purchased_this_month: Default::default(),
|
||||
billing_cycle_usage: None,
|
||||
has_billing_history: false,
|
||||
settings: Default::default(),
|
||||
invite_code: None,
|
||||
@@ -503,6 +526,42 @@ fn test_render_repos_field_error_state() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_repos_field_error_state_allows_manual_repo_entry() {
|
||||
App::test((), |mut app| async move {
|
||||
init_update_environment_form_test_models(&mut app);
|
||||
let window_id = create_test_window(&mut app);
|
||||
|
||||
let mut view_handle = None;
|
||||
app.update(|ctx| {
|
||||
view_handle = Some(ctx.add_typed_action_view(window_id, |ctx| {
|
||||
UpdateEnvironmentForm::new_for_test(EnvironmentFormInitArgs::Create, ctx)
|
||||
}));
|
||||
});
|
||||
let view_handle = view_handle.expect("UpdateEnvironmentForm handle should be created");
|
||||
|
||||
app.update(|ctx| {
|
||||
view_handle.update(ctx, |form, ctx| {
|
||||
set_github_auth_call_state(
|
||||
form,
|
||||
GithubAuthCallState::error("Failed to load GitHub repositories"),
|
||||
);
|
||||
form.repos_input = "warpdotdev/warp-internal".to_string();
|
||||
form.handle_action(&UpdateEnvironmentFormAction::AddRepo, ctx);
|
||||
});
|
||||
|
||||
let form = view_handle.as_ref(ctx);
|
||||
assert_eq!(form.form_state.selected_repos.len(), 1);
|
||||
assert_eq!(form.form_state.selected_repos[0].owner, "warpdotdev");
|
||||
assert_eq!(form.form_state.selected_repos[0].repo, "warp-internal");
|
||||
assert!(
|
||||
form.github_dropdown_state.load_error_message.is_some(),
|
||||
"Expected GitHub load error to remain visible after manually adding a repo"
|
||||
);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_render_repos_field_with_selected_repos() {
|
||||
App::test((), |mut app| async move {
|
||||
@@ -963,6 +1022,112 @@ fn test_create_environment_form_without_team_does_not_render_checkbox_and_defaul
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_environment_form_copy_orchestration_modal_overrides_settings_defaults() {
|
||||
let default_copy = EnvironmentFormCopy::default();
|
||||
let orchestration_copy = EnvironmentFormCopy::orchestration_modal();
|
||||
|
||||
assert_eq!(default_copy.name_placeholder, "Environment name");
|
||||
assert_eq!(default_copy.docker_image_label, "Docker image reference");
|
||||
assert!(default_copy.show_description_character_count);
|
||||
|
||||
assert_eq!(orchestration_copy.name_placeholder, "e.g., dev-env");
|
||||
assert_eq!(
|
||||
orchestration_copy.repos_placeholder_authed,
|
||||
"Browse GitHub repos..."
|
||||
);
|
||||
assert_eq!(orchestration_copy.docker_image_label, "Docker image");
|
||||
assert_eq!(
|
||||
orchestration_copy.docker_image_placeholder,
|
||||
"e.g., node:20-alpine"
|
||||
);
|
||||
assert_eq!(
|
||||
orchestration_copy.setup_commands_placeholder,
|
||||
"e.g., node start"
|
||||
);
|
||||
assert_eq!(
|
||||
orchestration_copy.setup_commands_helper,
|
||||
"Press Enter or click the submit button to add each command."
|
||||
);
|
||||
assert!(!orchestration_copy.show_description_character_count);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_orchestration_modal_form_configuration_renders_footer_actions_without_team_controls() {
|
||||
App::test((), |mut app| async move {
|
||||
init_update_environment_form_test_models(&mut app);
|
||||
let window_id = create_test_window(&mut app);
|
||||
|
||||
app.update(|ctx| {
|
||||
let team = team_for_test();
|
||||
let workspace = workspace_for_test(&team);
|
||||
let workspace_uid = workspace.uid;
|
||||
|
||||
UserWorkspaces::handle(ctx).update(ctx, |user_workspaces, ctx| {
|
||||
user_workspaces.update_workspaces(vec![workspace], ctx);
|
||||
user_workspaces.set_current_workspace_uid(workspace_uid, ctx);
|
||||
});
|
||||
|
||||
let view_handle = ctx.add_typed_action_view(window_id, |ctx| {
|
||||
let mut form =
|
||||
UpdateEnvironmentForm::new_for_test(EnvironmentFormInitArgs::Create, ctx);
|
||||
form.set_show_header(false, ctx);
|
||||
form.configure_for_orchestration_modal(ctx);
|
||||
form
|
||||
});
|
||||
|
||||
let form = view_handle.as_ref(ctx);
|
||||
assert!(!form.show_header);
|
||||
assert!(form.show_footer_cancel_button);
|
||||
assert!(!form.show_share_with_team_controls);
|
||||
assert_eq!(form.field_spacing, 10.);
|
||||
assert_eq!(form.description_height, 52.);
|
||||
assert!(!form.show_repo_helper_text);
|
||||
assert!(!form.copy.show_description_character_count);
|
||||
|
||||
let submit_button = form.submit_button.clone();
|
||||
let cancel_button = form.cancel_button.clone();
|
||||
|
||||
let submit_text = submit_button
|
||||
.as_ref(ctx)
|
||||
.render(ctx)
|
||||
.debug_text_content()
|
||||
.unwrap_or_default();
|
||||
let cancel_text = cancel_button
|
||||
.as_ref(ctx)
|
||||
.render(ctx)
|
||||
.debug_text_content()
|
||||
.unwrap_or_default();
|
||||
assert!(
|
||||
submit_text.contains("Create environment"),
|
||||
"Expected footer submit label in rendered content: {submit_text}"
|
||||
);
|
||||
assert!(
|
||||
cancel_text.contains("Cancel"),
|
||||
"Expected footer cancel action in rendered content: {cancel_text}"
|
||||
);
|
||||
|
||||
let text_content = view_handle
|
||||
.as_ref(ctx)
|
||||
.render(ctx)
|
||||
.debug_text_content()
|
||||
.unwrap_or_default();
|
||||
assert!(
|
||||
!text_content.contains("Share with team"),
|
||||
"Did not expect team-sharing controls in orchestration modal form: {text_content}"
|
||||
);
|
||||
assert!(
|
||||
!text_content.contains("0 / 240 characters"),
|
||||
"Did not expect settings character count in orchestration modal form: {text_content}"
|
||||
);
|
||||
assert!(
|
||||
!text_content.contains("Type owner/repo and press Enter"),
|
||||
"Did not expect settings repo helper text in orchestration modal form: {text_content}"
|
||||
);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_docker_hub_url_bare_owner_repo() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user