mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refactor test cases and improve snapshot handling
- Simplified the formatting of function calls in `encodePatchUpdate.spec.lua` for better readability. - Added multiple new snapshot files to enhance end-to-end testing for reference path changes, including scenarios for adding, removing, and handling nonexistent attributes. - Updated test cases in `apply.rs`, `compute.rs`, and `api.rs` to ensure consistent handling of reference properties and improve clarity in property updates. These changes enhance the maintainability of the test suite and improve the robustness of snapshot testing.
This commit is contained in:
parent
bbd9c0e0fa
commit
c181172460
11 changed files with 463 additions and 232 deletions
|
|
@ -633,12 +633,30 @@ impl ApiService {
|
|||
let updated_instances = request
|
||||
.updated
|
||||
.into_iter()
|
||||
.map(|update| PatchUpdate {
|
||||
id: update.id,
|
||||
changed_class_name: update.changed_class_name,
|
||||
changed_name: update.changed_name,
|
||||
changed_properties: update.changed_properties,
|
||||
changed_metadata: None,
|
||||
.map(|update| {
|
||||
// Convert nil Refs (Ref::none()) to property removals (None).
|
||||
//
|
||||
// In the two-way sync path, Ref::none() means "user explicitly
|
||||
// cleared this property" (e.g., set PrimaryPart to nil). But
|
||||
// apply_update_child skips nil Refs because in the forward-sync
|
||||
// path, Ref::none() is a sentinel for "unresolved ref."
|
||||
//
|
||||
// Converting to None ensures the property is actually removed
|
||||
// from the tree, keeping it consistent with the filesystem
|
||||
// (where the Rojo_Ref_* attribute was already removed).
|
||||
let mut changed_properties = update.changed_properties;
|
||||
for (_key, value) in changed_properties.iter_mut() {
|
||||
if matches!(value, Some(Variant::Ref(r)) if r.is_none()) {
|
||||
*value = None;
|
||||
}
|
||||
}
|
||||
PatchUpdate {
|
||||
id: update.id,
|
||||
changed_class_name: update.changed_class_name,
|
||||
changed_name: update.changed_name,
|
||||
changed_properties,
|
||||
changed_metadata: None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue