Skip to content

Commit c340e7a

Browse files
committed
fix(UItest): replaced unreliable .iml file usage in tests
Signed-off-by: Martin Szuc <[email protected]>
1 parent 5cf4c97 commit c340e7a

File tree

1 file changed

+15
-11
lines changed
  • src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,26 @@ public void hideAllPopups() {
7272

7373
@Test
7474
public void isItemPresentTest() {
75-
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, PROJECT_NAME + ".iml");
76-
assertTrue(isItemPresent, "The file '" + PROJECT_NAME + ".iml' should be present in the project on location '" + PROJECT_NAME + "/" + PROJECT_NAME + ".iml' but is not.");
75+
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, "src", "Main");
76+
assertTrue(isItemPresent, "The file 'Main' should be present in the project on location 'src/Main' but is not.");
7777
}
7878

7979
@Test
8080
public void openFileTest() {
81-
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
81+
projectExplorer.openFile(PROJECT_NAME, ".gitignore");
8282
if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+
83-
String projectLabelXpath = "//div[@accessiblename='" + PROJECT_NAME + ".iml' and @class='EditorTabLabel']//div[@class='ActionPanel']";
83+
String projectLabelXpath = "//div[@accessiblename='.gitignore' and @class='EditorTabLabel']//div[@class='ActionPanel']";
8484
try { // Verify file is opened by finding its tab in the editor
8585
remoteRobot.find(ComponentFixture.class, byXpath(projectLabelXpath));
8686
} catch (Exception e) {
87-
fail("The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
87+
fail("The '.gitignore' file should be opened but is not.");
8888
}
8989
} else {
9090
List<ContainerFixture> cfs = remoteRobot.findAll(ContainerFixture.class, byXpath(XPathDefinitions.SINGLE_HEIGHT_LABEL));
9191
ContainerFixture cf = cfs.get(cfs.size() - 1);
9292
String allText = TextUtils.listOfRemoteTextToString(cf.findAllText());
93-
boolean isFileOpened = allText.contains(PROJECT_NAME + ".iml");
94-
assertTrue(isFileOpened, "The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
93+
boolean isFileOpened = allText.contains(".gitignore");
94+
assertTrue(isFileOpened, "The '.gitignore' file should be opened but is not.");
9595
}
9696
}
9797

@@ -117,12 +117,16 @@ public void openViewsPopupTest() {
117117

118118
@Test
119119
public void selectOpenedFileTest() {
120-
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
120+
projectExplorer.expandAll();
121+
projectExplorer.openFile(PROJECT_NAME, "src", "Main");
121122
projectExplorer.projectViewTree().clickRow(0);
122-
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
123+
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
123124
projectExplorer.selectOpenedFile();
124-
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
125-
assertTrue(projectExplorer.projectViewTree().isPathSelected(projectExplorer.projectViewTree().getValueAtRow(0), PROJECT_NAME + ".iml"), "The file '" + PROJECT_NAME + ".xml' should be selected but is not.");
125+
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
126+
assertTrue(projectExplorer.projectViewTree().isPathSelected(
127+
projectExplorer.projectViewTree().getValueAtRow(0), "src", "Main"),
128+
"The file 'Main' should be selected but is not."
129+
);
126130
}
127131

128132
@Test

0 commit comments

Comments
 (0)