diff --git a/crates/op-editor-core/src/lib.rs b/crates/op-editor-core/src/lib.rs index 00821da6a..eb9d1ec64 100644 --- a/crates/op-editor-core/src/lib.rs +++ b/crates/op-editor-core/src/lib.rs @@ -93,11 +93,11 @@ pub use components::{Component, ComponentLibrary}; pub use design_md::parse_design_md; pub use editor_ui_state::{ BooleanOp, CloneField, CloneFormState, DesignMdRequest, EditorUiState, ExportFormat, - FileAction, FileMenuChoice, FillType, FlexLayout, GitCommitSummary, GitDiffTarget, GitDiffView, - GitFileEntry, GitOverflowView, GitPanelAction, GitPanelState, ImageAdjustmentField, - ImageFillMode, LayerContextMenuState, Locale, MergeConflictRow, MergeResolveFile, - MergeResolveState, PaddingEditMode, PageRenameState, PropertyTab, RecentFile, ShapeChoice, - ThemeMode, UpdateStatus, VariableRowFocus, + FileAction, FileMenuChoice, FillType, FlexLayout, GitBranchPickerMode, GitCommitSummary, + GitDiffTarget, GitDiffView, GitFileEntry, GitOverflowView, GitPanelAction, GitPanelState, + ImageAdjustmentField, ImageFillMode, LayerContextMenuState, Locale, MergeConflictRow, + MergeResolveFile, MergeResolveState, PaddingEditMode, PageRenameState, PropertyTab, RecentFile, + ShapeChoice, ThemeMode, UpdateStatus, VariableRowFocus, }; pub use fills::{ first_fill_type, first_image_fill_summary, first_solid_fill_hex, first_solid_fill_opacity, diff --git a/crates/op-editor-ui/src/widgets/git_panel_tests.rs b/crates/op-editor-ui/src/widgets/git_panel_tests.rs index e8e637a1f..0760d3ccd 100644 --- a/crates/op-editor-ui/src/widgets/git_panel_tests.rs +++ b/crates/op-editor-ui/src/widgets/git_panel_tests.rs @@ -4,8 +4,9 @@ use crate::widgets::git_panel::*; use crate::{Point2D, Rect}; use op_editor_core::{ - CloneField, CloneFormState, EditorState, GitCommitSummary, GitDiffView, GitFileEntry, - GitOverflowView, GitPanelState, MergeConflictRow, MergeResolveFile, MergeResolveState, + CloneField, CloneFormState, EditorState, GitBranchPickerMode, GitCommitSummary, GitDiffView, + GitFileEntry, GitOverflowView, GitPanelState, MergeConflictRow, MergeResolveFile, + MergeResolveState, }; fn state_with(panel: GitPanelState) -> EditorState { @@ -275,6 +276,44 @@ fn branch_picker_dropdown_switches_and_dismisses() { assert_eq!(panel.hit_test(rect, far), Some(GitPanelHit::DismissPopover)); } +#[test] +fn branch_picker_submodes_map_create_input_and_cancel() { + let s = state_with(GitPanelState { + branch: Some("main".to_string()), + branches: vec!["feature".to_string(), "main".to_string()], + branch_picker_open: true, + branch_picker_mode: GitBranchPickerMode::Create, + ..open_repo() + }); + let panel = GitPanel::for_editor(&s).unwrap(); + let rect = panel_rect(&panel); + let picker = panel.branch_picker_panel(rect); + let input_point = Point2D::new(picker.origin.x + 16.0, picker.origin.y + 34.0); + assert_eq!( + panel.hit_test(rect, input_point), + Some(GitPanelHit::BranchCreateInput) + ); + + let s = state_with(GitPanelState { + branch: Some("main".to_string()), + branches: vec!["feature".to_string(), "main".to_string()], + branch_picker_open: true, + branch_picker_mode: GitBranchPickerMode::Merge, + ..open_repo() + }); + let panel = GitPanel::for_editor(&s).unwrap(); + let rect = panel_rect(&panel); + let picker = panel.branch_picker_panel(rect); + let cancel_point = Point2D::new( + picker.origin.x + picker.size.x / 2.0, + picker.origin.y + picker.size.y - 12.0, + ); + assert_eq!( + panel.hit_test(rect, cancel_point), + Some(GitPanelHit::BranchPickerCancel) + ); +} + #[test] fn ready_long_branch_never_eats_the_overflow_button() { // A long branch name must not push the pull/push cluster over the