From 7336474ed5f2f006f2dbc3e29d2445a03b5d183b Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Wed, 14 Aug 2024 17:09:44 +0200 Subject: [PATCH] fix: IdeaProject folder getting cleared fix: click to gain focus added fix: createDirectories in clearWorkspace fix: project location during tests Signed-off-by: Martin Szuc --- .../commonuitest/fixtures/dialogs/FlatWelcomeFrame.java | 5 +++-- .../test/dialogs/information/CodeWithMeDialogTest.java | 2 ++ .../test/mainidewindow/idestatusbar/IdeStatusBarTest.java | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java index 4b239188..bf5dd79d 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java @@ -22,6 +22,7 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.pages.NotificationsPage; import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; +import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion; import com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps; import org.apache.commons.io.FileUtils; @@ -100,12 +101,12 @@ public void clickOnLink(String label) { public void clearWorkspace() { // Remove projects on disk try { - String pathToDirToMakeEmpty = System.getProperty("user.home") + File.separator + "IdeaProjects"; + String pathToDirToMakeEmpty = CreateCloseUtils.PROJECT_LOCATION; boolean doesProjectDirExists = Files.exists(Paths.get(pathToDirToMakeEmpty)); if (doesProjectDirExists) { FileUtils.cleanDirectory(new File(pathToDirToMakeEmpty)); } else { - Files.createDirectory(Paths.get(pathToDirToMakeEmpty)); + Files.createDirectories(Paths.get(pathToDirToMakeEmpty)); } } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java index da0bcf76..b6524a8d 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java @@ -45,7 +45,9 @@ public static void prepareProject() { if (UITestRunner.getIdeaVersionInt() >= 20221) { newProjectFirstPage.selectNewProjectType("New Project"); + newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage newProjectFirstPage.setProjectName(PROJECT_NAME); + newProjectFirstPage.setProjectLocation(CreateCloseUtils.PROJECT_LOCATION); newProjectFirstPage.setLanguage("Java"); newProjectFirstPage.setBuildSystem("IntelliJ"); newProjectFirstPage.setProjectSdkIfAvailable("11"); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java index a6c3cd27..4281cfe1 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java @@ -50,7 +50,10 @@ public void prepareProject() { NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); if (UITestRunner.getIdeaVersionInt() >= 20221) { + newProjectFirstPage.selectNewProjectType("New Project"); + newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage newProjectFirstPage.setProjectName(PROJECT_NAME); + newProjectFirstPage.setProjectLocation(CreateCloseUtils.PROJECT_LOCATION); newProjectFirstPage.selectNewProjectType("New Project"); newProjectFirstPage.setBuildSystem("Maven"); } else {