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,72 @@
use warpui::{
async_assert, async_assert_eq,
integration::{AssertionCallback, AssertionWithDataCallback},
AppContext, SingletonEntity,
};
use crate::{
ai::facts::{view::AIFactPage, CloudAIFactModel},
cloud_object::model::{generic_string_model::GenericStringObjectId, persistence::CloudModel},
integration_testing::view_getters::workspace_view,
server::ids::SyncId,
};
/// Assert that a specific AI fact exists with the given content
pub fn assert_rule_exists(
expected_id_key: impl Into<String>,
expected_content: impl Into<String>,
) -> AssertionWithDataCallback {
let expected_id_key = expected_id_key.into();
let expected_content = expected_content.into();
Box::new(move |app, _window_id, data| {
let sync_id: &SyncId = data.get(&expected_id_key).expect("No saved AI fact ID");
CloudModel::handle(app).read(app, |cloud_model, _| {
if let Some(ai_fact) =
cloud_model.get_object_of_type::<GenericStringObjectId, CloudAIFactModel>(sync_id)
{
let content = match &ai_fact.model().string_model {
crate::ai::facts::AIFact::Memory(memory) => &memory.content,
};
async_assert_eq!(content, &expected_content, "AI fact content should match")
} else {
async_assert!(false, "AI fact should exist")
}
})
})
}
/// Assert that the total number of AI facts matches the expected count
pub fn assert_rule_count(expected_count: usize) -> AssertionCallback {
Box::new(move |app, _| {
CloudModel::handle(app).read(app, |cloud_model, ctx| {
let count = rule_count(cloud_model, ctx);
async_assert_eq!(count, expected_count, "Rule count should match")
})
})
}
/// Helper function to count AI facts in the cloud model
pub fn rule_count(cloud_model: &CloudModel, _ctx: &AppContext) -> usize {
cloud_model
.get_all_objects_of_type::<GenericStringObjectId, CloudAIFactModel>()
.count()
}
pub fn assert_rule_pane_open(key: impl Into<String>) -> AssertionWithDataCallback {
let key = key.into();
Box::new(move |app, window_id, data| {
workspace_view(app, window_id).read(app, |workspace, _ctx| {
let sync_id: &SyncId = data.get(&key).expect("No saved AI fact ID");
workspace.ai_fact_view().read(app, |ai_fact_view, _ctx| {
let current_page = ai_fact_view.current_page();
async_assert_eq!(
current_page,
AIFactPage::RuleEditor {
sync_id: Some(*sync_id)
},
"Rule pane should be open"
)
})
})
})
}
+5
View File
@@ -0,0 +1,5 @@
pub mod assertion;
pub mod step;
pub use assertion::*;
pub use step::*;
+103
View File
@@ -0,0 +1,103 @@
use std::sync::Arc;
use warpui::{
async_assert, integration::TestStep, windowing::WindowManager, SingletonEntity, WindowId,
};
use crate::{
ai::facts::{view::AIFactPage, AIMemory},
cloud_object::{model::persistence::CloudModel, Space},
integration_testing::view_getters::workspace_view,
server::{
cloud_objects::update_manager::UpdateManager,
ids::{ClientId, SyncId},
},
workspaces::user_workspaces::UserWorkspaces,
};
/// Create a personal rule and save its sync ID into the step data.
pub fn create_a_personal_rule(
key: impl Into<String>,
name: impl Into<String>,
content: impl Into<String>,
) -> TestStep {
let key = key.into();
let name = Arc::new(Some(name.into()));
let content = Arc::new(content.into());
TestStep::new("Create a personal rule")
.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| {
let ai_fact = crate::ai::facts::AIFact::Memory(AIMemory {
is_autogenerated: false,
name: name.as_ref().clone(),
content: content.as_ref().clone(),
suggested_logging_id: None,
});
update_manager.create_ai_fact(
ai_fact,
client_id,
UserWorkspaces::as_ref(ctx)
.personal_drive(ctx)
.expect("User UID must be set in tests"),
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,
"Rule exists"
)
})
})
}
/// Open the rule pane saved at `key` in the active tab of the window saved at `window_key`
pub fn open_rule_pane(window_key: impl Into<String>, key: impl Into<String>) -> TestStep {
let window_key = window_key.into();
let key = key.into();
TestStep::new("Open rule pane").with_action(move |app, _, data| {
let window_id: &WindowId = data.get(&window_key).expect("No saved window ID");
let fact_id: &SyncId = data.get(&key).expect("No saved rule ID");
workspace_view(app, *window_id).update(app, |workspace, ctx| {
// Focus the window first
WindowManager::as_ref(ctx).show_window_and_focus_app(*window_id);
// Open the AI facts pane
let page = AIFactPage::RuleEditor {
sync_id: Some(*fact_id),
};
workspace.open_ai_fact_collection_pane(None, Some(page), ctx);
})
})
}
/// Update a rule's content
pub fn update_rule_content(
fact_key: impl Into<String>,
new_content: impl Into<String>,
) -> TestStep {
let fact_key = fact_key.into();
let new_content = Arc::new(new_content.into());
TestStep::new("Update rule content").with_action(move |app, _, data| {
let sync_id: &SyncId = data.get(&fact_key).expect("No saved rule ID");
UpdateManager::handle(app).update(app, |update_manager, ctx| {
let ai_fact = crate::ai::facts::AIFact::Memory(AIMemory {
is_autogenerated: false,
name: None,
content: new_content.as_ref().clone(),
suggested_logging_id: None,
});
update_manager.update_ai_fact(ai_fact, *sync_id, None, ctx);
});
})
}