From 5909d859a33ef7657f819b5d66bf2c63b1d747ad Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Tue, 29 Oct 2024 16:16:37 +0100 Subject: [PATCH] tests: disable service tests (#933) Signed-off-by: Stephane Bouchet --- .github/workflows/ci.yml | 4 +- .../cluster_integration_ui_tests.yml | 19 ++----- .../workflows/public_integration_ui_tests.yml | 10 ++-- .../openshift/test/ui/AbstractBaseTest.java | 17 ------ .../openshift/test/ui/ClusterTestsSuite.java | 16 +++++- .../openshift/test/ui/PublicTestsSuite.java | 16 +++++- .../ui/common/CreateComponentFixture.java | 41 -------------- ...mportProjectFromVersionControlFixture.java | 44 --------------- .../test/ui/common/ProjectTreeFixture.java | 47 ---------------- .../test/ui/common/WelcomeDialogFixture.java | 38 ------------- .../test/ui/dialogs/ClusterLoginDialog.java | 24 ++++----- .../cluster_project/ChangeProjectDialog.java | 22 +++++++- .../CreateNewProjectDialog.java | 20 +++++-- .../cluster_project/DeleteProjectDialog.java | 18 +++++-- .../component/CreateComponentDialog.java | 31 +++-------- .../service/CreateNewServiceDialog.java | 40 +++++++------- .../ui/tests_cluster/AboutClusterTest.java | 3 +- .../ui/tests_cluster/AbstractClusterTest.java | 5 +- .../ui/tests_cluster/CreateComponentTest.java | 18 +++++-- .../ui/tests_cluster/CreateServiceTest.java | 14 ++++- .../ui/tests_cluster/ProjectClusterTest.java | 10 ++-- .../test/ui/tests_public/AboutPublicTest.java | 8 ++- .../ClusterLoginDialogPublicTest.java | 6 ++- .../ui/tests_public/GettingStartedTest.java | 9 +++- .../tests_public/OpenshiftExtensionTest.java | 25 +++++++-- .../test/ui/utils/CleanUpUtility.java | 1 - .../test/ui/utils/KubeConfigUtility.java | 6 ++- .../test/ui/utils/ProjectUtility.java | 54 ------------------- .../ui/utils/constants/XPathConstants.java | 43 +++++++++++---- .../test/ui/views/GettingStartedView.java | 32 +++++++---- .../test/ui/views/OpenshiftView.java | 39 ++++++++------ .../openshift/utils/helm/HelmCliRepoTest.java | 5 +- .../utils/odo/OdoCliComponentTest.java | 6 ++- .../utils/odo/OdoCliServiceTest.java | 8 ++- .../openshift/utils/odo/OdoCliTest.java | 12 ++--- 35 files changed, 303 insertions(+), 408 deletions(-) delete mode 100644 src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/CreateComponentFixture.java delete mode 100644 src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ImportProjectFromVersionControlFixture.java delete mode 100644 src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ProjectTreeFixture.java delete mode 100644 src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/WelcomeDialogFixture.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 779ad9ec6..c7e7007bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew build --continue --no-daemon + run: ./gradlew build --continue - uses: actions/upload-artifact@v4 if: always() with: @@ -91,7 +91,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Play integration tests - run: ./gradlew integrationTest --continue --no-daemon + run: ./gradlew integrationTest --continue - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/cluster_integration_ui_tests.yml b/.github/workflows/cluster_integration_ui_tests.yml index adb6e0d5e..11b051b8b 100644 --- a/.github/workflows/cluster_integration_ui_tests.yml +++ b/.github/workflows/cluster_integration_ui_tests.yml @@ -1,11 +1,11 @@ -name: Cluster Integration UI Tests +name: Integration UI Tests with Local Kind Cluster Context on: workflow_run: workflows: [ "Java CI with Gradle" ] types: - completed jobs: - kubernetes-integration-ui-tests: + cluster-integration-ui-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -23,19 +23,6 @@ jobs: validate-wrappers: true - uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde #v1.10.0 name: Start cluster - - name: Setup cluster - run: | - curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.26.0/install.sh | bash -s v0.26.0 - kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml - kubectl create -f https://operatorhub.io/install/stable/cloud-native-postgresql.yaml - nb=0 - echo -n "Waiting for operator to show up " - while [ "$nb" != "2" ] - do - echo -n "." - sleep 1 - nb=`kubectl get pods -n operators --no-headers --ignore-not-found | grep Running | wc -l` - done - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Play cluster integration UI tests @@ -47,7 +34,7 @@ jobs: export DISPLAY=:99.0 Xvfb -ac :99 -screen 0 1920x1080x16 & sleep 10 - ./gradlew clusterIntegrationUITest --continue --no-daemon --info + ./gradlew clusterIntegrationUITest --continue - name: Publish tests reports if: always() uses: scacap/action-surefire-report@a2911bd1a4412ec18dde2d93b1758b3e56d2a880 #v1.8.0 diff --git a/.github/workflows/public_integration_ui_tests.yml b/.github/workflows/public_integration_ui_tests.yml index 650fcc874..c181bcfee 100644 --- a/.github/workflows/public_integration_ui_tests.yml +++ b/.github/workflows/public_integration_ui_tests.yml @@ -1,11 +1,11 @@ -name: Public Integration UI Tests +name: Integration UI Tests with No Context on: workflow_run: workflows: [ "Java CI with Gradle" ] types: - completed jobs: - public-integration-ui-tests: + no-context-integration-ui-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -23,7 +23,7 @@ jobs: validate-wrappers: true - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Play public integration UI tests + - name: Play integration UI tests env: GPG_PASSPHRASE: ${{ secrets.IDEA_KEY_PASSPHRASE }} run: | @@ -31,7 +31,7 @@ jobs: export DISPLAY=:99.0 Xvfb -ac :99 -screen 0 1920x1080x16 & sleep 10 - ./gradlew publicIntegrationUITest --continue --no-daemon + ./gradlew publicIntegrationUITest --continue - name: Publish tests reports if: always() uses: scacap/action-surefire-report@a2911bd1a4412ec18dde2d93b1758b3e56d2a880 #v1.8.0 @@ -39,7 +39,7 @@ jobs: github_token: ${{secrets.GITHUB_TOKEN}} report_paths: '${{github.workspace}}/build/test-results/**/TEST-*.xml' commit: ${{github.event.workflow_run.head_sha}} - check_name: Public Integration UI Tests Report + check_name: Integration UI Tests with No Context Report - name: Publish screenshots as artifacts if: failure() uses: actions/upload-artifact@v4 diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/AbstractBaseTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/AbstractBaseTest.java index 3b0fd7567..65b6e7439 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/AbstractBaseTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/AbstractBaseTest.java @@ -11,10 +11,8 @@ package org.jboss.tools.intellij.openshift.test.ui; import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils; import org.jboss.tools.intellij.openshift.test.ui.annotations.UITest; @@ -37,7 +35,6 @@ import java.io.File; import java.time.Duration; - /** * @author Ondrej Dockal, odockal@redhat.com */ @@ -110,20 +107,6 @@ protected static void logOut() { } } - public RemoteRobot getRobotReference() { - return robot; - } - - public boolean isStripeButtonAvailable(String label) { - try { - ToolWindowPane toolWindowPane = robot.find(ToolWindowPane.class); - toolWindowPane.stripeButton(label, false); - } catch (WaitForConditionTimeoutException e) { - return false; - } - return true; - } - protected static void sleep(long ms) { LOGGER.info("Putting thread into sleep for: {} ms", ms); try { diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/ClusterTestsSuite.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/ClusterTestsSuite.java index eabdf2c79..9a895e781 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/ClusterTestsSuite.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/ClusterTestsSuite.java @@ -1,6 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui; -import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.*; +import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.AboutClusterTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.CreateComponentTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.CreateServiceTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.LoginClusterTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_cluster.ProjectClusterTest; import org.jboss.tools.intellij.openshift.test.ui.utils.KubeConfigUtility; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/PublicTestsSuite.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/PublicTestsSuite.java index b12c55920..ffe0e2a5f 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/PublicTestsSuite.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/PublicTestsSuite.java @@ -1,5 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui; -import org.jboss.tools.intellij.openshift.test.ui.tests_public.*; + +import org.jboss.tools.intellij.openshift.test.ui.tests_public.AboutPublicTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_public.ClusterLoginDialogPublicTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_public.GettingStartedTest; +import org.jboss.tools.intellij.openshift.test.ui.tests_public.OpenshiftExtensionTest; import org.jboss.tools.intellij.openshift.test.ui.utils.KubeConfigUtility; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/CreateComponentFixture.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/CreateComponentFixture.java deleted file mode 100644 index 50c972ec0..000000000 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/CreateComponentFixture.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.intellij.openshift.test.ui.common; - -import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.intellij.remoterobot.fixtures.ContainerFixture; -import com.intellij.remoterobot.fixtures.DefaultXpath; -import com.intellij.remoterobot.fixtures.FixtureName; -import org.jetbrains.annotations.NotNull; - -import java.time.Duration; - -import static com.intellij.remoterobot.search.locators.Locators.byXpath; - -/** - * - * @author Ihor Okhrimenko - * - */ -@DefaultXpath(by = "CreateComponentFixture type", xpath = "//div[@class='MyDialog']") -@FixtureName(name = "Create Component") -public class CreateComponentFixture extends ContainerFixture { - public CreateComponentFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - public void clickToFinishButton(){ - find(ComponentFixture.class, byXpath("//div[@text='Finish']"), Duration.ofSeconds(30)).click(); - } - -} diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ImportProjectFromVersionControlFixture.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ImportProjectFromVersionControlFixture.java deleted file mode 100644 index 4c8f9c5b4..000000000 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ImportProjectFromVersionControlFixture.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.intellij.openshift.test.ui.common; - -import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.intellij.remoterobot.fixtures.ContainerFixture; -import com.intellij.remoterobot.fixtures.DefaultXpath; -import com.intellij.remoterobot.fixtures.FixtureName; -import com.intellij.remoterobot.fixtures.JTextFieldFixture; -import org.jetbrains.annotations.NotNull; -import java.time.Duration; -import static com.intellij.remoterobot.search.locators.Locators.byXpath; - -/** - * - * @author Ihor Okhrimenko - * - */ -@DefaultXpath(by = "ImportProjectFromVersionControlFixture type", xpath = "//div[@class='MyDialog']") -@FixtureName(name = "Import Project") -public class ImportProjectFromVersionControlFixture extends ContainerFixture { - public ImportProjectFromVersionControlFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - public void typeUrl(){ - find(JTextFieldFixture.class, byXpath("//div[@class='BorderlessTextField']"), Duration.ofSeconds(30)).setText("https://github.com/maxura/nodejs-hello-world.git"); - } - - public void clickCloneButton(){ - find(ComponentFixture.class, byXpath("//div[@text='Clone']"), Duration.ofSeconds(30)).click(); - } - -} diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ProjectTreeFixture.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ProjectTreeFixture.java deleted file mode 100644 index 8cc9c8ccc..000000000 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/ProjectTreeFixture.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.intellij.openshift.test.ui.common; - -import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ContainerFixture; -import com.intellij.remoterobot.fixtures.DefaultXpath; -import com.intellij.remoterobot.fixtures.FixtureName; -import com.intellij.remoterobot.fixtures.JTreeFixture; -import org.jetbrains.annotations.NotNull; -import java.time.Duration; -import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; - -/** - * - * @author Ihor Okhrimenko - * - */ -@DefaultXpath(by = "ProjectTreeFixture type", xpath = "//div[@class='ThreeComponentsSplitter']//div[@class='InternalDecorator']") -@FixtureName(name = "Project Tree Component") -public class ProjectTreeFixture extends ContainerFixture{ - public ProjectTreeFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - public void waitItemInTree(String itemText, int timeout, int pollingTimeout){ - waitFor(Duration.ofSeconds(timeout), - Duration.ofSeconds(pollingTimeout), - "The node-js project is not still available.", - () -> getProjectTree().hasText(itemText)); - } - - private JTreeFixture getProjectTree(){ - return find(JTreeFixture.class, byXpath("//div[@class='ProjectViewTree']"), Duration.ofSeconds(60)); - } - -} diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/WelcomeDialogFixture.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/WelcomeDialogFixture.java deleted file mode 100644 index 5f905d3c9..000000000 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/common/WelcomeDialogFixture.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.intellij.openshift.test.ui.common; - -import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.intellij.remoterobot.fixtures.ContainerFixture; -import org.jetbrains.annotations.NotNull; -import com.intellij.remoterobot.fixtures.DefaultXpath; -import com.intellij.remoterobot.fixtures.FixtureName; -import java.time.Duration; -import static com.intellij.remoterobot.search.locators.Locators.byXpath; - -/** - * - * @author Ihor Okhrimenko - * - */ -@DefaultXpath(by = "WelcomeDialogFixture type", xpath = "//div[@class='FlatWelcomeFrame']") -@FixtureName(name = "Welcome To IntelliJ IDEA Dialog") -public class WelcomeDialogFixture extends ContainerFixture { - public WelcomeDialogFixture(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - public void clickToVcsButton(){ - find(ComponentFixture.class, byXpath("//div[@defaulticon='fromVCSTab.svg']"), Duration.ofSeconds(30)).click(); - } -} diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/ClusterLoginDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/ClusterLoginDialog.java index f88ad3cac..5d764ca22 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/ClusterLoginDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/ClusterLoginDialog.java @@ -12,9 +12,11 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; -import org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants; -import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JTextFieldFixture; import org.jboss.tools.intellij.openshift.test.ui.views.OpenshiftView; import org.jetbrains.annotations.NotNull; @@ -22,8 +24,13 @@ import java.util.List; import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.*; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.CANCEL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.DEVFILE_REGISTRIES; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.LOG_IN_TO_CLUSTER; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.BUTTON_PASTE_LOGIN_COMMAND; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.JPASSWORD_FIELD; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.JTEXT_FIELD; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.MYDIALOG_CLASS; /** @@ -57,13 +64,6 @@ public void insertURL(String clusterURL) { urlField.setText(clusterURL); } - public void insertToken(String clusterToken) { - List passwordFields = findAll(JTextFieldFixture.class, byXpath(JPASSWORD_FIELD)); - JTextFieldFixture tokenField = passwordFields.get(0); - tokenField.click(); - tokenField.setText(clusterToken); - } - public void insertUsername(String username) { JTextFieldFixture usernameField = findAll(JTextFieldFixture.class, byXpath(JTEXT_FIELD)).get(1); usernameField.click(); diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/ChangeProjectDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/ChangeProjectDialog.java index 9a7169603..946f118f4 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/ChangeProjectDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/ChangeProjectDialog.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.dialogs.cluster_project; import com.intellij.remoterobot.RemoteRobot; @@ -30,13 +40,21 @@ public void enterProjectName(RemoteRobot remoteRobot, String projectName) { // Use RemoteRobot's Keyboard to type the project name Keyboard keyboard = new Keyboard(remoteRobot); keyboard.enterText(projectName); + if (isDropdownMenuOpened()) { + keyboard.enter(); // Hide the dropdown menu with suggestions + } } public void clickChange() { find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CHANGE)).click(); } - public void clickCancel() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CANCEL)).click(); + private boolean isDropdownMenuOpened() { + try { + this.find(ComponentFixture.class, byXpath(XPathConstants.HEAVY_WEIGHT_WINDOW)); + return true; + } catch (Exception ignored) { + return false; + } } } \ No newline at end of file diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/CreateNewProjectDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/CreateNewProjectDialog.java index f86dd7c61..cb0868b5f 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/CreateNewProjectDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/CreateNewProjectDialog.java @@ -1,8 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.dialogs.cluster_project; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JTextFieldFixture; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jetbrains.annotations.NotNull; @@ -25,10 +39,6 @@ public void enterProjectName(String projectName) { projectNameField.setText(projectName); } - public void clickCancel() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CANCEL)).click(); - } - public void clickCreate() { find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CREATE)).click(); } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/DeleteProjectDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/DeleteProjectDialog.java index b3d46ac9e..727955bdd 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/DeleteProjectDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/cluster_project/DeleteProjectDialog.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.dialogs.cluster_project; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jetbrains.annotations.NotNull; @@ -23,7 +36,4 @@ public void clickYes() { find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_YES)).click(); } - public void clickNo() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_NO)).click(); - } } \ No newline at end of file diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/component/CreateComponentDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/component/CreateComponentDialog.java index 19425edf2..9bc5a207a 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/component/CreateComponentDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/component/CreateComponentDialog.java @@ -12,7 +12,13 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JCheckboxFixture; +import com.intellij.remoterobot.fixtures.JListFixture; +import com.intellij.remoterobot.fixtures.JTextFieldFixture; import com.intellij.remoterobot.utils.Keyboard; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants; @@ -54,14 +60,6 @@ public void setName(String name) { nameField.setText(name); } - public void selectModule() { - find(ComponentFixture.class, byXpath("//div[@text='Select module']")).click(); - } - - public void selectFolder() { - find(ComponentFixture.class, byXpath("//div[@text='Select folder']")).click(); - } - public void selectComponentType(String type, RemoteRobot remoteRobot) { // Find the JList JListFixture jList = find(JListFixture.class, byXpath(XPathConstants.JLIST)); @@ -103,23 +101,8 @@ public void setStartDevMode(boolean start) { } } - public void clickPrevious() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_PREVIOUS)).click(); - } - - public void clickNext() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_NEXT)).click(); - } - public void clickCreate() { find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CREATE)).click(); } - public void clickCancel() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_CANCEL)).click(); - } - - public void clickHelp() { - find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_HELP)).click(); - } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/service/CreateNewServiceDialog.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/service/CreateNewServiceDialog.java index 107627ef3..8469ce339 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/service/CreateNewServiceDialog.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/dialogs/service/CreateNewServiceDialog.java @@ -1,9 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.dialogs.service; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; -import org.jboss.tools.intellij.openshift.test.ui.dialogs.ProjectStructureDialog; +import com.intellij.remoterobot.fixtures.ComboBoxFixture; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JListFixture; +import com.intellij.remoterobot.fixtures.JTextFieldFixture; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jboss.tools.intellij.openshift.test.ui.views.OpenshiftView; @@ -42,26 +57,19 @@ public static CreateNewServiceDialog open(RemoteRobot robot) { } public void selectTemplateByText(String visibleText) { - ComboBoxFixture typeComboBox = findAll(ComboBoxFixture.class, byXpath("//div[@class='JComboBox']")).get(0); + ComboBoxFixture typeComboBox = findAll(ComboBoxFixture.class, byXpath(XPathConstants.JCOMBOBOX)).get(0); typeComboBox.click(); JListFixture jListFixture = find(JListFixture.class, byXpath(XPathConstants.JLIST)); jListFixture.clickItem(visibleText, false); } public void selectType(int index) { - ComboBoxFixture typeComboBox = findAll(ComboBoxFixture.class, byXpath("//div[@class='JComboBox']")).get(1); + ComboBoxFixture typeComboBox = findAll(ComboBoxFixture.class, byXpath(XPathConstants.JCOMBOBOX)).get(1); typeComboBox.click(); JListFixture jListFixture = find(JListFixture.class, byXpath(XPathConstants.JLIST)); jListFixture.clickItemAtIndex(index); } - public void selectTypeByText(String visibleText) { - ComboBoxFixture typeComboBox = findAll(ComboBoxFixture.class, byXpath("//div[@class='JComboBox']")).get(1); - typeComboBox.click(); - JListFixture jListFixture = find(JListFixture.class, byXpath(XPathConstants.JLIST)); - jListFixture.clickItem(visibleText, false); - } - public void setServiceName(String name) { List textFields = findAll(JTextFieldFixture.class, byXpath(XPathConstants.JTEXT_FIELD)); JTextFieldFixture nameField = textFields.get(0); // First text field for service name @@ -76,13 +84,6 @@ public void setEnvName(String envName) { envNameField.setText(envName); } - public void setProvider(String provider) { - List textFields = findAll(JTextFieldFixture.class, byXpath(XPathConstants.JTEXT_FIELD)); - JTextFieldFixture providerField = textFields.get(2); - providerField.click(); - providerField.setText(provider); - } - public void setType(String type) { List textFields = findAll(JTextFieldFixture.class, byXpath(XPathConstants.JTEXT_FIELD)); JTextFieldFixture providerField = textFields.get(3); @@ -94,7 +95,4 @@ public void clickOk() { find(ComponentFixture.class, byXpath(XPathConstants.BUTTON_OK)).click(); } - public void clickCancel() { - find(ComponentFixture.class, byXpath("//div[@text.key='button.cancel']")).click(); - } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AboutClusterTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AboutClusterTest.java index efd0fc804..6680f27aa 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AboutClusterTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AboutClusterTest.java @@ -17,8 +17,7 @@ import org.slf4j.LoggerFactory; import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static com.jayway.jsonpath.internal.path.PathCompiler.fail; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.HIDE_BUTTON; /** * @author Martin Szuc diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AbstractClusterTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AbstractClusterTest.java index 730a1f4b0..26ecab853 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AbstractClusterTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/AbstractClusterTest.java @@ -22,8 +22,9 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps.waitForComponentByXpath; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.*; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.DEVFILE_REGISTRIES; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.OK; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.OPEN_CONSOLE_DASHBOARD; /** * @author Martin Szuc diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateComponentTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateComponentTest.java index e40b8d679..4087fe042 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateComponentTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateComponentTest.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.tests_cluster; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; @@ -23,19 +33,20 @@ public class CreateComponentTest extends AbstractClusterTest { @Test @Order(1) public void openCloseCreateComponentDialogTest() { + LOGGER.info("openCloseCreateComponentDialogTest: Start"); // Open the Create Component dialog CreateComponentDialog createComponentDialog = CreateComponentDialog.open(robot); assertNotNull(createComponentDialog); createComponentDialog.close(); - assertThrowsExactly(WaitForConditionTimeoutException.class, () -> { - robot.find(CreateComponentDialog.class, Duration.ofSeconds(2)); - }); + assertThrowsExactly(WaitForConditionTimeoutException.class, () -> robot.find(CreateComponentDialog.class, Duration.ofSeconds(2))); + LOGGER.info("openCloseCreateComponentDialogTest: End"); } @Test @Order(2) public void createGoRuntimeComponentTest() { + LOGGER.info("createGoRuntimeComponentTest: Start"); String COMPONENT_NAME = "test-component"; CreateComponentDialog createComponentDialog = CreateComponentDialog.open(robot); @@ -48,5 +59,6 @@ public void createGoRuntimeComponentTest() { robot.find(IdeStatusBar.class).waitUntilAllBgTasksFinish(); ProjectClusterTest.verifyProjectHasItem("newtestproject", COMPONENT_NAME); + LOGGER.info("createGoRuntimeComponentTest: End"); } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateServiceTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateServiceTest.java index 511cb9e4c..807f960bd 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateServiceTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/CreateServiceTest.java @@ -1,8 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.tests_cluster; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; import org.jboss.tools.intellij.openshift.test.ui.dialogs.service.CreateNewServiceDialog; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -14,12 +25,11 @@ public class CreateServiceTest extends AbstractClusterTest { private static final String SERVICE_NAME = "test-service"; - private static final String ENV_NAME = "env-name"; - private static final String PROVIDER_NAME = "test-provider"; private static final String PROJECT_NAME = "newtestproject"; @Test @Order(1) + @Disabled public void createServiceTest() { CreateNewServiceDialog createNewServiceDialog = CreateNewServiceDialog.open(robot); assertNotNull(createNewServiceDialog); diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/ProjectClusterTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/ProjectClusterTest.java index 47cb24c2e..d26f53bf8 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/ProjectClusterTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_cluster/ProjectClusterTest.java @@ -17,7 +17,11 @@ import org.jboss.tools.intellij.openshift.test.ui.dialogs.cluster_project.DeleteProjectDialog; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants; import org.jboss.tools.intellij.openshift.test.ui.views.OpenshiftView; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,7 +104,6 @@ private static void createNewClusterProject(String projectName) { private void verifyProjectIsVisible(String projectName) { LOGGER.info("Verifying project creation for: " + projectName); OpenshiftView view = robot.find(OpenshiftView.class); - view.refreshTree(robot); sleep(3000); try{ view.expandOpenshiftExceptDevfile(); @@ -114,7 +117,6 @@ private void verifyProjectIsVisible(String projectName) { public static void verifyProjectHasItem(String projectName, String itemName) { LOGGER.info("Verifying project " + projectName + " has item: " + itemName); OpenshiftView view = robot.find(OpenshiftView.class); - view.refreshTree(robot); IdeStatusBar ideStatusBar = robot.find(IdeStatusBar.class, Duration.ofSeconds(2)); ideStatusBar.waitUntilAllBgTasksFinish(); @@ -149,7 +151,7 @@ public static void verifyProjectHasItem(String projectName, String itemName) { private static String findLabel(OpenshiftView openshiftView, String primaryLabel, String fallbackLabel, int row) { // Try to locate the primary label try { - if (openshiftView.hasMenuOption(robot, primaryLabel, row)) { + if (openshiftView.hasMenuOption(primaryLabel, row)) { return primaryLabel; } } catch (Exception e) { diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/AboutPublicTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/AboutPublicTest.java index bed382d44..dd967bca0 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/AboutPublicTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/AboutPublicTest.java @@ -20,7 +20,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.awt.*; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; @@ -29,7 +30,10 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.jayway.jsonpath.internal.path.PathCompiler.fail; import static com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps.waitForComponentByXpath; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.COPY; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.HIDE_BUTTON; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.JB_TERMINAL_PANEL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.SELECT_ALL; /** * @author Martin Szuc diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/ClusterLoginDialogPublicTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/ClusterLoginDialogPublicTest.java index b6014cc93..64759b40c 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/ClusterLoginDialogPublicTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/ClusterLoginDialogPublicTest.java @@ -21,11 +21,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.awt.*; +import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Szuc diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/GettingStartedTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/GettingStartedTest.java index 31216d311..bda7c15b9 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/GettingStartedTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/GettingStartedTest.java @@ -14,10 +14,15 @@ import com.intellij.remoterobot.search.locators.Locator; import org.jboss.tools.intellij.openshift.test.ui.AbstractBaseTest; import org.jboss.tools.intellij.openshift.test.ui.views.GettingStartedView; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.BACK_START_A_COMPONENT_IN_DEVELOPMENT_MODE; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.LEAVE_FEEDBACK; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.NEXT_BROWSE_ALL_THE_DEVFILE_STACKS; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/OpenshiftExtensionTest.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/OpenshiftExtensionTest.java index 0d82d7ae3..17f120506 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/OpenshiftExtensionTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/tests_public/OpenshiftExtensionTest.java @@ -11,13 +11,18 @@ package org.jboss.tools.intellij.openshift.test.ui.tests_public; import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; +import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowLeftToolbar; import org.jboss.tools.intellij.openshift.test.ui.AbstractBaseTest; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jboss.tools.intellij.openshift.test.ui.views.GettingStartedView; import org.jboss.tools.intellij.openshift.test.ui.views.OpenshiftView; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,8 +30,9 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.*; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.GETTING_STARTED; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.KUBERNETES; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.OPENSHIFT; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -87,6 +93,7 @@ public void defaultNodeTest() { "defaultNodeTest: End"); } + @Test @Order(4) public void openGettingStartedFromOpenshiftView() { @@ -102,4 +109,14 @@ public void openGettingStartedFromOpenshiftView() { gettingStartedView.closeView(); openshiftView.closeView(); } + + private boolean isStripeButtonAvailable(String label) { + try { + ToolWindowLeftToolbar toolWindowLeftToolbar = robot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(10)); + toolWindowLeftToolbar.stripeButton(OPENSHIFT); + } catch (WaitForConditionTimeoutException e) { + return false; + } + return true; + } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/CleanUpUtility.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/CleanUpUtility.java index 292248065..6cc2d8cd1 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/CleanUpUtility.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/CleanUpUtility.java @@ -13,7 +13,6 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.fixtures.ContainerFixture; -import org.jboss.tools.intellij.openshift.test.ui.AbstractBaseTest; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jboss.tools.intellij.openshift.test.ui.views.GettingStartedView; import org.jboss.tools.intellij.openshift.test.ui.views.OpenshiftView; diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/KubeConfigUtility.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/KubeConfigUtility.java index 1e685b835..68833e06a 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/KubeConfigUtility.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/KubeConfigUtility.java @@ -15,7 +15,11 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import java.nio.file.*; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; /** * @author Martin Szuc diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/ProjectUtility.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/ProjectUtility.java index 4328c672b..dbe1cc9ba 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/ProjectUtility.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/ProjectUtility.java @@ -12,14 +12,7 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.intellij.remoterobot.fixtures.JTextFieldFixture; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.information.TipDialog; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.NewProjectDialogWizard; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; -import org.jboss.tools.intellij.openshift.test.ui.common.ImportProjectFromVersionControlFixture; -import org.jboss.tools.intellij.openshift.test.ui.common.ProjectTreeFixture; import java.time.Duration; @@ -30,44 +23,6 @@ */ public class ProjectUtility { - public static void importProject(RemoteRobot robot, String projectName) { - final ImportProjectFromVersionControlFixture importProjectFromVersionControlFixture = robot - .find(ImportProjectFromVersionControlFixture.class); - importProjectFromVersionControlFixture.typeUrl(); - importProjectFromVersionControlFixture.clickCloneButton(); - - final ProjectTreeFixture projectTreeFixture = robot.find(ProjectTreeFixture.class, Duration.ofSeconds(60)); - projectTreeFixture.waitItemInTree(projectName, 180, 10); - } - - public static void createEmptyProject(RemoteRobot robot, String projectName) { - final FlatWelcomeFrame flatWelcomeFrame = robot.find(FlatWelcomeFrame.class); - flatWelcomeFrame.createNewProject(); - final NewProjectDialogWizard newProjectDialogWizard = flatWelcomeFrame.find(NewProjectDialogWizard.class, Duration.ofSeconds(20)); - selectNewProjectType(robot, "Empty Project"); - JTextFieldFixture textField = robot.find(JTextFieldFixture.class, byXpath("//div[@visible_text='untitled']")); - textField.setText(projectName); - newProjectDialogWizard.finish(); - - final IdeStatusBar ideStatusBar = robot.find(IdeStatusBar.class, Duration.ofSeconds(5)); - //ideStatusBar.waitUntilProjectImportIsComplete(); TODO fix on IJ ULTIMATE 2023.2 - } - - public static void selectNewProjectType(RemoteRobot robot, String projectType) { - ComponentFixture newProjectTypeList = robot.findAll(ComponentFixture.class, byXpath("JBList", "//div[contains(@visible_text, 'FX')]")).get(0); - newProjectTypeList.findText(projectType).click(); - } - - public static void closeTipDialogIfItAppears(RemoteRobot robot) { - try { - TipDialog tipDialog = robot.find(TipDialog.class, Duration.ofSeconds(10)); -// tipDialog.close(); // temporary commented - robot.find(ComponentFixture.class, byXpath("//div[@accessiblename='Close' and @class='JButton' and @text='Close']"), Duration.ofSeconds(5)).click(); // temporary workaround - } catch (WaitForConditionTimeoutException e) { - // no dialog appeared, no need to exception handling - } - } - public static void closeGotItPopup(RemoteRobot robot) { try { robot.find(ComponentFixture.class, byXpath("JBList", "//div[@accessiblename='Got It' and @class='JButton' and @text='Got It']"), Duration.ofSeconds(10)).click(); @@ -76,13 +31,4 @@ public static void closeGotItPopup(RemoteRobot robot) { } } - public static void sleep(long ms) { - System.out.println("Putting thread into sleep for: " + ms + " ms"); - try { - Thread.sleep(ms); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/constants/XPathConstants.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/constants/XPathConstants.java index fd67ce39c..bcbe19b67 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/constants/XPathConstants.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/utils/constants/XPathConstants.java @@ -10,46 +10,71 @@ ******************************************************************************/ package org.jboss.tools.intellij.openshift.test.ui.utils.constants; +import org.intellij.lang.annotations.Language; + public class XPathConstants { + @Language("XPath") public static final String BACK_BUTTON_GETTING_STARTED = "//div[@accessiblename='<< Getting Started with OpenShift Toolkit' and @class='JLabel' and @text='<< Getting Started with OpenShift Toolkit']"; + @Language("XPath") public static final String BACK_START_A_COMPONENT_IN_DEVELOPMENT_MODE = "//div[@accessiblename='< Back: Start a component in development mode' and @class='JLabel' and @text='< Back: Start a component in development mode']"; - public static final String BUTTON_CANCEL = "//div[@text='Cancel']"; + @Language("XPath") public static final String BUTTON_CHANGE = "//div[@text='Change']"; + @Language("XPath") public static final String BUTTON_CLASS = "//div[@class='JButton']"; + @Language("XPath") public static final String BUTTON_CREATE = "//div[@text='Create']"; - public static final String BUTTON_NEXT = "//div[@text='Next']"; - public static final String BUTTON_NO = "//div[@text='No']"; + @Language("XPath") public static final String BUTTON_OK = "//div[@text='OK']"; - public static final String BUTTON_PREVIOUS = "//div[@text='Previous']"; + @Language("XPath") public static final String BUTTON_YES = "//div[@text='Yes']"; + @Language("XPath") public static final String COPY = "//div[contains(@text.key, 'action.$Copy.text')]"; + @Language("XPath") public static final String GETTING_STARTED_BASELABEL = "//div[@accessiblename='Getting Started' and @class='BaseLabel' and @text='Getting Started']"; + @Language("XPath") + public static final String HEAVY_WEIGHT_WINDOW = "//div[@class='HeavyWeightWindow']"; + @Language("XPath") public static final String HIDE_BUTTON = "//div[@class='ToolWindowHeader'][.//div[@class='ContentTabLabel']]//div[@myaction.key='tool.window.hide.action.name']"; + @Language("XPath") public static final String IDE_FRAME_IMPL = "//div[@class='IdeFrameImpl']"; + @Language("XPath") public static final String JBTEXTFIELD = "//div[@class='JBTextField']"; + @Language("XPath") public static final String JB_TERMINAL_PANEL = "//div[@class='JBTerminalPanel']"; + @Language("XPath") public static final String JCHECKBOX = "//div[@class='JCheckBox']"; + @Language("XPath") + public static final String JCOMBOBOX = "//div[@class='JComboBox']"; + @Language("XPath") public static final String JEDITOR_PANE = "//div[@class='JEditorPane']"; + @Language("XPath") public static final String JPASSWORD_FIELD = "//div[@class='JPasswordField']"; + @Language("XPath") public static final String JTEXT_FIELD = "//div[@class='JTextField']"; + @Language("XPath") public static final String LEAVE_FEEDBACK = "//div[@text='Leave feedback']"; + @Language("XPath") public static final String MYDIALOG_CLASS = "//div[@class='MyDialog']"; + @Language("XPath") public static final String NEXT_BROWSE_ALL_THE_DEVFILE_STACKS = "//div[@accessiblename='Next: Browse all the Devfile stacks from Devfile registries >' and @class='JLabel' and @text='Next: Browse all the Devfile stacks from Devfile registries >']"; + @Language("XPath") public static final String OPEN_CONSOLE_DASHBOARD = "//div[@text='Open Console Dashboard']"; + @Language("XPath") public static final String OPENSHIFT_BASELABEL = "//div[@accessiblename='OpenShift' and @class='BaseLabel' and @text='OpenShift']"; + @Language("XPath") public static final String SELECT_ALL = "//div[contains(@text.key, 'action.$SelectAll.text')]"; + @Language("XPath") public static final String TEXT_FIELD_W_AUTO_COMPLETION = "//div[@class='TextFieldWithAutoCompletion']"; + @Language("XPath") public static final String TREE_CLASS = "//div[@class='Tree']"; - public static final String BUTTON_HELP = "//div[@accessiblename='Help' and @class='JButton' and @text='Help']"; + @Language("XPath") public static final String JLIST = "//div[@class='JList']"; + @Language("XPath") public static final String BUTTON_PASTE_LOGIN_COMMAND = "//div[@text='Paste Login Command']"; + @Language("XPath") public static final String GETTING_STARTED_ACTION_MENU_ITEM = "//div[@accessiblename='Getting Started' and @class='ActionMenuItem' and @text='Getting Started']"; - public static String getToolWindowButton(String label) { - return "//div[@tooltiptext='" + label + "']"; - } - public static String getTextXPath(String selection) { return "//div[@text='" + selection + "']"; } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/GettingStartedView.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/GettingStartedView.java index a684c7dbf..f57672d29 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/GettingStartedView.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/GettingStartedView.java @@ -12,9 +12,13 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.ContainerFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.Keyboard; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowRightToolbar; import org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -25,8 +29,11 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.GETTING_STARTED; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.GETTING_STARTED_BASELABEL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.IDE_FRAME_IMPL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.JEDITOR_PANE; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.TREE_CLASS; /** * @author Richard Kocian @@ -43,20 +50,23 @@ public GettingStartedView(@NotNull RemoteRobot remoteRobot, @NotNull RemoteCompo public void openView() { if (!isViewOpened()) { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.button(byXpath(getToolWindowButton(GETTING_STARTED)), Duration.ofSeconds(2)).click(); + clickStripeButton(); LOGGER.info("Getting Started view opened"); } } public void closeView() { if (isViewOpened()) { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.button(byXpath(getToolWindowButton(GETTING_STARTED)), Duration.ofSeconds(2)).click(); + clickStripeButton(); LOGGER.info("Getting Started view closed"); } } + private void clickStripeButton() { + ToolWindowRightToolbar toolWindowRightToolbar = find(ToolWindowRightToolbar.class, Duration.ofSeconds(10)); + toolWindowRightToolbar.clickStripeButton(GETTING_STARTED); + } + public void waitForTreeItem(String itemText, int duration, int interval) { waitFor(Duration.ofSeconds(duration), Duration.ofSeconds(interval), @@ -84,12 +94,12 @@ public void maximalizeToolWindow(RemoteRobot robot) { private boolean isViewOpened() { try { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.find(ComponentFixture.class, byXpath(GETTING_STARTED_BASELABEL)); + find(ComponentFixture.class, byXpath(GETTING_STARTED_BASELABEL), Duration.ofSeconds(5)); LOGGER.info("Getting Started view: View is already opened"); return true; } catch (Exception ignored) { - } + LOGGER.info("Getting Started view: View is not opened"); return false; } } +} diff --git a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/OpenshiftView.java b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/OpenshiftView.java index f20ed1ad8..f7f0895b4 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/OpenshiftView.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/test/ui/views/OpenshiftView.java @@ -12,8 +12,12 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.*; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; +import com.intellij.remoterobot.fixtures.ComponentFixture; +import com.intellij.remoterobot.fixtures.ContainerFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JTreeFixture; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowLeftToolbar; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,13 +27,16 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; import static com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps.waitForComponentByXpath; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.*; -import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.*; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.DEVFILE_REGISTRIES; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.OPENSHIFT; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.LabelConstants.REFRESH; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.IDE_FRAME_IMPL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.OPENSHIFT_BASELABEL; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.TREE_CLASS; +import static org.jboss.tools.intellij.openshift.test.ui.utils.constants.XPathConstants.getTextXPath; /** - * * @author Ihor Okhrimenko, Ondrej Dockal, Martin Szuc - * */ @DefaultXpath(by = "OpenshiftView type", xpath = IDE_FRAME_IMPL) @FixtureName(name = "Openshift View") @@ -42,22 +49,21 @@ public OpenshiftView(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent public void openView() { if (!isViewOpened()) { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.button(byXpath(getToolWindowButton(OPENSHIFT)), Duration.ofSeconds(2)).click(); + clickStripeButton(); LOGGER.info("Openshift view opened"); } } public void closeView() { if (isViewOpened()) { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.button(byXpath(getToolWindowButton(OPENSHIFT)), Duration.ofSeconds(2)).click(); + clickStripeButton(); LOGGER.info("Openshift view closed"); } } - public void expandOpenshiftViewTree(String path) { - getOpenshiftConnectorTree().expand(path); + private void clickStripeButton() { + ToolWindowLeftToolbar toolWindowLeftToolbar = find(ToolWindowLeftToolbar.class, Duration.ofSeconds(10)); + toolWindowLeftToolbar.clickStripeButton(OPENSHIFT); } public void expandOpenshiftExceptDevfile() { @@ -88,8 +94,7 @@ public void refreshTree(RemoteRobot robot){ private boolean isViewOpened() { try { - final ToolWindowPane toolWindowPane = find(ToolWindowPane.class); - toolWindowPane.find(ComponentFixture.class, byXpath(OPENSHIFT_BASELABEL)); + find(ComponentFixture.class, byXpath(OPENSHIFT_BASELABEL), Duration.ofSeconds(5)); LOGGER.info("Openshift view: View is already opened"); return true; } catch (Exception ignored) { @@ -100,15 +105,15 @@ private boolean isViewOpened() { /** * Checks if a menu option exists without clicking it. - * @param robot the RemoteRobot instance + * * @param selection the label of the menu option to check * @param row the row index to right-click * @return true if the menu option exists, false otherwise */ - public boolean hasMenuOption(RemoteRobot robot, String selection, int row) { + public boolean hasMenuOption(String selection, int row) { try { getOpenshiftConnectorTree().rightClickRow(row); - return findAll(ComponentFixture.class, byXpath(getTextXPath(selection))).size() > 0; + return !findAll(ComponentFixture.class, byXpath(getTextXPath(selection))).isEmpty(); } catch (Exception e) { return false; } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/helm/HelmCliRepoTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/helm/HelmCliRepoTest.java index 5f9c4bfda..e9e9087f1 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/helm/HelmCliRepoTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/helm/HelmCliRepoTest.java @@ -13,7 +13,6 @@ import java.io.IOException; import java.util.List; -import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; @@ -47,14 +46,14 @@ public void testRemoveRepos_should_remove_repo_that_was_added() throws IOExcepti helm.addRepo(name2, "https://charts.openshift.io/", null); List helmRepositoryNames = helm.listRepos().stream() .map(HelmRepository::getName) - .collect(Collectors.toList()); + .toList(); assertThat(helmRepositoryNames).contains(name, name2); // when helm.removeRepos(name, name2); // then helmRepositoryNames = helm.listRepos().stream() .map(HelmRepository::getName) - .collect(Collectors.toList()); + .toList(); assertThat(helmRepositoryNames).doesNotContain(name, name2); } finally { silentlyRemoveRepos(name, name2); diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java index 295fe963d..6147e5e6d 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java @@ -11,6 +11,7 @@ package org.jboss.tools.intellij.openshift.utils.odo; import com.intellij.util.io.ZipUtil; +import com.intellij.openapi.util.io.FileUtil; import com.redhat.devtools.intellij.common.utils.ExecHelper; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -204,8 +205,9 @@ public void checkCreateComponentAndDebug() throws IOException, ExecutionExceptio @Test public void checkCreateComponentStarter() throws IOException, ExecutionException, InterruptedException { - createComponent(project, component, "go-starter", projectPath); - List descriptors = odo.discover(projectPath); + String starterPath = FileUtil.createTempDirectory("go-starter", "").getPath(); + createComponent(project, component, "go-starter", starterPath); + List descriptors = odo.discover(starterPath); assertNotNull(descriptors); assertEquals(1, descriptors.size()); } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java index ae5760af1..a56e1cfba 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java @@ -19,6 +19,12 @@ public class OdoCliServiceTest extends OdoCliTest { private final String projectPath = new File("src/it/projects/springboot-rest").getAbsolutePath(); + @Override + protected void tearDown() throws Exception { + cleanLocalProjectDirectory(projectPath); + super.tearDown(); + } + public void testCheckCreateService() throws IOException, ExecutionException, InterruptedException { String project = PROJECT_PREFIX + random.nextInt(); String service = SERVICE_PREFIX + random.nextInt(); @@ -54,6 +60,6 @@ private void createService(String project, String service) throws IOException, E ServiceTemplate serviceTemplate = getServiceTemplate(); OperatorCRD crd = getOperatorCRD(serviceTemplate); assertNotNull(crd); - createService(project, serviceTemplate, crd, service, projectPath); + createService(project, serviceTemplate, crd, service); } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java index 6733b4fd9..8ad5840ad 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java @@ -11,9 +11,9 @@ package org.jboss.tools.intellij.openshift.utils.odo; import com.intellij.openapi.ui.TestDialog; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.redhat.devtools.intellij.common.utils.MessagesHelper; -import org.apache.commons.io.FileUtils; import org.jboss.tools.intellij.openshift.tree.application.ApplicationRootNodeOdo; import org.jboss.tools.intellij.openshift.tree.application.ApplicationsRootNode; import org.jboss.tools.intellij.openshift.utils.OdoCluster; @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import static org.awaitility.Awaitility.with; +import static org.jboss.tools.intellij.openshift.Constants.PLUGIN_FOLDER; import static org.mockito.Mockito.mock; @@ -101,9 +102,9 @@ protected void createComponent(String project, String component, String projectP } protected void cleanLocalProjectDirectory(String projectPath) throws IOException { - FileUtils.deleteDirectory(new File(projectPath, ".odo")); - FileUtils.deleteDirectory(new File(projectPath, "kubernetes")); - FileUtils.deleteQuietly(new File(projectPath + "/devfile.yaml")); + FileUtil.delete(new File(projectPath, PLUGIN_FOLDER).toPath()); + FileUtil.delete(new File(projectPath, "kubernetes").toPath()); + FileUtil.delete(new File(projectPath + "/devfile.yaml").toPath()); } protected OperatorCRD getOperatorCRD(ServiceTemplate serviceTemplate) { @@ -116,8 +117,7 @@ protected ServiceTemplate getServiceTemplate() throws IOException { return odo.getServiceTemplates().stream().filter(s -> s.getName().equals(SERVICE_TEMPLATE + "." + (odo.isOpenShift() ? SERVICE_OPENSHIFT_VERSION : SERVICE_KUBE_VERSION))).findFirst().orElse(null); } - protected void createService(String project, ServiceTemplate serviceTemplate, OperatorCRD crd, String service, String projectPath) throws IOException { - cleanLocalProjectDirectory(projectPath); + protected void createService(String project, ServiceTemplate serviceTemplate, OperatorCRD crd, String service) throws IOException { odo.createService(project, serviceTemplate, crd, service, null, false); } }