Initial public release of Warp.

Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
David Stern
2026-04-28 08:43:33 -05:00
commit 0dbd3d567a
4982 changed files with 1431549 additions and 0 deletions
@@ -0,0 +1,98 @@
use warpui::{
async_assert, async_assert_eq,
integration::{AssertionCallback, AssertionWithDataCallback},
App, ViewHandle,
};
use crate::{
integration_testing::{cloud_object::assert_metadata_revision, view_getters::workflow_view},
server::ids::SyncId,
workflows::{workflow_view::WorkflowView, CloudWorkflowModel, WorkflowId},
};
/// Asserts metadata exists for the workflow with the given key and that the revision in that
/// metadata matches the given expected revision.
pub fn assert_workflow_metadata_revision(
id: impl AsRef<str>,
expected_revision: i64,
) -> AssertionCallback {
assert_metadata_revision::<WorkflowId, CloudWorkflowModel>(id.as_ref(), expected_revision)
}
/// Asserts that a pane has the given workflow open.
pub fn assert_workflow_id(
tab_index: usize,
pane_index: usize,
expected_id_key: impl Into<String>,
) -> AssertionWithDataCallback {
let expected_id_key = expected_id_key.into();
Box::new(move |app, window_id, data| {
let expected_id = data.get(&expected_id_key).expect("No saved workflow ID");
let workflow = workflow_view(app, window_id, tab_index, pane_index);
workflow.read(app, |workflow, _ctx| {
let id = workflow.workflow_id();
async_assert_eq!(
id, *expected_id,
"Expected window_id={window_id}, tab_index={tab_index}, pane_index={pane_index} to contain {expected_id:?}, but got {id:?}")
})
})
}
pub fn assert_no_workflow_pane_open() -> AssertionCallback {
Box::new(move |app, _| {
let count = get_all_open_workflows(app).len();
async_assert!(count == 0, "Expected no workflow panes to be open")
})
}
pub fn assert_no_team_workflow_pane_open() -> AssertionCallback {
Box::new(move |app, _| {
let count = get_all_open_workflows(app)
.iter()
.filter(|view| view.read(app, |v, _| v.is_team_workflow()))
.count();
async_assert!(count == 0, "Expected no workflow panes to be open")
})
}
pub fn assert_open_workflow_pane_count_equals(num: usize) -> AssertionCallback {
Box::new(move |app, _| {
let count = get_all_open_workflows(app).len();
async_assert!(
count == num,
"Expected number of open workflow panes to be: {num}. Found {count} instead"
)
})
}
pub fn assert_open_team_workflow_pane_count_equals(num: usize) -> AssertionCallback {
Box::new(move |app, _| {
let count = get_all_open_workflows(app)
.iter()
.filter(|view| view.read(app, |v, _| v.is_team_workflow()))
.count();
async_assert!(
count == num,
"Expected number of open workflow panes to be: {num}. Found {count} instead"
)
})
}
/// Find number of workflows that are open by id
pub fn open_workflow_count(app: &App, id: SyncId) -> usize {
app.window_ids()
.into_iter()
.flat_map(|window_id| app.views_of_type::<WorkflowView>(window_id))
.flatten()
.filter(move |view| view.read(app, |view, _ctx| view.workflow_id()) == id)
.count()
}
fn get_all_open_workflows(app: &mut App) -> Vec<ViewHandle<WorkflowView>> {
app.window_ids()
.into_iter()
.flat_map(|window_id| app.views_of_type::<WorkflowView>(window_id))
.flatten()
.collect()
}
@@ -0,0 +1,7 @@
mod assertion;
mod step;
pub use assertion::*;
pub use step::*;
pub use crate::user_config::workflows_dir;
@@ -0,0 +1,87 @@
use warpui::{
async_assert, integration::TestStep, windowing::WindowManager, SingletonEntity, WindowId,
};
use crate::{
cloud_object::{model::persistence::CloudModel, CloudObjectEventEntrypoint, Space},
drive::OpenWarpDriveObjectSettings,
integration_testing::view_getters::workspace_view,
server::{
cloud_objects::update_manager::UpdateManager,
ids::{ClientId, SyncId},
},
workflows::{manager::WorkflowOpenSource, workflow::Workflow, WorkflowViewMode},
workspaces::user_workspaces::UserWorkspaces,
};
use super::open_workflow_count;
/// Create a personal workflow and save its sync ID into the step data.
pub fn create_a_personal_workflow(key: impl Into<String>) -> TestStep {
let key = key.into();
let workflow = Workflow::new("personal workflow", "echo 'name'");
TestStep::new("Create a personal workflow")
.with_action(move |app, _, data| {
let client_id = ClientId::new();
let sync_id = SyncId::ClientId(client_id);
UpdateManager::handle(app).update(app, |update_manager, ctx| {
update_manager.create_workflow(
workflow.clone(),
UserWorkspaces::as_ref(ctx)
.personal_drive(ctx)
.expect("User UID must be set in tests"),
None,
client_id,
CloudObjectEventEntrypoint::ManagementUI,
true,
ctx,
);
});
data.insert(key.clone(), sync_id);
})
.add_assertion(move |app, _| {
CloudModel::handle(app).read(app, |cloud_model, ctx| {
async_assert!(
cloud_model
.active_cloud_objects_in_space(Space::Personal, ctx)
.count()
> 0,
"Workflow exists"
)
})
})
}
/// Open the workflow saved at `workflow_key` in the active tab of the window saved at `window_key`
pub fn open_workflow(window_key: impl Into<String>, workflow_key: impl Into<String>) -> TestStep {
let window_key = window_key.into();
let workflow_key = workflow_key.into();
let workflow_other_key = workflow_key.clone();
TestStep::new("Open workflow")
.with_action(move |app, _, data| {
let workflow_id: &SyncId = data.get(&workflow_key).expect("No saved workflow ID");
let window_id: &WindowId = data.get(&window_key).expect("No saved window ID");
workspace_view(app, *window_id).update(app, |workspace, ctx| {
// If the workflow isn't open yet, opening it won't focus the window (we only change
// focus if switching to an already-open window). Since the user wouldn't be able to
// open a workflow in an unfocused window, switch focus explicitly here.
WindowManager::as_ref(ctx).show_window_and_focus_app(*window_id);
workspace.open_workflow_in_pane(
&WorkflowOpenSource::Existing(*workflow_id),
&OpenWarpDriveObjectSettings::default(),
WorkflowViewMode::View,
ctx,
);
})
})
.add_named_assertion_with_data_from_prior_step(
"Check workflow is open",
move |app, _, data| {
let workflow_id: &SyncId =
data.get(&workflow_other_key).expect("No workflow ID found");
async_assert!(open_workflow_count(app, *workflow_id) == 1)
},
)
}