Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): allow loading background plugins on startup #3616

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 g  UNLOCK  Alt +  <n> New Pane  <←↓↑→> Change Focus  <f> Floating 
Loading
Loading