diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e0377539a..74e373efe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -98,13 +98,10 @@ jobs: fail-fast: false matrix: runtime: [ linux, mac, windows ] - test-group: [ LSP4Jakarta-Unit, Maven-MicroProfile, Gradle-MicroProfile, Maven-Custom-Liberty-Install, Gradle-Custom-Liberty-Install, Maven-MP-Config, Gradle-MP-Config, Maven-MP-SID, Gradle-MP-SID, Maven-NLT-REST, Gradle-NLT-REST, Gradle-Language-Server, Gradle-MP-Language-Server, Gradle-Jakarta-Language-Server, Maven-Multi-Module-MP ] - exclude: - # Exclude LSP4Jakarta-Unit from mac and windows - only run on linux - - runtime: mac - test-group: LSP4Jakarta-Unit - - runtime: windows - test-group: LSP4Jakarta-Unit + test-group: [ Gradle-MP-Language-Server ] + repeat: [ 1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30 ] include: - runtime: linux os: ubuntu-latest @@ -112,36 +109,8 @@ jobs: os: macOS-14 - runtime: windows os: windows-latest - - test-group: Maven-MicroProfile - test-class: io.openliberty.tools.intellij.it.MavenSingleModMPProjectTest - - test-group: Gradle-MicroProfile - test-class: io.openliberty.tools.intellij.it.GradleSingleModMPProjectTest - - test-group: Maven-Custom-Liberty-Install - test-class: io.openliberty.tools.intellij.it.MavenSingleModCustomWLPInstallProjectTest - - test-group: Gradle-Custom-Liberty-Install - test-class: io.openliberty.tools.intellij.it.GradleSingleModCustomWLPInstallProjectTest - - test-group: Maven-MP-Config - test-class: io.openliberty.tools.intellij.it.MavenSingleModMPCfgProjectTest - - test-group: Gradle-MP-Config - test-class: io.openliberty.tools.intellij.it.GradleSingleModMPCfgProjectTest - - test-group: Maven-MP-SID - test-class: io.openliberty.tools.intellij.it.MavenSingleModMPSIDProjectTest - - test-group: Gradle-MP-SID - test-class: io.openliberty.tools.intellij.it.GradleSingleModMPSIDProjectTest - - test-group: Maven-NLT-REST - test-class: io.openliberty.tools.intellij.it.MavenSingleModNLTRestProjectTest - - test-group: Gradle-NLT-REST - test-class: io.openliberty.tools.intellij.it.GradleSingleModNLTRestProjectTest - - test-group: Gradle-Language-Server - test-class: io.openliberty.tools.intellij.it.GradleSingleModLSTest - test-group: Gradle-MP-Language-Server test-class: io.openliberty.tools.intellij.it.GradleSingleModMPLSTest - - test-group: Gradle-Jakarta-Language-Server - test-class: io.openliberty.tools.intellij.it.GradleSingleModJakartaLSTest - - test-group: Maven-Multi-Module-MP - test-class: io.openliberty.tools.intellij.it.MavenMPMultipleProjectTest - - test-group: LSP4Jakarta-Unit - test-class: "io.openliberty.tools.intellij.lsp4jakarta.it.*" env: USE_LOCAL_PLUGIN: ${{ inputs.useLocalPlugin || false }} REF_LSP4IJ: ${{ needs.fetch_merge_commit_sha_from_lsp4ij_PR.outputs.pr_details }} @@ -205,6 +174,8 @@ jobs: if: ${{ failure() && steps.run_tests.conclusion == 'failure' }} uses: actions/upload-artifact@v4.3.4 with: - name: ${{ matrix.runtime }}-${{ matrix.test-group }}-test-report-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH || 'default' }} - path: | - liberty-tools-intellij/build/reports/ + name: ${{ matrix.runtime }}-${{ matrix.test-group }}-test-report-LTI-${{ env.REF_LTI_TAG || 'default' }}-LSP4IJ-${{ env.LSP4IJ_BRANCH || 'default' }}-run-${{ matrix.repeat }} + path: liberty-tools-intellij/build/reports/ + if-no-files-found: warn + compression-level: 6 + overwrite: true \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 69886aad2..2c509e5e0 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -149,13 +149,16 @@ public void testJakartaDiagnosticsInJavaPart() { /** * Tests Jakarta Language Server quick fix support in a Java source file */ -// @Test -// @Video + @Test + @Video public void testJakartaQuickFixInJavaPart() { String publicString = "public Response getProperties() {"; String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; + UIBotTestUtils.clickOnWindowPaneStripeButton(remoteRobot, "Language Servers"); + UIBotTestUtils.enableDebugTraceInLS(remoteRobot); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"); String quickfixChooserString = "Make method public"; @@ -183,6 +186,7 @@ public void testJakartaQuickFixInJavaPart() { finally { // Replace modified content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + UIBotTestUtils.captureLSPConsoleLog(remoteRobot); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 2f1743cc5..ae2ed842e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -161,6 +161,9 @@ public void testMPQuickFixInJavaFile() { String quickfixChooserString = "Insert " + livenessString; String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'"; + UIBotTestUtils.clickOnWindowPaneStripeButton(remoteRobot, "Language Servers"); + UIBotTestUtils.enableMPDebugTraceInLS(remoteRobot); + // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java"); @@ -185,6 +188,7 @@ public void testMPQuickFixInJavaFile() { } finally { // Replace modified content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + UIBotTestUtils.captureLSPConsoleLog(remoteRobot); } } @@ -296,6 +300,9 @@ public void testQuickFixInMicroProfileConfigProperties() { Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", "microprofile-config.properties"); + UIBotTestUtils.clickOnWindowPaneStripeButton(remoteRobot, "Language Servers"); + UIBotTestUtils.enableMPDebugTraceInLS(remoteRobot); + // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties"); @@ -314,6 +321,7 @@ public void testQuickFixInMicroProfileConfigProperties() { } finally { // Replace modified microprofile-config.properties with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot, true); + UIBotTestUtils.captureLSPConsoleLog(remoteRobot); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 472828335..c13f2dd53 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -26,13 +26,18 @@ import java.awt.*; import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.KeyEvent; import java.io.BufferedReader; import java.io.FileWriter; +import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.time.Duration; import java.util.HashMap; import java.util.List; @@ -2939,4 +2944,143 @@ public static void clickOnLoad(RemoteRobot remoteRobot) { TestUtils.sleepAndIgnoreException(5); } + + /** + * Enable the trace level to verbose in LSP console + * + * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. + */ + public static void enableDebugTraceInLS(RemoteRobot remoteRobot) { + ComponentFixture node = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + + List rts = node.findAllText(); + for (RemoteText rt : rts) { + if (rt.getText().contains("Jakarta EE")) + rt.click(); + } + + ComponentFixture node1 = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + List rts1 = node1.findAllText(); + for (RemoteText rt : rts1) { + if (rt.getText().contains("Debug")) + rt.click(); + } + + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); + List comboBoxes = projectFrame.getComboBoxButton(); + ComboBoxFixture comboBox = comboBoxes.get(1); + comboBox.selectItem("verbose"); + + String xPath = "//div[starts-with(@accessiblename, 'Apply') and @class='ActionButton']"; + ComponentFixture actionButton = projectFrame.getActionButton(xPath, "10"); + actionButton.click(); + + ComponentFixture node3 = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + List rts3 = node3.findAllText(); + for (RemoteText rt : rts3) { + if (rt.getText().contains("start")) { + rt.click(); + break; + } + } + } + + /** + * Enable the trace level to verbose in LSP console + * + * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. + */ + public static void enableMPDebugTraceInLS(RemoteRobot remoteRobot) { + ComponentFixture node = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + + List rts = node.findAllText(); + for (RemoteText rt : rts) { + if (rt.getText().contains("MicroProfile")) + rt.click(); + } + + ComponentFixture node1 = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + List rts1 = node1.findAllText(); + for (RemoteText rt : rts1) { + if (rt.getText().contains("Debug")) + rt.click(); + } + + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); + List comboBoxes = projectFrame.getComboBoxButton(); + ComboBoxFixture comboBox = comboBoxes.get(1); + comboBox.selectItem("verbose"); + + String xPath = "//div[starts-with(@accessiblename, 'Apply') and @class='ActionButton']"; + ComponentFixture actionButton = projectFrame.getActionButton(xPath, "10"); + actionButton.click(); + + ComponentFixture node3 = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='LSPConsoleToolWindowPanel']"), Duration.ofSeconds(10)); + List rts3 = node3.findAllText(); + for (RemoteText rt : rts3) { + if (rt.getText().contains("started pid")) { + rt.click(); + } + } + } + + /** + * Access editor content in LSP console + * + * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. + */ + public static void captureLSPConsoleLog(RemoteRobot remoteRobot) { + Locator locator = byXpath("(//div[@class='EditorComponentImpl' and @accessiblename='Editor'])[1]"); + EditorFixture editorNew = remoteRobot.find(EditorFixture.class, locator, Duration.ofSeconds(20)); + editorNew.click(); + + copyEditorContent(remoteRobot); + } + + /** + * Copies the entire content of the LSP console, + * writes it to a log file, and then triggers the “Hide” action button in the UI. + * + * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. + */ + public static void copyEditorContent(RemoteRobot remoteRobot) { + Keyboard keyboard = new Keyboard(remoteRobot); + keyboard.hotKey(remoteRobot.isMac() ? KeyEvent.VK_META : KeyEvent.VK_CONTROL, KeyEvent.VK_A); + keyboard.hotKey(remoteRobot.isMac() ? KeyEvent.VK_META : KeyEvent.VK_CONTROL, KeyEvent.VK_C); + + String copiedText = getClipboardText(); + Path logPath = Path.of("build/reports/problems/lsp4ij-logs.log"); + try { + Files.createDirectories(logPath.getParent()); + + Files.writeString( + logPath, + copiedText + System.lineSeparator(), + StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING + ); + } catch (IOException e) { + throw new RuntimeException(e); + } + + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); + String xPath = "//div[starts-with(@accessiblename, 'Hide') and @class='ActionButton']"; + ComponentFixture actionButton = projectFrame.getActionButton(xPath, "10"); + actionButton.click(); + } + + /** + * Retrieves the current text content from the system clipboard. + */ + private static String getClipboardText() { + try { + TestUtils.sleepAndIgnoreException(1); + return (String) Toolkit.getDefaultToolkit() + .getSystemClipboard() + .getData(DataFlavor.stringFlavor); + } catch (UnsupportedFlavorException | IOException e) { + throw new RuntimeException("Failed to read from clipboard", e); + } + } + } diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index 25a7de186..967a4b4d4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -446,4 +446,11 @@ public void clickOnMainMenuWithActions(RemoteRobot remoteRobot, String... action throw new IllegalStateException("Failed to perform the menu actions after multiple attempts."); } } + + /** + * Method to get list of comboBoxes + */ + public List getComboBoxButton() { + return comboBoxes(byXpath("//div[@class='ComboBox']")); + } }