aboutsummaryrefslogtreecommitdiffstats
path: root/sl0ppij/zellij-integration-tests/tests/plugins.rs
blob: 21990a943b07b0d729b9878f96316faedd40d543 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#![cfg(unix)]

use insta::assert_snapshot;
use zellij_integration_tests::{normalized, TestRunner, TERMINAL_SIZE};

fn load_background_plugin_config() -> String {
    let plugin_path = format!(
        "{}/../zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm",
        env!("CARGO_MANIFEST_DIR")
    );
    format!(
        "plugins {{\n  permission-requester location=\"file:{}\"\n}}\nload_plugins {{\n  \"permission-requester\"\n}}\n",
        plugin_path
    )
}

#[test]
fn load_plugins_in_background_on_startup() {
    let mut zellij = TestRunner::new(TERMINAL_SIZE)
        .with_config(&load_background_plugin_config())
        .start();
    let terminal = zellij.expect_pty_spawn();
    terminal.output(b"$ ");

    let grid_snapshot =
        zellij.wait_until("background plugin requests permissions", |grid_snapshot| {
            grid_snapshot.contains("Allow? (y/n)")
                && grid_snapshot.tab_bar_appears()
                && grid_snapshot.status_bar_appears()
                && grid_snapshot.contains("STAGGERED")
        });
    assert_snapshot!(normalized(&grid_snapshot));
    zellij.send_stdin(b"y");
    zellij.wait_until(
        "permission prompt dismissed after granting",
        |grid_snapshot| !grid_snapshot.contains("Allow? (y/n)"),
    );
    zellij.quit();
}