Skip to content

Commit

Permalink
feat(config): allow loading background plugins on startup (zellij-org…
Browse files Browse the repository at this point in the history
…#3616)

* remove old partial implementation

* feat(plugins): allow loading background plugins on startup

* add e2e test

* update config

* udpate config merging

* style(fmt): rustfmt
  • Loading branch information
imsnif committed Dec 31, 2024
1 parent d4d5203 commit 3d2947a
Show file tree
Hide file tree
Showing 23 changed files with 839 additions and 103 deletions.
52 changes: 52 additions & 0 deletions src/tests/e2e/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2371,3 +2371,55 @@ pub fn send_command_through_the_cli() {
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

#[test]
#[ignore]
pub fn load_plugins_in_background_on_startup() {
let fake_win_size = Size {
cols: 120,
rows: 24,
};
let config_file_name = "load_background_plugins.kdl";
let mut test_attempts = 10;
let mut test_timed_out = false;
let last_snapshot = loop {
RemoteRunner::kill_running_sessions(fake_win_size);
let mut runner =
RemoteRunner::new_with_config(fake_win_size, config_file_name).add_step(Step {
name: "Wait for plugin to load and request permissions",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if remote_terminal.snapshot_contains("Allow? (y/n)") {
std::thread::sleep(std::time::Duration::from_millis(100));
remote_terminal.send_key("y".as_bytes());
step_is_complete = true;
}
step_is_complete
},
});
runner.run_all_steps();
let last_snapshot = runner.take_snapshot_after(Step {
name: "Wait for plugin to disappear after permissions were granted",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
let mut step_is_complete = false;
if !remote_terminal.snapshot_contains("Allow? (y/n)") {
step_is_complete = true;
}
step_is_complete
},
});
if runner.test_timed_out && test_attempts > 0 {
test_attempts -= 1;
continue;
} else {
test_timed_out = runner.test_timed_out;
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert!(
!test_timed_out,
"Test timed out, possibly waiting for permission request"
);
assert_snapshot!(last_snapshot);
}
4 changes: 4 additions & 0 deletions src/tests/e2e/remote_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ fn stop_zellij(channel: &mut ssh2::Channel) {
channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous
// tests
channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous
channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous
channel
.write_all(b"rm -rf ~/.cache/zellij/*/session_info\n")
.unwrap();
channel
.write_all(b"rm -rf ~/.cache/zellij/permissions.kdl\n")
.unwrap();
}

fn start_zellij(channel: &mut ssh2::Channel) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 2426
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1
Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
$ █ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl gUNLOCKAlt +  <n> New Pane  <←↓↑→> Change Focus  <f> Floating 
Loading

0 comments on commit 3d2947a

Please sign in to comment.