Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
use warpui::{
|
||||
async_assert_eq,
|
||||
integration::{AssertionCallback, AssertionOutcome},
|
||||
};
|
||||
|
||||
use crate::integration_testing::view_getters::pane_group_view;
|
||||
|
||||
pub fn assert_num_shared_sessions_in_pane_group(
|
||||
tab_index: usize,
|
||||
num_shared_sessions: usize,
|
||||
) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let pane_group = pane_group_view(app, window_id, tab_index);
|
||||
pane_group.read(app, |view, ctx| {
|
||||
async_assert_eq!(view.number_of_shared_sessions(ctx), num_shared_sessions)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn assert_num_panes_in_tab(tab_index: usize, num_panes: usize) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let pane_group = pane_group_view(app, window_id, tab_index);
|
||||
pane_group.read(app, |view, _| {
|
||||
async_assert_eq!(view.pane_count(), num_panes)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn assert_focused_pane_index(tab_index: usize, pane_index: usize) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let pane_group = pane_group_view(app, window_id, tab_index);
|
||||
pane_group.read(app, |view, ctx| {
|
||||
let Some(pane_id) = view.pane_id_from_index(pane_index) else {
|
||||
return AssertionOutcome::failure(format!("no pane at pane_index {pane_index}"));
|
||||
};
|
||||
async_assert_eq!(view.focused_pane_id(ctx), pane_id)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn assert_pane_header_overlay_is_open(
|
||||
should_be_open: bool,
|
||||
tab_index: usize,
|
||||
pane_index: usize,
|
||||
) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
pane_group_view(app, window_id, tab_index).read(app, |pane_group, app| {
|
||||
pane_group
|
||||
.terminal_pane_view_at_pane_index(pane_index)
|
||||
.unwrap()
|
||||
.read(app, |pane_view, _| {
|
||||
pane_view.header().read(app, |pane_header, _| {
|
||||
async_assert_eq!(pane_header.is_overlay_open(), should_be_open)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
mod assertions;
|
||||
mod step;
|
||||
|
||||
pub use assertions::*;
|
||||
pub use step::*;
|
||||
@@ -0,0 +1,55 @@
|
||||
use warpui::integration::TestStep;
|
||||
|
||||
use crate::integration_testing::view_getters::pane_group_view;
|
||||
use crate::pane_group::tree::Direction;
|
||||
|
||||
/// Close a specific pane by its index within a tab.
|
||||
pub fn close_pane_by_index(tab_index: usize, pane_index: usize) -> TestStep {
|
||||
TestStep::new("Close pane by index").with_action(move |app, _, _| {
|
||||
let active_window = app
|
||||
.read(|ctx| ctx.windows().active_window())
|
||||
.expect("no active window");
|
||||
|
||||
let pg = pane_group_view(app, active_window, tab_index);
|
||||
|
||||
let pane_id = pg.read(app, |pane_group, _ctx| {
|
||||
pane_group
|
||||
.pane_id_from_index(pane_index)
|
||||
.expect("missing pane index")
|
||||
});
|
||||
|
||||
pg.update(app, |pane_group, ctx| {
|
||||
pane_group.close_pane(pane_id, ctx);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/// Move one pane relative to another by pane indices within a tab.
|
||||
pub fn move_pane_by_indices(
|
||||
tab_index: usize,
|
||||
from_pane_index: usize,
|
||||
to_pane_index: usize,
|
||||
direction: Direction,
|
||||
) -> TestStep {
|
||||
TestStep::new("Move pane by indices").with_action(move |app, _, _| {
|
||||
let active_window = app
|
||||
.read(|ctx| ctx.windows().active_window())
|
||||
.expect("window exists");
|
||||
|
||||
let pg = pane_group_view(app, active_window, tab_index);
|
||||
|
||||
let (from_id, to_id) = pg.read(app, |pane_group, _ctx| {
|
||||
let a = pane_group
|
||||
.pane_id_from_index(from_pane_index)
|
||||
.expect("missing from pane index");
|
||||
let b = pane_group
|
||||
.pane_id_from_index(to_pane_index)
|
||||
.expect("missing to pane index");
|
||||
(a, b)
|
||||
});
|
||||
|
||||
pg.update(app, |pane_group, ctx| {
|
||||
pane_group.move_pane(from_id, to_id, direction, ctx);
|
||||
});
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user