Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,31 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
}
}

// === React Profiling (component-level render data) ===
"react_profile" => {
const VALID: &[&str] = &["start", "stop"];
match rest.first().copied() {
Some("start") => {
Ok(json!({ "id": id, "action": "react_profile_start" }))
}
Some("stop") => {
let mut cmd = json!({ "id": id, "action": "react_profile_stop" });
if let Some(path) = rest.get(1) {
cmd["path"] = json!(path);
}
Ok(cmd)
}
Some(sub) => Err(ParseError::UnknownSubcommand {
subcommand: sub.to_string(),
valid_options: VALID,
}),
None => Err(ParseError::MissingArguments {
context: "react_profile".to_string(),
usage: "react_profile <start|stop> [path]",
}),
}
}

// === Recording (Playwright native video recording) ===
"record" => {
const VALID: &[&str] = &["start", "stop", "restart"];
Expand Down Expand Up @@ -2919,6 +2944,49 @@ mod tests {
));
}

// === React Profile Tests ===

#[test]
fn test_react_profile_start() {
let cmd = parse_command(&args("react_profile start"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "react_profile_start");
}

#[test]
fn test_react_profile_stop_no_path() {
let cmd = parse_command(&args("react_profile stop"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "react_profile_stop");
assert!(cmd.get("path").is_none());
}

#[test]
fn test_react_profile_stop_with_path() {
let cmd =
parse_command(&args("react_profile stop react.json"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "react_profile_stop");
assert_eq!(cmd["path"], "react.json");
}

#[test]
fn test_react_profile_invalid_subcommand() {
let result = parse_command(&args("react_profile foo"), &default_flags());
assert!(result.is_err());
assert!(matches!(
result.unwrap_err(),
ParseError::UnknownSubcommand { .. }
));
}

#[test]
fn test_react_profile_missing_subcommand() {
let result = parse_command(&args("react_profile"), &default_flags());
assert!(result.is_err());
assert!(matches!(
result.unwrap_err(),
ParseError::MissingArguments { .. }
));
}

// === Eval Tests ===

#[test]
Expand Down
Loading
Loading