test(config): cover vim action migration
- commit
- 55482b4bafa5d858ee2cb799aaa893b156141535
- author
- brice · · 2026-08-14 13:17 UTC
- parent
- f52290e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +35 -0
M internal/infrastructure/config/migrate_test.go +35 -0
| @@ -816,6 +816,41 @@ func TestMigrator_MergeMissingDefaultActions_PaneMode(t *testing.T) { | |||
| 816 | 816 | assert.Equal(t, "Custom move pane", move["desc"]) | |
| 817 | 817 | } | |
| 818 | 818 | ||
| 819 | + | func TestMigrator_MergeMissingDefaultActions_VimMode(t *testing.T) { | |
| 820 | + | m := NewMigrator() | |
| 821 | + | ||
| 822 | + | rawConfig := map[string]any{ | |
| 823 | + | "workspace": map[string]any{ | |
| 824 | + | "vim_mode": map[string]any{ | |
| 825 | + | "actions": map[string]any{ | |
| 826 | + | "heading-next": map[string]any{ | |
| 827 | + | "keys": []string{"]]"}, | |
| 828 | + | "desc": "Custom next heading", | |
| 829 | + | }, | |
| 830 | + | }, | |
| 831 | + | }, | |
| 832 | + | }, | |
| 833 | + | } | |
| 834 | + | ||
| 835 | + | m.mergeMissingDefaultActions(rawConfig) | |
| 836 | + | ||
| 837 | + | actionsAny := m.getNestedValue(rawConfig, "workspace.vim_mode.actions") | |
| 838 | + | actions, ok := actionsAny.(map[string]any) | |
| 839 | + | require.True(t, ok) | |
| 840 | + | ||
| 841 | + | focusAny, hasFocus := actions["focus-input"] | |
| 842 | + | require.True(t, hasFocus) | |
| 843 | + | focus, ok := focusAny.(ActionBinding) | |
| 844 | + | require.True(t, ok) | |
| 845 | + | assert.Equal(t, []string{"gi"}, focus.Keys) | |
| 846 | + | ||
| 847 | + | headingAny, hasHeading := actions["heading-next"] | |
| 848 | + | require.True(t, hasHeading) | |
| 849 | + | heading, ok := headingAny.(map[string]any) | |
| 850 | + | require.True(t, ok) | |
| 851 | + | assert.Equal(t, "Custom next heading", heading["desc"]) | |
| 852 | + | } | |
| 853 | + | ||
| 819 | 854 | func TestMigrator_DefaultValueForKey_WorkspaceShortcutAction(t *testing.T) { | |
| 820 | 855 | m := NewMigrator() | |
| 821 | 856 | ||
| @@ -816,6 +816,41 @@ func TestMigrator_MergeMissingDefaultActions_PaneMode(t *testing.T) { | |||||
| 816 | assert.Equal(t, "Custom move pane", move["desc"]) | 816 | assert.Equal(t, "Custom move pane", move["desc"]) | ||
| 817 | } | 817 | } | ||
| 818 | 818 | ||||
| 819 | + | func TestMigrator_MergeMissingDefaultActions_VimMode(t *testing.T) { | |||
| 820 | + | m := NewMigrator() | |||
| 821 | + | ||||
| 822 | + | rawConfig := map[string]any{ | |||
| 823 | + | "workspace": map[string]any{ | |||
| 824 | + | "vim_mode": map[string]any{ | |||
| 825 | + | "actions": map[string]any{ | |||
| 826 | + | "heading-next": map[string]any{ | |||
| 827 | + | "keys": []string{"]]"}, | |||
| 828 | + | "desc": "Custom next heading", | |||
| 829 | + | }, | |||
| 830 | + | }, | |||
| 831 | + | }, | |||
| 832 | + | }, | |||
| 833 | + | } | |||
| 834 | + | ||||
| 835 | + | m.mergeMissingDefaultActions(rawConfig) | |||
| 836 | + | ||||
| 837 | + | actionsAny := m.getNestedValue(rawConfig, "workspace.vim_mode.actions") | |||
| 838 | + | actions, ok := actionsAny.(map[string]any) | |||
| 839 | + | require.True(t, ok) | |||
| 840 | + | ||||
| 841 | + | focusAny, hasFocus := actions["focus-input"] | |||
| 842 | + | require.True(t, hasFocus) | |||
| 843 | + | focus, ok := focusAny.(ActionBinding) | |||
| 844 | + | require.True(t, ok) | |||
| 845 | + | assert.Equal(t, []string{"gi"}, focus.Keys) | |||
| 846 | + | ||||
| 847 | + | headingAny, hasHeading := actions["heading-next"] | |||
| 848 | + | require.True(t, hasHeading) | |||
| 849 | + | heading, ok := headingAny.(map[string]any) | |||
| 850 | + | require.True(t, ok) | |||
| 851 | + | assert.Equal(t, "Custom next heading", heading["desc"]) | |||
| 852 | + | } | |||
| 853 | + | ||||
| 819 | func TestMigrator_DefaultValueForKey_WorkspaceShortcutAction(t *testing.T) { | 854 | func TestMigrator_DefaultValueForKey_WorkspaceShortcutAction(t *testing.T) { | ||
| 820 | m := NewMigrator() | 855 | m := NewMigrator() | ||
| 821 | 856 | ||||