aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/plugins/unit/plugin_tests.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-10-22 15:27:40 +0200
committerGitHub <noreply@github.com>2024-10-22 15:27:40 +0200
commitd671ab650e231d353a05a2808c0984e952de38c4 (patch)
tree38a0604f9b4b20adfed5cf3e8324c59fbdf1ff2b /zellij-server/src/plugins/unit/plugin_tests.rs
parentdocs(changelog): wasmtime patch upgrade (diff)
downloadsl0ppij-d671ab650e231d353a05a2808c0984e952de38c4.tar.gz
sl0ppij-d671ab650e231d353a05a2808c0984e952de38c4.tar.xz
sl0ppij-d671ab650e231d353a05a2808c0984e952de38c4.zip
feat(plugins): add API to list clients, their focused panes and running commands/plugins (#3687)
* fix(list-clients): properly show client info after a tab was closed * feat(plugins): add API to list clients, their focused panes and running commands/plugins * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/plugins/unit/plugin_tests.rs')
-rw-r--r--zellij-server/src/plugins/unit/plugin_tests.rs71
1 files changed, 71 insertions, 0 deletions
diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs
index 0750c0dd..63d88115 100644
--- a/zellij-server/src/plugins/unit/plugin_tests.rs
+++ b/zellij-server/src/plugins/unit/plugin_tests.rs
@@ -8551,3 +8551,74 @@ pub fn rebind_keys_plugin_command() {
.clone();
assert_snapshot!(format!("{:#?}", rebind_event));
}
+
+#[test]
+#[ignore]
+pub fn list_clients_plugin_command() {
+ let temp_folder = tempdir().unwrap(); // placed explicitly in the test scope because its
+ // destructor removes the directory
+ let plugin_host_folder = PathBuf::from(temp_folder.path());
+ let cache_path = plugin_host_folder.join("permissions_test.kdl");
+ let (plugin_thread_sender, screen_receiver, teardown) =
+ create_plugin_thread(Some(plugin_host_folder));
+ let plugin_should_float = Some(false);
+ let plugin_title = Some("test_plugin".to_owned());
+ let run_plugin = RunPluginOrAlias::RunPlugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(&*PLUGIN_FIXTURE)),
+ configuration: Default::default(),
+ ..Default::default()
+ });
+ let tab_index = 1;
+ let client_id = 1;
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let received_screen_instructions = Arc::new(Mutex::new(vec![]));
+ let screen_thread = grant_permissions_and_log_actions_in_thread!(
+ received_screen_instructions,
+ ScreenInstruction::ListClientsToPlugin,
+ screen_receiver,
+ 1,
+ &PermissionType::ChangeApplicationState,
+ cache_path,
+ plugin_thread_sender,
+ client_id
+ );
+
+ let _ = plugin_thread_sender.send(PluginInstruction::AddClient(client_id));
+ let _ = plugin_thread_sender.send(PluginInstruction::Load(
+ plugin_should_float,
+ false,
+ plugin_title,
+ run_plugin,
+ Some(tab_index),
+ None,
+ client_id,
+ size,
+ None,
+ false,
+ ));
+ std::thread::sleep(std::time::Duration::from_millis(500));
+ let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
+ None,
+ Some(client_id),
+ Event::Key(KeyWithModifier::new(BareKey::Char('z')).with_alt_modifier()), // this triggers the enent in the fixture plugin
+ )]));
+ screen_thread.join().unwrap(); // this might take a while if the cache is cold
+ teardown();
+ let list_clients_instruction = received_screen_instructions
+ .lock()
+ .unwrap()
+ .iter()
+ .find_map(|i| {
+ if let ScreenInstruction::ListClientsToPlugin(..) = i {
+ Some(i.clone())
+ } else {
+ None
+ }
+ })
+ .unwrap();
+ assert_snapshot!(format!("{:#?}", list_clients_instruction));
+}