Skip to content

Commit f245b04

Browse files
committed
fix: fix failed tests screenshot comment
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 638a1ea commit f245b04

File tree

8 files changed

+12
-24
lines changed

8 files changed

+12
-24
lines changed

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.intellij.remoterobot.fixtures.JListFixture;
2222
import com.intellij.remoterobot.fixtures.JPopupMenuFixture;
2323
import com.intellij.remoterobot.fixtures.JTextFieldFixture;
24-
import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText;
2524
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
2625
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
2726
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
@@ -47,8 +46,8 @@
4746
@DefaultXpath(by = "MyDialog type", xpath = XPathDefinitions.DIALOG_ROOT_PANE)
4847
@FixtureName(name = "New Project Dialog")
4948
public class NewProjectFirstPage extends AbstractNewProjectFinalPage {
50-
private final RemoteRobot remoteRobot;
51-
private int projectSdkItemsCount = -1;
49+
protected final RemoteRobot remoteRobot;
50+
private boolean isProjectSdkItemsLoaded = false;
5251
private final int ideaVersion;
5352

5453
public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
@@ -184,12 +183,8 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
184183
private kotlin.Pair<Boolean, CommonContainerFixture> didProjectSdkListLoadAllItems() {
185184
return step("Test whether the 'Project SDK' list has loaded all items", () -> {
186185
CommonContainerFixture parentFixture = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG));
187-
JPopupMenuFixture projectSdkList = parentFixture.jPopupMenus(byXpath(XPathDefinitions.HEAVY_WEIGHT_WINDOW)).get(0); // issue https://github.com/JetBrains/intellij-ui-test-robot/issues/104
188-
List<RemoteText> sdkItems = projectSdkList.findAllText();
189-
int currentSdkItemsCount = sdkItems.size();
190-
191-
if ((projectSdkItemsCount == -1) || (projectSdkItemsCount != currentSdkItemsCount)) {
192-
projectSdkItemsCount = currentSdkItemsCount;
186+
if (!isProjectSdkItemsLoaded) {
187+
isProjectSdkItemsLoaded = true;
193188
return new kotlin.Pair<>(false, parentFixture);
194189
}
195190
return new kotlin.Pair<>(true, parentFixture);

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/idestatusbar/IdeStatusBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public IdeStatusBar(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent r
4646
* @return fixture for the InlineProgressPanel
4747
*/
4848
public ComponentFixture inlineProgressPanel() {
49-
return find(ComponentFixture.class, byXpath(XPathDefinitions.INLINE_PROGRESS_PANEL));
49+
return find(ComponentFixture.class, byXpath(XPathDefinitions.INLINE_PROGRESS_PANEL), Duration.ofSeconds(5));
5050
}
5151

5252
/**

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,8 @@ protected void togglePane(String label, Class<? extends Fixture> fixtureClass, b
114114
}
115115

116116
private boolean isPaneOpened(Class<? extends Fixture> fixtureClass) {
117-
AbstractToolWinPane toolWinPane;
118-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
119-
toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10));
120-
} else {
121-
toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10));
122-
}
123-
124117
try {
125-
toolWinPane.find(fixtureClass, Duration.ofSeconds(10));
126-
return true;
118+
return find(fixtureClass, Duration.ofSeconds(10)).isShowing();
127119
} catch (WaitForConditionTimeoutException e) {
128120
return false;
129121
}

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPane.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public void reloadAllMavenProjects() {
5959
public void collapseAll() {
6060
if (UITestRunner.getIdeaVersionInt() >= 20242) {
6161
actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_2024_2), Duration.ofSeconds(2)).click();
62-
6362
} else {
6463
actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_FOR), Duration.ofSeconds(2)).click();
6564
}

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/testextension/ScreenshotAfterTestFailExtension.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ public void afterTestExecution(ExtensionContext extensionContext) {
5252
LOGGER.log(Level.SEVERE, "Can't take a screenshot, remoteRobot is null!");
5353
return;
5454
}
55+
String testClass = extensionContext.getRequiredTestClass().getName();
56+
String testMethod = extensionContext.getRequiredTestMethod().getName();
5557
step("Take a screenshot after a test has failed",
56-
() -> ScreenshotUtils.takeScreenshot(remoteRobot)
58+
() -> ScreenshotUtils.takeScreenshot(remoteRobot, testClass+"_"+testMethod)
5759
);
5860
step("Return to the 'Welcome Frame' dialog",
5961
() -> cleanAfterTestFail(remoteRobot)

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/BuildViewTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void prepareProject() {
4444
toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10));
4545
}
4646
toolWinPane.openMavenBuildToolPane();
47-
toolWinPane.find(MavenBuildToolPane.class, Duration.ofSeconds(10)).buildProject("install");
47+
toolWinPane.find(MavenBuildToolPane.class, Duration.ofSeconds(10)).buildProject("verify");
4848
}
4949

5050
@AfterAll

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ void createToolWindowsPaneFixture() {
5656
void mavenBuildTest() {
5757
toolWinPane.openMavenBuildToolPane();
5858
MavenBuildToolPane mavenBuildToolPane = toolWinPane.find(MavenBuildToolPane.class, Duration.ofSeconds(10));
59-
mavenBuildToolPane.buildProject("install");
59+
mavenBuildToolPane.buildProject("verify");
6060
}
6161
}

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPaneTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void closeCurrentProject() {
5555

5656
@Test
5757
void buildProjectTest() {
58-
mavenBuildToolPane.buildProject("install");
58+
mavenBuildToolPane.buildProject("verify");
5959
boolean isBuildSuccessful = toolWinPane.find(BuildView.class, Duration.ofSeconds(10)).isBuildSuccessful();
6060
assertTrue(isBuildSuccessful, "The build should be successful but is not.");
6161
}

0 commit comments

Comments
 (0)