Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
use warpui::{async_assert, integration::AssertionCallback};
|
||||
|
||||
use crate::integration_testing::{terminal::util::ExpectedOutput, view_getters::pane_group_view};
|
||||
|
||||
/// Asserts that the tab has a pane at the given index with the expected title.
|
||||
pub fn assert_pane_title(
|
||||
tab_index: usize,
|
||||
pane_index: usize,
|
||||
expected_title: impl ExpectedOutput + 'static,
|
||||
) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let pane_group = pane_group_view(app, window_id, tab_index);
|
||||
pane_group.read(app, |pane_group, ctx| {
|
||||
match pane_group.pane_by_index(pane_index) {
|
||||
Some(pane) => {
|
||||
let pane_title = pane.pane_configuration().as_ref(ctx).title().to_owned();
|
||||
async_assert!(
|
||||
expected_title.matches(&pane_title),
|
||||
"Expected title for window_id={window_id}, tab_index={tab_index}, pane_index={pane_index} to be [{expected_title:?}], but got [{pane_title:?}]"
|
||||
)
|
||||
},
|
||||
None => panic!("pane should exist for window_id={window_id}, tab_index={tab_index}, pane_index={pane_index}")
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Asserts that the active pane of the tab has an expected title.
|
||||
pub fn assert_tab_title(
|
||||
tab_index: usize,
|
||||
expected_title: impl ExpectedOutput + 'static,
|
||||
) -> AssertionCallback {
|
||||
Box::new(move |app, window_id| {
|
||||
let pane_group = pane_group_view(app, window_id, tab_index);
|
||||
let title = pane_group.read(app, |pane_group, ctx| pane_group.display_title(ctx));
|
||||
async_assert!(
|
||||
expected_title.matches(&title),
|
||||
"Expected title of tab {tab_index} to match [{expected_title:?}], but was [{title}]"
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
mod assertion;
|
||||
mod step;
|
||||
|
||||
pub use assertion::*;
|
||||
pub use step::*;
|
||||
@@ -0,0 +1,11 @@
|
||||
use warpui::integration::TestStep;
|
||||
|
||||
use crate::integration_testing::{step::new_step_with_default_assertions, tab::assert_tab_title};
|
||||
|
||||
/// Checks whether the current tab has an expected title.
|
||||
/// #Panics if any of the assertions fail (including if the tab title doesn't match
|
||||
/// `expected_tab_title`)
|
||||
pub fn tab_title_step(assertion_name: &str, expected_tab_title: String) -> TestStep {
|
||||
new_step_with_default_assertions(assertion_name)
|
||||
.add_assertion(assert_tab_title(0, expected_tab_title))
|
||||
}
|
||||
Reference in New Issue
Block a user