@@ -256,6 +256,39 @@ void handles_restart_action() {
256256 then (controller .getWorker ().getColumn ()).isEqualTo (initialColumn );
257257 }
258258
259+ @ Test
260+ void can_undo_the_last_move () {
261+ // given - make a move
262+ int initialLine = controller .getWorker ().getLine ();
263+ int initialColumn = controller .getWorker ().getColumn ();
264+
265+ // Move right
266+ KeyEvent rightKey = new KeyEvent (window ,
267+ KeyEvent .KEY_PRESSED ,
268+ System .currentTimeMillis (),
269+ 0 ,
270+ KeyEvent .VK_RIGHT ,
271+ KeyEvent .CHAR_UNDEFINED );
272+ window .keyPressed (rightKey );
273+
274+ // when - press space to step back
275+ KeyEvent spaceKey = new KeyEvent (window ,
276+ KeyEvent .KEY_PRESSED ,
277+ System .currentTimeMillis (),
278+ 0 ,
279+ KeyEvent .VK_SPACE ,
280+ KeyEvent .CHAR_UNDEFINED );
281+ window .keyPressed (spaceKey );
282+
283+ // then - worker should be back at initial position
284+ then (controller .getWorker ().getLine ())
285+ .as ("line position is restored when undoing last move" )
286+ .isEqualTo (initialLine );
287+ then (controller .getWorker ().getColumn ())
288+ .as ("column position is restored when undoing last move" )
289+ .isEqualTo (initialColumn );
290+ }
291+
259292 @ Test
260293 void completing_a_custom_level_disposes_window_and_shows_home_window () {
261294 // given - create a test window with the simplified level that only needs one push
0 commit comments