package guitests.guihandles;

import guitests.GuiRobot;
import javafx.scene.input.KeyCode;
import javafx.stage.Stage;
import seedu.taskitty.TestApp;

import java.util.Arrays;

/**
 * Provides a handle to the main menu of the app.
 */
public class MainMenuHandle extends GuiHandle {
    public MainMenuHandle(GuiRobot guiRobot, Stage primaryStage) {
        super(guiRobot, primaryStage, TestApp.APP_TITLE);
    }

    public GuiHandle clickOn(String... menuText) {
        Arrays.stream(menuText).forEach((menuItem) -> guiRobot.clickOn(menuItem));
        return this;
    }

    public HelpWindowHandle openHelpWindowUsingMenu() {
        clickOn("Help", "F1");
        return new HelpWindowHandle(guiRobot, primaryStage);
    }

    public HelpWindowHandle openHelpWindowUsingAccelerator() {
        useF1Accelerator();
        return new HelpWindowHandle(guiRobot, primaryStage);
    }
    
    public void useClearCommandUsingAccelerator() {
        guiRobot.push(KeyCode.CONTROL, KeyCode.SHIFT, KeyCode.C);
        guiRobot.sleep(500);
    }
    
    public void useUndoCommandUsingAccelerator() {
        guiRobot.push(KeyCode.CONTROL, KeyCode.SHIFT, KeyCode.Z);
        guiRobot.sleep(500);
    }
    
    private void useF1Accelerator() {
        guiRobot.push(KeyCode.F1);
        guiRobot.sleep(500);
    }
      
}

@@ -794,26 +794,24 @@
 %0A        use
-F1
 Accelerator(
@@ -810,16 +810,20 @@
 lerator(
+%22F1%22
 );%0A     
@@ -953,63 +953,43 @@
     
-guiRobot.push(KeyCode.CONTROL, KeyCode.SHIFT, KeyCode.C
+useAccelerator(%22Ctrl%22, %22Shift%22, %22C%22
 );%0A 
@@ -1090,63 +1090,43 @@
     
-guiRobot.push(KeyCode.CONTROL, KeyCode.SHIFT, KeyCode.Z
+useAccelerator(%22Ctrl%22, %22Shift%22, %22Z%22
 );%0A 
@@ -1160,24 +1160,29 @@
 %0A    %7D%0A    %0A
+    %0A
     private 
@@ -1189,18 +1189,16 @@
 void use
-F1
 Accelera
@@ -1205,44 +1205,264 @@
 tor(
-) %7B%0A        guiRobot.push(KeyCode.F1
+String... buttonsToPress) %7B%0A        KeyCode%5B%5D buttons = new KeyCode%5BbuttonsToPress.length%5D;%0A        for (int i = 0; i %3C buttonsToPress.length; i++) %7B%0A            buttons%5Bi%5D = KeyCode.getKeyCode(buttonsToPress%5Bi%5D);%0A        %7D   %0A        guiRobot.push(buttons
 );%0A 
@@ -1494,18 +1494,18 @@
 );%0A    %7D
-%0A
   
+%0A
     %0A%7D%0A

Add new method useAccelerator in MainMenuHandle and update other relevant methods inside to call it