Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(desktop-gpui): record the video ids the mock Cap server creates and deletes

Richie McIlroy8ad1db90e29c
diff --git a/apps/desktop-gpui/src/upload/verify_tests.rs b/apps/desktop-gpui/src/upload/verify_tests.rs
index 7d13956be..503978eeb 100644
--- a/apps/desktop-gpui/src/upload/verify_tests.rs
+++ b/apps/desktop-gpui/src/upload/verify_tests.rs
@@ -207,6 +207,8 @@ struct MockState {
next_id: u32,
confirmations: Vec<Value>,
deletes: u32,
+ created: Vec<String>,
+ deleted: Vec<String>,
problems: Vec<String>,
}
@@ -433,6 +435,16 @@ impl MockCap {
self.lock().confirmations.clone()
}
+ /// Video ids the mock created, in order.
+ pub(super) fn created(&self) -> Vec<String> {
+ self.lock().created.clone()
+ }
+
+ /// Video ids the mock was asked to delete, in order.
+ pub(super) fn deleted(&self) -> Vec<String> {
+ self.lock().deleted.clone()
+ }
+
pub(super) fn deletes(&self) -> u32 {
self.lock().deletes
}
@@ -792,6 +804,7 @@ impl Server {
state.next_id += 1;
format!("verifyvideo{:04}", state.next_id)
});
+ state.created.push(id.clone());
reply(200, json!({ "id": id }))
}
("POST", "/api/upload/multipart/initiate") => {
@@ -924,6 +937,9 @@ impl Server {
}
("DELETE", "/api/desktop/video/delete") => {
state.deletes += 1;
+ if let Some(id) = query.get("videoId") {
+ state.deleted.push(id.clone());
+ }
reply(200, json!({ "success": true }))
}
_ => {