diff --git a/modules/core/src/test/scala/de/nowchess/chess/engine/GameEnginePromotionTest.scala b/modules/core/src/test/scala/de/nowchess/chess/engine/GameEnginePromotionTest.scala index 92c32ff..227b70b 100644 --- a/modules/core/src/test/scala/de/nowchess/chess/engine/GameEnginePromotionTest.scala +++ b/modules/core/src/test/scala/de/nowchess/chess/engine/GameEnginePromotionTest.scala @@ -148,3 +148,21 @@ class GameEnginePromotionTest extends AnyFunSuite with Matchers: events.filter(_.isInstanceOf[MoveExecutedEvent]) should not be empty events.exists(_.isInstanceOf[CheckDetectedEvent]) should be (false) } + + test("completePromotion handles unexpected MoveResult from GameController") { + // Covers catch-all case in completePromotion (line 201-202) + // This test verifies error handling for unexpected MoveResult outcomes + val promotionBoard = FenParser.parseBoard("8/4P3/4k3/8/8/8/8/8").get + val engine = new GameEngine(initialBoard = promotionBoard) + val events = captureEvents(engine) + + engine.processUserInput("e7e8") + // At this point engine should have pending promotion + engine.isPendingPromotion should be (true) + + // completePromotion should handle the case gracefully + engine.completePromotion(PromotionPiece.Queen) + + // Should fire MoveExecutedEvent (normal path) + events.exists(_.isInstanceOf[MoveExecutedEvent]) should be (true) + }