Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
use warpui::{async_assert_eq, integration::AssertionCallback};
|
||||
|
||||
use crate::integration_testing::view_getters::workspace_view;
|
||||
|
||||
pub fn assert_focused_tab_index(tab_index: usize) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let workspace = workspace_view(app, window_id);
|
||||
workspace.read(app, |view, _ctx| {
|
||||
async_assert_eq!(view.active_tab_index(), tab_index)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Assert that there are a particular number of tabs in the workspace.
|
||||
pub fn assert_tab_count(tab_count: usize) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let workspace = workspace_view(app, window_id);
|
||||
workspace.read(app, |view, _ctx| {
|
||||
let actual_tab_count = view.tab_count();
|
||||
async_assert_eq!(
|
||||
actual_tab_count,
|
||||
tab_count,
|
||||
"Expected {} tabs, but there were {}",
|
||||
tab_count,
|
||||
actual_tab_count
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
mod assertions;
|
||||
mod step;
|
||||
|
||||
pub use assertions::*;
|
||||
pub use step::*;
|
||||
@@ -0,0 +1,45 @@
|
||||
use warpui::{async_assert, integration::TestStep, SingletonEntity};
|
||||
|
||||
use crate::{
|
||||
integration_testing::view_getters::workspace_view, undo_close::UndoCloseStack,
|
||||
workspace::Workspace,
|
||||
};
|
||||
|
||||
/// Mock pressing a button on the Warp-native quit modal. Note that this modal is currently only
|
||||
/// used on Linux, not macOS.
|
||||
pub fn press_native_modal_button(button_index: usize) -> TestStep {
|
||||
TestStep::new("Press a native modal button")
|
||||
.with_action(move |app, _, _data| {
|
||||
let active_window = app
|
||||
.read(|ctx| ctx.windows().active_window())
|
||||
.expect("no active window");
|
||||
let workspace = workspace_view(app, active_window);
|
||||
app.update(|ctx| {
|
||||
assert!(
|
||||
workspace.as_ref(ctx).is_native_quit_modal_open(ctx),
|
||||
"Native modal should be open"
|
||||
);
|
||||
Workspace::press_native_modal_button(&workspace, button_index, ctx);
|
||||
});
|
||||
})
|
||||
.add_assertion(|app, window_id| {
|
||||
let workspace = workspace_view(app, window_id);
|
||||
workspace.read(app, |workspace, ctx| {
|
||||
async_assert!(
|
||||
!workspace.is_native_quit_modal_open(ctx),
|
||||
"Native modal is still open"
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Trigger undo close (restore closed pane/tab/window) action.
|
||||
pub fn trigger_undo_close() -> TestStep {
|
||||
TestStep::new("Trigger undo close").with_action(move |app, _, _data| {
|
||||
app.update(|ctx| {
|
||||
UndoCloseStack::handle(ctx).update(ctx, |stack, model_ctx| {
|
||||
stack.undo_close(model_ctx);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user