package de.bmoth.app;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.junit.Ignore;
import org.junit.Test;

import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.base.NodeMatchers.*;

public class AppControllerTest extends HeadlessUITest {

    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("app.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 500, 300);
        AppController appController = loader.getController();
        appController.setupStage(stage);
        stage.setScene(scene);
        stage.show();
    }

    @Test
    public void clickingOptionsOpensDialog() {
        clickOn("#fileMenu");
        clickOn("#options");

        verifyThat("#minInt", isNotNull());
        clickOn("Close");
        verifyThat("#minInt", isNull());
    }

    @Test
    public void checkChangesDetected() {
        clickOn("#codeArea").write(" ");
        verifyThat("#infoArea", hasText("Unsaved changes"));
    }

    @Test
    @Ignore("this test confuses the other repl tests, because it does not close the repl window")
    public void clickingReplOpensRepl() {
        verifyThat("#replText", isNull());

        clickOn("#replMenu").clickOn("#openRepl");

        verifyThat("#replText", isNotNull());
    }
}

@@ -47,16 +47,42 @@
 Loader;%0A
+import javafx.scene.Node;%0A
 import j
@@ -159,33 +159,8 @@
 ge;%0A
-import org.junit.Ignore;%0A
 impo
@@ -1147,106 +1147,8 @@
 est%0A
-    @Ignore(%22this test confuses the other repl tests, because it does not close the repl window%22)%0A
     
@@ -1182,16 +1182,44 @@
 nsRepl()
+ throws InterruptedException
  %7B%0A     
@@ -1350,21 +1350,348 @@
 sNotNull());
+%0A%0A        // close the repl window so that later tests are not confused%0A        Node repl = lookup(%22REPL%22).query();%0A        interact(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Stage scene = (Stage) repl.getScene().getWindow();%0A                scene.close();%0A            %7D%0A        %7D);
 %0A    %7D%0A%7D%0A

fix ignored tests and enable it again