Add test that JSON schema generation works + actions build from no input (#23049)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-13 13:42:08 -07:00 committed by GitHub
parent 85b727c1a2
commit b633f62aa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 81 additions and 16 deletions

View file

@ -3502,6 +3502,73 @@ mod tests {
assert_key_bindings_for(workspace.into(), cx, vec![("6", &Deploy)], line!());
}
#[gpui::test]
async fn test_generate_keymap_json_schema_for_registered_actions(
cx: &mut gpui::TestAppContext,
) {
init_keymap_test(cx);
cx.update(|cx| {
// Make sure it doesn't panic.
KeymapFile::generate_json_schema_for_registered_actions(cx);
});
}
/// Actions that don't build from empty input won't work from command palette invocation.
#[gpui::test]
async fn test_actions_build_with_empty_input(cx: &mut gpui::TestAppContext) {
init_keymap_test(cx);
cx.update(|cx| {
let all_actions = cx.all_action_names();
let mut failing_names = Vec::new();
let mut errors = Vec::new();
for action in all_actions {
match action.to_string().as_str() {
"vim::FindCommand"
| "vim::Literal"
| "vim::ResizePane"
| "vim::SwitchMode"
| "vim::PushOperator"
| "vim::Number"
| "vim::SelectRegister"
| "terminal::SendText"
| "terminal::SendKeystroke"
| "app_menu::OpenApplicationMenu"
| "app_menu::NavigateApplicationMenuInDirection"
| "picker::ConfirmInput"
| "editor::HandleInput"
| "editor::FoldAtLevel"
| "pane::ActivateItem"
| "workspace::ActivatePane"
| "workspace::ActivatePaneInDirection"
| "workspace::MoveItemToPane"
| "workspace::MoveItemToPaneInDirection"
| "workspace::OpenTerminal"
| "workspace::SwapPaneInDirection"
| "workspace::SendKeystrokes"
| "zed::OpenBrowser"
| "zed::OpenZedUrl" => {}
_ => {
let result = cx.build_action(action, None);
match &result {
Ok(_) => {}
Err(err) => {
failing_names.push(action);
errors.push(format!("{action} failed to build: {err:?}"));
}
}
}
}
}
if errors.len() > 0 {
panic!(
"Failed to build actions using {{}} as input: {:?}. Errors:\n{}",
failing_names,
errors.join("\n")
);
}
});
}
#[gpui::test]
fn test_bundled_settings_and_themes(cx: &mut AppContext) {
cx.text_system()