Merge story-29: Backfill tests for maximum coverage
Adds 57 Rust tests and 60 frontend tests across 4 batches: - Batch 1: store, search, workflow - Batch 2: fs, shell, http/workflow - Batch 3: usePathCompletion, api/client, api/workflow - Batch 4: App, GatePanel, ReviewPanel Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -450,3 +450,108 @@ fn parse_test_status(value: &str) -> Result<TestStatus, String> {
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::workflow::{StoryTestResults, TestCaseResult, TestStatus};
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_pass() {
|
||||
assert_eq!(parse_test_status("pass").unwrap(), TestStatus::Pass);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_fail() {
|
||||
assert_eq!(parse_test_status("fail").unwrap(), TestStatus::Fail);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_invalid() {
|
||||
let result = parse_test_status("unknown");
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("Invalid test status"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_test_case_converts_pass() {
|
||||
let payload = TestCasePayload {
|
||||
name: "my_test".to_string(),
|
||||
status: "pass".to_string(),
|
||||
details: Some("all good".to_string()),
|
||||
};
|
||||
let result = to_test_case(payload).unwrap();
|
||||
assert_eq!(result.name, "my_test");
|
||||
assert_eq!(result.status, TestStatus::Pass);
|
||||
assert_eq!(result.details, Some("all good".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_test_case_rejects_invalid_status() {
|
||||
let payload = TestCasePayload {
|
||||
name: "bad".to_string(),
|
||||
status: "maybe".to_string(),
|
||||
details: None,
|
||||
};
|
||||
assert!(to_test_case(payload).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_all_passing() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![TestCaseResult {
|
||||
name: "i1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(review.can_accept);
|
||||
assert!(review.reasons.is_empty());
|
||||
assert!(review.missing_categories.is_empty());
|
||||
assert_eq!(review.summary.total, 2);
|
||||
assert_eq!(review.summary.passed, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_missing_integration() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(!review.can_accept);
|
||||
assert!(review.missing_categories.contains(&"integration".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_with_failures() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Fail,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![TestCaseResult {
|
||||
name: "i1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(!review.can_accept);
|
||||
assert_eq!(review.summary.failed, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user