story 2-12-preview-partial-mode: implemented and reviewed via bmad-loop
This commit is contained in:
1 parent
d1ba0bd0e4
commit
ab35d67177
56 files changed
+5801
-376
No files matched your search
@@ -196,7 +196,16 @@ fn ac_2_manifest_covers_fifty_provenanced_specs_with_exact_expectations() {
|
||||
"corpus fixtures are single-operation exact oracles"
|
||||
);
|
||||
let expected = &document.expected_preview["operations"][0];
|
||||
let actual_candidate = serde_json::to_value(candidates[0]).unwrap();
|
||||
let mut actual_candidate = serde_json::to_value(candidates[0]).unwrap();
|
||||
// Corpus snapshots freeze the pre-location semantic candidate.
|
||||
// Source provenance is covered by dedicated preview assertions.
|
||||
actual_candidate
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("source_location");
|
||||
for finding in actual_candidate["findings"].as_array_mut().unwrap() {
|
||||
finding.as_object_mut().unwrap().remove("source_location");
|
||||
}
|
||||
assert_eq!(
|
||||
actual_candidate,
|
||||
expected["candidate"],
|
||||
@@ -224,13 +233,24 @@ fn ac_2_manifest_covers_fifty_provenanced_specs_with_exact_expectations() {
|
||||
"candidate canonical digest in {}",
|
||||
document.file
|
||||
);
|
||||
let mut actual_preview = serde_json::to_value(&preview).unwrap();
|
||||
for group in actual_preview["groups"].as_array_mut().unwrap() {
|
||||
for candidate in group["operations"].as_array_mut().unwrap() {
|
||||
candidate.as_object_mut().unwrap().remove("source_location");
|
||||
for finding in candidate["findings"].as_array_mut().unwrap() {
|
||||
finding.as_object_mut().unwrap().remove("source_location");
|
||||
}
|
||||
}
|
||||
}
|
||||
for finding in actual_preview["findings"].as_array_mut().unwrap() {
|
||||
finding.as_object_mut().unwrap().remove("source_location");
|
||||
}
|
||||
assert_eq!(
|
||||
hex(canonical_json(&serde_json::to_value(&preview).unwrap())),
|
||||
hex(canonical_json(&actual_preview)),
|
||||
document.expected_preview["canonical_preview_digest"],
|
||||
"preview canonical digest in {}",
|
||||
document.file
|
||||
);
|
||||
let actual_preview = serde_json::to_value(&preview).unwrap();
|
||||
assert_eq!(
|
||||
actual_preview,
|
||||
document.expected_preview["canonical_preview"],
|
||||
|
||||
@@ -96,6 +96,19 @@ definitions:
|
||||
assert_eq!(operation.draft.input_mapping.rules.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn historical_preview_without_locations_still_deserializes() {
|
||||
let old = serde_json::to_value(preview_document_legacy_v1(OPENAPI3).unwrap()).unwrap();
|
||||
let replay: crank_import::rest::ImportPreview = serde_json::from_value(old).unwrap();
|
||||
assert!(replay.groups[0].operations[0].source_location.is_none());
|
||||
assert!(
|
||||
replay.groups[0].operations[0]
|
||||
.findings
|
||||
.iter()
|
||||
.all(|finding| finding.source_location.is_none())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn previews_swagger2_and_resolves_local_definitions() {
|
||||
let preview = preview_document(SWAGGER2).unwrap();
|
||||
@@ -511,6 +524,26 @@ paths:
|
||||
assert!(codes.contains(&"missing_summary"));
|
||||
assert!(codes.contains(&"missing_description"));
|
||||
assert!(codes.contains(&"missing_response_schema"));
|
||||
assert_eq!(
|
||||
operation
|
||||
.source_location
|
||||
.as_ref()
|
||||
.map(|location| location.pointer.as_str()),
|
||||
Some("/paths/~1items/get")
|
||||
);
|
||||
assert!(operation.findings.iter().any(|finding| {
|
||||
finding.code == "missing_operation_id"
|
||||
&& finding
|
||||
.source_location
|
||||
.as_ref()
|
||||
.is_some_and(|location| location.pointer == "/paths/~1items/get/operationId")
|
||||
}));
|
||||
assert!(
|
||||
operation
|
||||
.findings
|
||||
.iter()
|
||||
.all(|finding| finding.source_location.is_some())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -656,6 +689,13 @@ paths:
|
||||
.filter(|finding| finding.code == "unsupported_http_method")
|
||||
.count();
|
||||
assert_eq!(unsupported, 2);
|
||||
assert!(preview.findings.iter().any(|finding| {
|
||||
finding.code == "unsupported_http_method"
|
||||
&& finding
|
||||
.source_location
|
||||
.as_ref()
|
||||
.is_some_and(|location| location.pointer == "/paths/~1health/trace")
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user