Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated UI tests for case insensitive matching of completion items #1203

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,62 @@ public void testInsertLibertyConfigIntoServerEnv() {
}
}

/**
* Tests Liberty-LS support in server.env for
* providing completion suggestions in lowercase letters.
*/
@Test
@Video
public void testInsertLibertyConfigIntoServerEnvForLowerCase() {
dessina-devasia marked this conversation as resolved.
Show resolved Hide resolved
String envCfgSnippetLowerCase = "wlp_logging_con";
String envCfgNameChooserSnippet = "FORMAT";
String envCfgValueSnippet = "sim";
String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE";

// get focus on server.env tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env");

// Save the current server.env content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippetLowerCase, envCfgNameChooserSnippet, envCfgValueSnippet, true);
Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env");
TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString);
} finally {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}
}

/**
* Tests Liberty-LS support in server.env for providing completion
* suggestions in a mix of uppercase and lowercase letters.
*/
@Test
@Video
public void testInsertLibertyConfigIntoServerEnvForMixOfCases() {
String envCfgSnippetMixCase = "wLp_LOgginG_coN";
String envCfgNameChooserSnippet = "FORMAT";
String envCfgValueSnippet = "sIM";
String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE";

// get focus on server.env tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env");

// Save the current server.env content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippetMixCase, envCfgNameChooserSnippet, envCfgValueSnippet, true);
Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env");
TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString);
} finally {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}
}

/**
* Tests liberty-ls type ahead support in bootstrap.properties for a
* Liberty Server Configuration booststrap.properties entry
Expand Down Expand Up @@ -217,6 +273,62 @@ public void testInsertLibertyConfigIntoBootstrapProps() {
}
}

/**
* Tests Liberty-LS support in bootstrap.properties for
* providing completion suggestions in capital case letters.
*/
@Test
@Video
public void testInsertLibertyConfigIntoBootstrapPropsForCapitalCase() {
String configNameSnippetUpperCase = "COM.IBM.WS.LOGGING.CON";
String configNameChooserSnippet = "format";
String configValueSnippet = "tba";
String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC";

// get focus on bootstrap.properties tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties");

// Save the current bootstrap.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippetUpperCase, configNameChooserSnippet, configValueSnippet, true);
Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties");
TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString);
} finally {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}
}

/**
* Tests Liberty-LS support in bootstrap.properties for providing completion
* suggestions in a mix of uppercase and lowercase letters.
*/
@Test
@Video
public void testInsertLibertyConfigIntoBootstrapPropsForMixOfCases() {
String configNameSnippetMixCase = "CoM.Ibm.wS.LoGginG.cON";
String configNameChooserSnippet = "format";
String configValueSnippet = "Tba";
String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC";

// get focus on bootstrap.properties tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties");

// Save the current bootstrap.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippetMixCase, configNameChooserSnippet, configValueSnippet, true);
Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties");
TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString);
} finally {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}
}

/**
* Tests liberty-ls Hover support in server.env for a
* Liberty Server Config setting
Expand Down Expand Up @@ -286,7 +398,6 @@ public void testDiagnosticInServerXML() {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}

}

/**
Expand Down Expand Up @@ -324,8 +435,6 @@ public void testQuickFixInServerXML() {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot, true);
}


}

/**
Expand Down Expand Up @@ -356,7 +465,6 @@ public void testDiagnosticInServerEnv() {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}

}

/**
Expand Down Expand Up @@ -387,7 +495,6 @@ public void testDiagnosticInBootstrapProperties() {
// Replace server.xml content with the original content
UIBotTestUtils.pasteOnActiveWindow(remoteRobot);
}

}

/**
Expand Down
31 changes: 22 additions & 9 deletions src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1096,17 +1096,29 @@ public static void insertConfigIntoMPConfigPropertiesFile(RemoteRobot remoteRobo
*
* @param remoteRobot The RemoteRobot instance.
* @param fileName The string path to the config file
* @param configNameSnippet the portion of the name to type
* @param configNameSnippetCaseSpecific the portion of the name to type
vaisakhkannan marked this conversation as resolved.
Show resolved Hide resolved
* @param configNameChooserSnippet the portion of the name to use for selecting from popup menu
* @param configValueSnippet the value to type into keyboard - could be a snippet or a whole word
* @param completeWithPopup use popup to complete value selection or type in an entire provided value string
*/
public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fileName, String configNameSnippet, String configNameChooserSnippet, String configValueSnippet, boolean completeWithPopup) {
public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fileName, String configNameSnippetCaseSpecific, String configNameChooserSnippet, String configValueSnippet, boolean completeWithPopup) {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30));
clickOnFileTab(remoteRobot, fileName);
EditorFixture editorNew = remoteRobot.find(EditorFixture.class, EditorFixture.Companion.getLocator());
Exception error = null;

String configNameSnippet = "";
if (fileName.equals("server.env")) {
configNameSnippet = configNameSnippetCaseSpecific.toUpperCase();
}
else if (fileName.equals("bootstrap.properties")) {
configNameSnippet = configNameSnippetCaseSpecific.toLowerCase();
}
else {
configNameSnippet = configNameSnippetCaseSpecific;
}
String configValueSnippetUpperCase = configValueSnippet.toUpperCase();
vaisakhkannan marked this conversation as resolved.
Show resolved Hide resolved

for (int i = 0; i < 10; i++) {
error = null;
try {
Expand All @@ -1118,19 +1130,20 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi
keyboard.hotKey(VK_CONTROL, VK_END);
keyboard.enter();

keyboard.enterText(configNameSnippet);
keyboard.enterText(configNameSnippetCaseSpecific);
// After typing it can take 1 or 2s for IntelliJ to render diagnostics etc. Must wait before continuing.
TestUtils.sleepAndIgnoreException(5);

// Narrow down the config name completion suggestions in the pop-up window that is automatically
// opened as text is typed based on the value of configNameSnippet. Avoid hitting ctrl + space as it has the side effect of selecting
// and entry automatically if the completion suggestion windows has one entry only.
ComponentFixture namePopupWindow = projectFrame.getLookupList();
String finalConfigNameSnippet = configNameSnippet;
RepeatUtilsKt.waitFor(Duration.ofSeconds(5),
Duration.ofSeconds(1),
"Waiting for text " + configNameSnippet + " to appear in the completion suggestion pop-up window",
"Text " + configNameSnippet + " did not appear in the completion suggestion pop-up window",
() -> namePopupWindow.hasText(configNameSnippet));
() -> namePopupWindow.hasText(finalConfigNameSnippet));

// now choose the specific item based on the chooser string
namePopupWindow.findText(contains(configNameChooserSnippet)).doubleClick();
Expand All @@ -1150,11 +1163,11 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi
ComponentFixture valuePopupWindow = projectFrame.getLookupList();
RepeatUtilsKt.waitFor(Duration.ofSeconds(5),
Duration.ofSeconds(1),
"Waiting for text " + configValueSnippet + " to appear in the completion suggestion pop-up window",
"Text " + configValueSnippet + " did not appear in the completion suggestion pop-up window",
() -> valuePopupWindow.hasText(configValueSnippet));
"Waiting for text " + configValueSnippetUpperCase + " to appear in the completion suggestion pop-up window",
"Text " + configValueSnippetUpperCase + " did not appear in the completion suggestion pop-up window",
() -> valuePopupWindow.hasText(configValueSnippetUpperCase));

valuePopupWindow.findText(contains(configValueSnippet)).doubleClick();
valuePopupWindow.findText(contains(configValueSnippetUpperCase)).doubleClick();
}
// let the auto-save function of intellij save the file before testing it
if (remoteRobot.isMac()) {
Expand All @@ -1175,7 +1188,7 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi

// Report the last error if there is one.
if (error != null) {
throw new RuntimeException("Unable to insert entry in config file : " + fileName + " using text: " + configNameSnippet, error);
throw new RuntimeException("Unable to insert entry in config file : " + fileName + " using text: " + configNameSnippetCaseSpecific, error);
}
}

Expand Down
Loading