fix(git): cover branch picker submode wiring

This commit is contained in:
Kayshen-X 2026-05-31 21:05:26 +08:00
parent 1ef8c45f37
commit a0a1f4da04
2 changed files with 46 additions and 7 deletions

View file

@ -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,

View file

@ -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