Skip to content

Commit 7afc97c

Browse files
zachcpclaude
andcommitted
test(molviewspec_viewer): add preset + executor verification tests
Seven tests covering the Phase 4 viewer example: - each of the five presets serializes to JSON that the executor's own State::from_str parse path accepts - component/label/transform tree structure assertions - collapsible tree-inspector logic - end-to-end: Basic preset (real 1cbs.cif) rendered through MvsPlugin spawns meshes and its focus node repositions the orbit camera Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2c08a66 commit 7afc97c

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

crates/ferritin-examples/examples/bevy/molviewspec_viewer.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,45 @@ mod tests {
11251125
assert!(tree_has_camera_or_focus(&state.root));
11261126
}
11271127

1128+
/// End-to-end: run the Basic preset (with a real extracted 1cbs.cif) through
1129+
/// the actual `MvsPlugin` executor and confirm it spawns rendered meshes.
1130+
#[test]
1131+
fn test_preset_basic_renders_meshes_through_executor() {
1132+
use ferritin_bevy::MvsEntity;
1133+
1134+
let (path, _handle) = TestFile::mvs_1cbs()
1135+
.create_temp()
1136+
.expect("extract 1cbs.cif");
1137+
let json = preset_basic(&path);
1138+
1139+
let mut app = App::new();
1140+
app.add_plugins(bevy::MinimalPlugins);
1141+
app.add_plugins(bevy::asset::AssetPlugin::default());
1142+
app.add_plugins(MvsPlugin);
1143+
1144+
app.world_mut()
1145+
.write_message(LoadMvsEvent::FromString(json));
1146+
app.update();
1147+
1148+
let mesh_count = app
1149+
.world_mut()
1150+
.query_filtered::<Entity, (With<Mesh3d>, With<MvsEntity>)>()
1151+
.iter(app.world())
1152+
.count();
1153+
assert!(
1154+
mesh_count >= 1,
1155+
"Basic preset must render at least one mesh, got {mesh_count}"
1156+
);
1157+
1158+
// The focus node should have moved the orbit camera off its default.
1159+
let orbit = app.world().resource::<OrbitCamera>().clone();
1160+
assert_ne!(
1161+
orbit,
1162+
OrbitCamera::default(),
1163+
"focus node must reposition the orbit camera"
1164+
);
1165+
}
1166+
11281167
#[test]
11291168
fn test_collapsed_node_hides_descendants() {
11301169
let state = assert_preset_parses(&preset_basic("/tmp/1cbs.cif"));

0 commit comments

Comments
 (0)