From f8c14cb82dff2fb37137cad374ebbd409bb997c7 Mon Sep 17 00:00:00 2001 From: demenik Date: Wed, 3 Dec 2025 22:34:07 +0100 Subject: [PATCH] test: Fix interaction tests for harvesting update --- tests/interaction.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/interaction.rs b/tests/interaction.rs index 7609fa8..9cab385 100644 --- a/tests/interaction.rs +++ b/tests/interaction.rs @@ -1,4 +1,5 @@ use bevy::ecs::system::RunSystemOnce; +use pomomon_garden::features::config::components::BerrySeedConfig; use pomomon_garden::features::grid::components::{Grid, Tile, TileState}; use pomomon_garden::features::inventory::components::{Inventory, ItemStack, ItemType}; use pomomon_garden::features::pom::actions::InteractionAction; @@ -49,6 +50,16 @@ fn setup_interaction_app( items: inventory_items, }); + let mut game_config = GameConfig::default(); + game_config.berry_seeds.push(BerrySeedConfig { + name: "TestSeed".to_string(), + cost: 1, + grants: 1, + slice: "seed.aseprite".to_string(), + growth_stages: 2, + }); + app.insert_resource(game_config); + app } @@ -64,13 +75,13 @@ fn test_plant_seed_interaction() { vec![(seed_type.clone(), 1)], ); - // Run the interaction logic as a system or closure let _ = app.world_mut().run_system_once( move |grid: Res, mut tile_query: Query<&mut TileState>, mut inventory: ResMut, mut item_stack_query: Query<&mut ItemStack>, - mut commands: Commands| { + mut commands: Commands, + game_config: Res| { let action = InteractionAction::Plant(seed_type.clone()); action.execute( (1, 1), @@ -79,6 +90,7 @@ fn test_plant_seed_interaction() { &mut inventory, &mut item_stack_query, &mut commands, + &game_config, ); }, ); @@ -138,7 +150,8 @@ fn test_plant_seed_no_inventory() { mut tile_query: Query<&mut TileState>, mut inventory: ResMut, mut item_stack_query: Query<&mut ItemStack>, - mut commands: Commands| { + mut commands: Commands, + game_config: Res| { let action = InteractionAction::Plant(seed_type.clone()); action.execute( (1, 1), @@ -147,6 +160,7 @@ fn test_plant_seed_no_inventory() { &mut inventory, &mut item_stack_query, &mut commands, + &game_config, ); }, ); @@ -192,10 +206,11 @@ fn test_water_crop() { move |grid: Res, tile_query: Query<&TileState>, inventory: Res, - item_query: Query<&ItemStack>| { + item_query: Query<&ItemStack>, + game_config: Res| { let tile_entity = grid.get_tile((1, 1)).unwrap(); let tile_state = tile_query.get(tile_entity).unwrap(); - let options = InteractionAction::list_options(tile_state, &inventory, item_query); + let options = InteractionAction::list_options(tile_state, &inventory, item_query, &game_config); assert!( options.contains(&InteractionAction::Water), @@ -210,7 +225,8 @@ fn test_water_crop() { mut tile_query: Query<&mut TileState>, mut inventory: ResMut, mut item_stack_query: Query<&mut ItemStack>, - mut commands: Commands| { + mut commands: Commands, + game_config: Res| { let action = InteractionAction::Water; action.execute( (1, 1), @@ -219,6 +235,7 @@ fn test_water_crop() { &mut inventory, &mut item_stack_query, &mut commands, + &game_config, ); }, ); @@ -241,10 +258,11 @@ fn test_water_crop() { move |grid: Res, tile_query: Query<&TileState>, inventory: Res, - item_query: Query<&ItemStack>| { + item_query: Query<&ItemStack>, + game_config: Res| { let tile_entity = grid.get_tile((1, 1)).unwrap(); let tile_state = tile_query.get(tile_entity).unwrap(); - let options = InteractionAction::list_options(tile_state, &inventory, item_query); + let options = InteractionAction::list_options(tile_state, &inventory, item_query, &game_config); assert!( !options.contains(&InteractionAction::Water),