Skip to content

Commit fe7ae00

Browse files
committed
fix: fix for 2023.3 use case
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 9b0f887 commit fe7ae00

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/navigation/SearchEverywherePopup.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,21 @@ public void activateTab(String tabName) {
6767
* @param cmdToEnter command that will be invoked using the search field
6868
*/
6969
public void invokeCmd(String cmdToEnter) {
70+
invokeSearch(cmdToEnter, true);
71+
}
72+
73+
public void searchText(String searchString){
74+
invokeSearch(searchString, false);
75+
}
76+
77+
private void invokeSearch(String searchText, boolean invoke){
7078
JTextFieldFixture searchField = textField(JTextFieldFixture.Companion.byType(), Duration.ofSeconds(2));
7179
searchField.click();
72-
searchField.setText(cmdToEnter);
73-
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "the search dialog in the Search Everywhere popup to load in 30 seconds.", () -> didSearchFinish(cmdToEnter));
74-
new Keyboard(remoteRobot).hotKey(KeyEvent.VK_ENTER);
80+
searchField.setText(searchText);
81+
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "the search dialog in the Search Everywhere popup to load in 30 seconds.", () -> didSearchFinish(searchText));
82+
if(invoke){
83+
new Keyboard(remoteRobot).hotKey(KeyEvent.VK_ENTER);
84+
}
7585
}
7686

7787
private boolean didSearchFinish(String cmdToInvoke) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public void invokeCmdUsingSearchEverywherePopup(String cmdToInvoke) {
9898
searchEverywherePopup.invokeCmd(cmdToInvoke);
9999
}
100100

101+
public void searchEverywhere(String searchString) {
102+
SearchEverywherePopup searchEverywherePopup = openSearchEverywherePopup();
103+
searchEverywherePopup.searchText(searchString);
104+
}
105+
101106
private SearchEverywherePopup openSearchEverywherePopup() {
102107
try {
103108
find(ActionButtonFixture.class, byXpath("//div[@myicon='search.svg']"), Duration.ofSeconds(5)).click();

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ public void setVisible(){
116116
} catch (WaitForConditionTimeoutException e) {
117117
// not visible
118118
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
119-
mainIdeWindow.invokeCmdUsingSearchEverywherePopup("Appearance");
119+
mainIdeWindow.searchEverywhere("Appearance");
120120
ScreenshotUtils.takeScreenshot(remoteRobot);
121121
ComponentFixture appearanceDialog = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='JBViewport'][.//div[@class='MyList']]"));
122122
List<RemoteText> items = appearanceDialog.findAllText();
123-
items.stream().filter(remoteText -> remoteText.getText().equals("Main Menu")).findFirst().ifPresent(RemoteText::click);
123+
items.stream().filter(remoteText -> remoteText.getText().equals("View | Appearance: Main Menu")).findFirst().ifPresent(RemoteText::click);
124124
}
125125
}
126126
}

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
*/
4242
public class CreateCloseUtils {
4343

44+
static final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
45+
4446
/**
4547
* Create new project with given project name according to given project type
4648
*
@@ -52,8 +54,6 @@ public static void createNewProject(RemoteRobot remoteRobot, String projectName,
5254
NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot);
5355
NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10));
5456

55-
final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
56-
5757
if (ideaVersionInt >= 20221) {
5858
newProjectFirstPage.selectNewProjectType("New Project");
5959
newProjectFirstPage.setLanguage("Java");
@@ -121,8 +121,10 @@ public static void createEmptyProject(RemoteRobot remoteRobot, String projectNam
121121
public static void waitAfterOpeningProject(RemoteRobot remoteRobot) {
122122
IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10));
123123
ideStatusBar.waitUntilProjectImportIsComplete();
124-
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
125-
mainIdeWindow.maximizeIdeWindow();
124+
if (ideaVersionInt > 20233) {
125+
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
126+
mainIdeWindow.maximizeIdeWindow();
127+
}
126128
ideStatusBar.waitUntilAllBgTasksFinish(500);
127129
CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot);
128130
//ensure main menu is visible

0 commit comments

Comments
 (0)