From a14a2ead965422d3e7bf5dd2c04f1d8033cf996e Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Fri, 8 Nov 2024 18:26:56 +0530 Subject: [PATCH 01/19] update package.json for new tests --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 71c69e79..d38c9c46 100644 --- a/package.json +++ b/package.json @@ -240,7 +240,8 @@ "buildJakarta": "gulp buildJakartaJdt buildJakartaLs", "test": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/*.js'", "test-mac-maven":"npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/M*.js'", - "test-mac-gradle": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/G*.js'" + "test-mac-gradle": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/G*.js'", + "test-lsp4jakarta": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/GradleSingle*.js'" }, "devDependencies": { "@types/chai": "^4.3.4", From 61f4d45dd445c269d1e40bd975e2493b75c7a386 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Fri, 8 Nov 2024 18:27:41 +0530 Subject: [PATCH 02/19] test for checking snippet rest_class --- src/test/GradleSingleModJakartaLSTest.ts | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/GradleSingleModJakartaLSTest.ts diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts new file mode 100644 index 00000000..5c568445 --- /dev/null +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -0,0 +1,33 @@ +import { TextEditor, EditorView, SideBarView, VSBrowser } from 'vscode-extension-tester'; +import * as constants from './definitions/constants'; +import * as utils from './utils/testUtils'; +import * as path from 'path'; +import * as assert from 'assert'; + +describe('LSP4Jakarta LS test for snippet test', () => { + + let editor: TextEditor; + + it('check if correct code is inserted when rest_class snippet is triggered', async() => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); + //editor.clear(); + editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; + editor.typeText("rest"); + + //open the assistant + const assist = await editor.toggleContentAssist(true); + // toggle can return void, so we need to make sure the object is present + if (assist) { + // to select an item use + await assist.select('rest_class') + } + + // close the assistant + await editor.toggleContentAssist(false); + + const insertedCode = await editor.getText(); + assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); + }).timeout(275000); + +}); \ No newline at end of file From b7e2dcb2dfe07aeae6524df113f33ba918da6319 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Fri, 8 Nov 2024 18:28:20 +0530 Subject: [PATCH 03/19] new resource for checking snippets completion --- .../src/main/java/test/gradle/liberty/web/app/SystemResource.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource.java diff --git a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource.java b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource.java new file mode 100644 index 00000000..e69de29b From d86ff94a61ab0568d126401c8a0ed438f33e221c Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 12 Nov 2024 13:23:34 +0530 Subject: [PATCH 04/19] Code improvements --- src/test/GradleSingleModJakartaLSTest.ts | 6 +- src/test/GradleTestDevModeActions.ts | 273 ----------------------- 2 files changed, 4 insertions(+), 275 deletions(-) delete mode 100755 src/test/GradleTestDevModeActions.ts diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 5c568445..4e228f89 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,4 +1,4 @@ -import { TextEditor, EditorView, SideBarView, VSBrowser } from 'vscode-extension-tester'; +import { TextEditor, EditorView, VSBrowser } from 'vscode-extension-tester'; import * as constants from './definitions/constants'; import * as utils from './utils/testUtils'; import * as path from 'path'; @@ -9,7 +9,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; it('check if correct code is inserted when rest_class snippet is triggered', async() => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); //editor.clear(); editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; @@ -28,6 +27,9 @@ describe('LSP4Jakarta LS test for snippet test', () => { const insertedCode = await editor.getText(); assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); + + await editor.clearText(); + await editor.save(); }).timeout(275000); }); \ No newline at end of file diff --git a/src/test/GradleTestDevModeActions.ts b/src/test/GradleTestDevModeActions.ts deleted file mode 100755 index 55994e41..00000000 --- a/src/test/GradleTestDevModeActions.ts +++ /dev/null @@ -1,273 +0,0 @@ -import { expect } from 'chai'; -import { InputBox, Workbench,SideBarView, ViewSection,EditorView,DefaultTreeItem, DebugView } from 'vscode-extension-tester'; -import * as utils from './utils/testUtils'; -import * as constants from './definitions/constants'; -import path = require('path'); - -describe('Devmode action tests for Gradle Project', () => { - let sidebar: SideBarView; - let debugView: DebugView; - let section: ViewSection; - let item: DefaultTreeItem; - let tabs: string[]; - - before(() => { - sidebar = new SideBarView(); - debugView = new DebugView(); - }); - -it('getViewControl works with the correct label', async() => { - - const contentPart = sidebar.getContent(); - section = await contentPart.getSection('Liberty Dashboard'); - console.log("Found Liberty Dashboard...."); - expect(section).not.undefined; - -}).timeout(10000); - - -it('Open dasboard shows items - Gradle', async () => { - - // Wait for the Liberty Dashboard to load and expand. The dashboard only expands after using the 'expand()' method. - await utils.delay(65000); - await section.expand(); - await utils.delay(6000); - const menu = await section.getVisibleItems(); - expect(menu).not.empty; - item = await section.findItem(constants.GRADLE_PROJECT) as DefaultTreeItem; - expect(item).not.undefined; - - -}).timeout(300000); - - -it('Start gradle project from liberty dashboard', async () => { - - - await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION,constants.START_DASHBOARD_MAC_ACTION); - await utils.delay(30000); - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - if(!serverStartStatus) - console.log("Server started message not found in the terminal"); - else - { - console.log("Server succuessfully started"); - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); - if(!serverStopStatus){ - console.error("Server stopped message not found in the terminal"); - } - else - console.log("Server stopped successfully"); - expect (serverStopStatus).to.be.true; -} - expect (serverStartStatus).to.be.true; - - -}).timeout(350000); - -it('Run tests for gradle project', async () => { - - await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION, constants.START_DASHBOARD_MAC_ACTION); - await utils.delay(30000); - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - console.log("after checkTerminalforServerState"); - if(!serverStartStatus) - console.log("Server started message not found in the terminal"); - else - { - console.log("Server succuessfully started"); - await utils.launchDashboardAction(item,constants.RUNTEST_DASHBOARD_ACTION,constants.RUNTEST_DASHBOARD_MAC_ACTION); - const testStatus = await utils.checkTestStatus(constants.GRADLE_TEST_RUN_STRING); - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); - if(!serverStopStatus) - console.error("Server stopped message not found in the terminal"); - else - console.log("Server stopped successfully"); - expect (serverStopStatus).to.be.true; - expect (testStatus).to.be.true; -} - expect (serverStartStatus).to.be.true; - - -}).timeout(350000); - - -it('start gradle with options from liberty dashboard', async () => { - - const reportPath = path.join(utils.getGradleProjectPath(),"build", "reports", "tests", "test", "index.html"); - const deleteReport = await utils.deleteReports(reportPath); - expect (deleteReport).to.be.true; - await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); - await utils.setCustomParameter("--hotTests"); - await utils.delay(30000); - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - if(!serverStartStatus) - console.log("Server started with params message not found in terminal "); - else - { - console.log("Server succuessfully started"); - let checkFile = await utils.checkIfTestReportExists(reportPath); - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); - console.log("after dashboard action"); - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); - if(!serverStopStatus) - console.error("Server stopped message not found in ther terminal"); - else - console.log("Server stopped successfully"); - expect (serverStopStatus).to.be.true; - expect (checkFile).to.be.true; -} - expect (serverStartStatus).to.be.true; - -}).timeout(550000); - -it('start gradle with history from liberty dashboard', async () => { - - const reportPath = path.join(utils.getGradleProjectPath(),"build", "reports", "tests", "test", "index.html"); - const deleteReport = await utils.deleteReports(reportPath); - expect (deleteReport).to.be.true; - await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); - const foundCommand = await utils.chooseCmdFromHistory("--hotTests"); - console.log("foundcmd:" + foundCommand); - expect (foundCommand).to.be.true; - await utils.delay(30000); - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - if(!serverStartStatus) - console.log("Server started with params message not found in the terminal "); - else - { - console.log("Server succuessfully started"); - let checkFile = await utils.checkIfTestReportExists(reportPath); - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); - if(!serverStopStatus) - console.error("Server stopped message not found in terminal"); - else - console.log("Server stopped successfully"); - expect (serverStopStatus).to.be.true; - expect (checkFile).to.be.true; -} - expect (serverStartStatus).to.be.true; - -}).timeout(350000); - - - - - - - - - - - - - - - - -it('attach debugger for gradle with custom parameter event', async () => { - console.log("start attach debugger"); - let isServerRunning: Boolean = true; - let attachStatus: Boolean = false; - try { - await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); - await utils.setCustomParameter("-DdebugPort=7777"); - await utils.delay(30000); - - isServerRunning = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - if (!isServerRunning) - console.log("Server started with params message not found in terminal"); - else { - console.log("Server succuessfully started"); - await utils.launchDashboardAction(item,constants.ATTACH_DEBUGGER_DASHBOARD_ACTION, constants.ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION); - console.log("Attach Debugger action done"); - await utils.delay(8000); - const contentPart = debugView.getContent(); - //console.log("Get Content"); - - let mysecarry: Promise = contentPart.getSections(); - let mysecmap: IterableIterator<[number, ViewSection]> = (await mysecarry).entries(); - for (const [key, value] of (mysecmap)) { - if ((await value.getEnclosingElement().getText()).includes("BREAKPOINTS")) { - //console.log("******** mysecmap getEnclosingElement " + (await value.getEnclosingElement().getText()).valueOf()); - console.log("Found Breakpoints"); - attachStatus = true; - break; - } - } - - await utils.stopLibertyserver(); - isServerRunning = !await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); //negate isServerRunning - if (!isServerRunning) - console.log("Server stopped successfully "); - } - } catch (e) { - console.error("error - ", e) - } finally { - console.log("finally block: is server running - ", isServerRunning); - if (isServerRunning) { - utils.stopLibertyserver(); - } - else - console.log("good to close test - Attach Debugger for start with custom parameter(-DdebugPort=7777) event"); - } - expect(attachStatus).to.be.true; -}).timeout(550000); - -it('start gradle with docker from liberty dashboard', async () => { - - if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux')) - { - //skip running for platforms , enable them for linux after resolving docker setup in GHA - return true; - } - - - await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITHDOCKER, constants.START_DASHBOARD_MAC_ACTION_WITHDOCKER); - await utils.delay(60000); - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); - if(!serverStartStatus) - console.log("Server started message not found in the terminal"); - else - { - console.log("Server succuessfully started"); - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); - if(!serverStopStatus){ - console.error("Server stopped message not found in the terminal"); - } - else - console.log("Server stopped successfully"); - expect (serverStopStatus).to.be.true; -} - expect (serverStartStatus).to.be.true; - - -}).timeout(350000); - -it('View test report for gradle project', async () => { - - if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux')) - { - //skip running for platforms , enable once https://github.com/OpenLiberty/liberty-tools-vscode/issues/266 is resolved - return true; - } - - await utils.launchDashboardAction(item,constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION); - tabs = await new EditorView().getOpenEditorTitles(); - // expect (tabs[1]], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE); - expect (tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE)>-1, "Gradle test report not found").to.equal(true); - -}).timeout(30000); - - // Based on the UI testing code, it sometimes selects the wrong command in "command palette", such as choosing "Liberty: Start ..." instead of "Liberty: Start" from the recent suggestions. This discrepancy occurs because we specifically need "Liberty: Start" at that moment. - // Now, clear the command history of the "command palette" to avoid receiving "recently used" suggestions. This action should be performed at the end of Gradle Project tests. -it('Clear Command Palatte', async () => { - await utils.clearCommandPalette(); -}).timeout(100000); - -}); - From 7cdd8213724e8ed9fec170952c9e57ae7a39c2ae Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 12 Nov 2024 13:24:54 +0530 Subject: [PATCH 05/19] Revert "Code improvements" This reverts commit d86ff94a61ab0568d126401c8a0ed438f33e221c. --- src/test/GradleSingleModJakartaLSTest.ts | 6 +- src/test/GradleTestDevModeActions.ts | 273 +++++++++++++++++++++++ 2 files changed, 275 insertions(+), 4 deletions(-) create mode 100755 src/test/GradleTestDevModeActions.ts diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 4e228f89..5c568445 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,4 +1,4 @@ -import { TextEditor, EditorView, VSBrowser } from 'vscode-extension-tester'; +import { TextEditor, EditorView, SideBarView, VSBrowser } from 'vscode-extension-tester'; import * as constants from './definitions/constants'; import * as utils from './utils/testUtils'; import * as path from 'path'; @@ -9,6 +9,7 @@ describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; it('check if correct code is inserted when rest_class snippet is triggered', async() => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); //editor.clear(); editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; @@ -27,9 +28,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { const insertedCode = await editor.getText(); assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); - - await editor.clearText(); - await editor.save(); }).timeout(275000); }); \ No newline at end of file diff --git a/src/test/GradleTestDevModeActions.ts b/src/test/GradleTestDevModeActions.ts new file mode 100755 index 00000000..55994e41 --- /dev/null +++ b/src/test/GradleTestDevModeActions.ts @@ -0,0 +1,273 @@ +import { expect } from 'chai'; +import { InputBox, Workbench,SideBarView, ViewSection,EditorView,DefaultTreeItem, DebugView } from 'vscode-extension-tester'; +import * as utils from './utils/testUtils'; +import * as constants from './definitions/constants'; +import path = require('path'); + +describe('Devmode action tests for Gradle Project', () => { + let sidebar: SideBarView; + let debugView: DebugView; + let section: ViewSection; + let item: DefaultTreeItem; + let tabs: string[]; + + before(() => { + sidebar = new SideBarView(); + debugView = new DebugView(); + }); + +it('getViewControl works with the correct label', async() => { + + const contentPart = sidebar.getContent(); + section = await contentPart.getSection('Liberty Dashboard'); + console.log("Found Liberty Dashboard...."); + expect(section).not.undefined; + +}).timeout(10000); + + +it('Open dasboard shows items - Gradle', async () => { + + // Wait for the Liberty Dashboard to load and expand. The dashboard only expands after using the 'expand()' method. + await utils.delay(65000); + await section.expand(); + await utils.delay(6000); + const menu = await section.getVisibleItems(); + expect(menu).not.empty; + item = await section.findItem(constants.GRADLE_PROJECT) as DefaultTreeItem; + expect(item).not.undefined; + + +}).timeout(300000); + + +it('Start gradle project from liberty dashboard', async () => { + + + await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION,constants.START_DASHBOARD_MAC_ACTION); + await utils.delay(30000); + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + if(!serverStartStatus) + console.log("Server started message not found in the terminal"); + else + { + console.log("Server succuessfully started"); + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); + if(!serverStopStatus){ + console.error("Server stopped message not found in the terminal"); + } + else + console.log("Server stopped successfully"); + expect (serverStopStatus).to.be.true; +} + expect (serverStartStatus).to.be.true; + + +}).timeout(350000); + +it('Run tests for gradle project', async () => { + + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION, constants.START_DASHBOARD_MAC_ACTION); + await utils.delay(30000); + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + console.log("after checkTerminalforServerState"); + if(!serverStartStatus) + console.log("Server started message not found in the terminal"); + else + { + console.log("Server succuessfully started"); + await utils.launchDashboardAction(item,constants.RUNTEST_DASHBOARD_ACTION,constants.RUNTEST_DASHBOARD_MAC_ACTION); + const testStatus = await utils.checkTestStatus(constants.GRADLE_TEST_RUN_STRING); + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); + if(!serverStopStatus) + console.error("Server stopped message not found in the terminal"); + else + console.log("Server stopped successfully"); + expect (serverStopStatus).to.be.true; + expect (testStatus).to.be.true; +} + expect (serverStartStatus).to.be.true; + + +}).timeout(350000); + + +it('start gradle with options from liberty dashboard', async () => { + + const reportPath = path.join(utils.getGradleProjectPath(),"build", "reports", "tests", "test", "index.html"); + const deleteReport = await utils.deleteReports(reportPath); + expect (deleteReport).to.be.true; + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); + await utils.setCustomParameter("--hotTests"); + await utils.delay(30000); + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + if(!serverStartStatus) + console.log("Server started with params message not found in terminal "); + else + { + console.log("Server succuessfully started"); + let checkFile = await utils.checkIfTestReportExists(reportPath); + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); + console.log("after dashboard action"); + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); + if(!serverStopStatus) + console.error("Server stopped message not found in ther terminal"); + else + console.log("Server stopped successfully"); + expect (serverStopStatus).to.be.true; + expect (checkFile).to.be.true; +} + expect (serverStartStatus).to.be.true; + +}).timeout(550000); + +it('start gradle with history from liberty dashboard', async () => { + + const reportPath = path.join(utils.getGradleProjectPath(),"build", "reports", "tests", "test", "index.html"); + const deleteReport = await utils.deleteReports(reportPath); + expect (deleteReport).to.be.true; + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); + const foundCommand = await utils.chooseCmdFromHistory("--hotTests"); + console.log("foundcmd:" + foundCommand); + expect (foundCommand).to.be.true; + await utils.delay(30000); + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + if(!serverStartStatus) + console.log("Server started with params message not found in the terminal "); + else + { + console.log("Server succuessfully started"); + let checkFile = await utils.checkIfTestReportExists(reportPath); + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); + if(!serverStopStatus) + console.error("Server stopped message not found in terminal"); + else + console.log("Server stopped successfully"); + expect (serverStopStatus).to.be.true; + expect (checkFile).to.be.true; +} + expect (serverStartStatus).to.be.true; + +}).timeout(350000); + + + + + + + + + + + + + + + + +it('attach debugger for gradle with custom parameter event', async () => { + console.log("start attach debugger"); + let isServerRunning: Boolean = true; + let attachStatus: Boolean = false; + try { + await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); + await utils.setCustomParameter("-DdebugPort=7777"); + await utils.delay(30000); + + isServerRunning = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + if (!isServerRunning) + console.log("Server started with params message not found in terminal"); + else { + console.log("Server succuessfully started"); + await utils.launchDashboardAction(item,constants.ATTACH_DEBUGGER_DASHBOARD_ACTION, constants.ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION); + console.log("Attach Debugger action done"); + await utils.delay(8000); + const contentPart = debugView.getContent(); + //console.log("Get Content"); + + let mysecarry: Promise = contentPart.getSections(); + let mysecmap: IterableIterator<[number, ViewSection]> = (await mysecarry).entries(); + for (const [key, value] of (mysecmap)) { + if ((await value.getEnclosingElement().getText()).includes("BREAKPOINTS")) { + //console.log("******** mysecmap getEnclosingElement " + (await value.getEnclosingElement().getText()).valueOf()); + console.log("Found Breakpoints"); + attachStatus = true; + break; + } + } + + await utils.stopLibertyserver(); + isServerRunning = !await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); //negate isServerRunning + if (!isServerRunning) + console.log("Server stopped successfully "); + } + } catch (e) { + console.error("error - ", e) + } finally { + console.log("finally block: is server running - ", isServerRunning); + if (isServerRunning) { + utils.stopLibertyserver(); + } + else + console.log("good to close test - Attach Debugger for start with custom parameter(-DdebugPort=7777) event"); + } + expect(attachStatus).to.be.true; +}).timeout(550000); + +it('start gradle with docker from liberty dashboard', async () => { + + if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux')) + { + //skip running for platforms , enable them for linux after resolving docker setup in GHA + return true; + } + + + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITHDOCKER, constants.START_DASHBOARD_MAC_ACTION_WITHDOCKER); + await utils.delay(60000); + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); + if(!serverStartStatus) + console.log("Server started message not found in the terminal"); + else + { + console.log("Server succuessfully started"); + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); + if(!serverStopStatus){ + console.error("Server stopped message not found in the terminal"); + } + else + console.log("Server stopped successfully"); + expect (serverStopStatus).to.be.true; +} + expect (serverStartStatus).to.be.true; + + +}).timeout(350000); + +it('View test report for gradle project', async () => { + + if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux')) + { + //skip running for platforms , enable once https://github.com/OpenLiberty/liberty-tools-vscode/issues/266 is resolved + return true; + } + + await utils.launchDashboardAction(item,constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION); + tabs = await new EditorView().getOpenEditorTitles(); + // expect (tabs[1]], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE); + expect (tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE)>-1, "Gradle test report not found").to.equal(true); + +}).timeout(30000); + + // Based on the UI testing code, it sometimes selects the wrong command in "command palette", such as choosing "Liberty: Start ..." instead of "Liberty: Start" from the recent suggestions. This discrepancy occurs because we specifically need "Liberty: Start" at that moment. + // Now, clear the command history of the "command palette" to avoid receiving "recently used" suggestions. This action should be performed at the end of Gradle Project tests. +it('Clear Command Palatte', async () => { + await utils.clearCommandPalette(); +}).timeout(100000); + +}); + From 5114a6a310a6e1d77921b86e51f8f58c0592ff0c Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 12 Nov 2024 13:26:40 +0530 Subject: [PATCH 06/19] Code improvements --- src/test/GradleSingleModJakartaLSTest.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 5c568445..fa819867 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,5 +1,4 @@ -import { TextEditor, EditorView, SideBarView, VSBrowser } from 'vscode-extension-tester'; -import * as constants from './definitions/constants'; +import { TextEditor, EditorView, VSBrowser } from 'vscode-extension-tester'; import * as utils from './utils/testUtils'; import * as path from 'path'; import * as assert from 'assert'; @@ -9,7 +8,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; it('check if correct code is inserted when rest_class snippet is triggered', async() => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); //editor.clear(); editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; From 89e67152270367d9c2d5507c8c0036d172878bbd Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 12 Nov 2024 13:31:34 +0530 Subject: [PATCH 07/19] removed tests added as part of lsp4jakarta --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index d38c9c46..71c69e79 100644 --- a/package.json +++ b/package.json @@ -240,8 +240,7 @@ "buildJakarta": "gulp buildJakartaJdt buildJakartaLs", "test": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/*.js'", "test-mac-maven":"npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/M*.js'", - "test-mac-gradle": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/G*.js'", - "test-lsp4jakarta": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/GradleSingle*.js'" + "test-mac-gradle": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/G*.js'" }, "devDependencies": { "@types/chai": "^4.3.4", From dcea4c9d740360a7b88a0cf9500be00d449aae09 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 12 Nov 2024 13:53:58 +0530 Subject: [PATCH 08/19] performance improvement --- src/test/GradleSingleModJakartaLSTest.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index fa819867..64d417a4 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -9,8 +9,14 @@ describe('LSP4Jakarta LS test for snippet test', () => { it('check if correct code is inserted when rest_class snippet is triggered', async() => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); - //editor.clear(); + editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; + + const textPressent = await editor.getText(); + if(textPressent.length > 0){ + editor.clearText(); + } + editor.typeText("rest"); //open the assistant @@ -26,6 +32,9 @@ describe('LSP4Jakarta LS test for snippet test', () => { const insertedCode = await editor.getText(); assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); + + await editor.clearText(); + await editor.save(); }).timeout(275000); }); \ No newline at end of file From 7e1c8ccb80d2eadeaad2851d7f1683d4e46724ca Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 13 Nov 2024 11:12:48 +0530 Subject: [PATCH 09/19] Initial implementation --- src/test/GradleSingleModJakartaLSTest.ts | 43 ++++++++++++++++++- .../liberty/web/app/SystemResource2.java | 16 +++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource2.java diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 64d417a4..c22bd1f2 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,4 +1,4 @@ -import { TextEditor, EditorView, VSBrowser } from 'vscode-extension-tester'; +import { TextEditor, EditorView, VSBrowser, TitleBar, BottomBarPanel, MarkerType } from 'vscode-extension-tester'; import * as utils from './utils/testUtils'; import * as path from 'path'; import * as assert from 'assert'; @@ -6,6 +6,13 @@ import * as assert from 'assert'; describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; + let titleBar: TitleBar; + let bottomBar: BottomBarPanel; + + before(() => { + titleBar = new TitleBar(); + bottomBar = new BottomBarPanel(); + }); it('check if correct code is inserted when rest_class snippet is triggered', async() => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); @@ -37,4 +44,38 @@ describe('LSP4Jakarta LS test for snippet test', () => { await editor.save(); }).timeout(275000); + it('check for diagnostic support', async() => { + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); + + editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; + + //await titleBar.select("Selection", "Select All"); + //await titleBar.select("Edit", "Copy"); + + let insertedCode = await editor.getText(); + insertedCode = insertedCode.replace("public String", "private String"); + await editor.setText(insertedCode); + + await utils.delay(3000); + + const problemsView = await bottomBar.openProblemsView(); + const errors = await problemsView.getAllVisibleMarkers(MarkerType.Error); + await utils.delay(3000); + let privateMethodError = false; + errors.forEach(async (value) => { + const label = await value.getText(); + console.log("label: ", label); + if(label.includes("Error: Only public methods can be exposed as resource methods")){ + privateMethodError = true; + } + }); + assert(privateMethodError, "Did not find diagnostic help text."); + + // await titleBar.select("Selection", "Select All"); + // await titleBar.select("Edit", "Paste"); + + utils.delay(10000); + + }).timeout(275000); + }); \ No newline at end of file diff --git a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource2.java b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource2.java new file mode 100644 index 00000000..dec9b61f --- /dev/null +++ b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource2.java @@ -0,0 +1,16 @@ +package test.gradle.liberty.web.app; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/path") +public class SystemResource2 { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String methodname() { + return "hello"; + } +} \ No newline at end of file From b4261c6f643e2fc142607bec548d3d5789b43dab Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 13 Nov 2024 12:08:04 +0530 Subject: [PATCH 10/19] diagnostic support by public methods --- src/test/GradleSingleModJakartaLSTest.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index c22bd1f2..045e4354 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -49,33 +49,29 @@ describe('LSP4Jakarta LS test for snippet test', () => { editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; - //await titleBar.select("Selection", "Select All"); - //await titleBar.select("Edit", "Copy"); - let insertedCode = await editor.getText(); + // change the resource method from public to private insertedCode = insertedCode.replace("public String", "private String"); await editor.setText(insertedCode); - await utils.delay(3000); + // opeining the problem window const problemsView = await bottomBar.openProblemsView(); + // filtering the problems with type error const errors = await problemsView.getAllVisibleMarkers(MarkerType.Error); await utils.delay(3000); let privateMethodError = false; + // iterates through errors array and find whether the error Only public methods can be exposed as resource methods exists or not errors.forEach(async (value) => { const label = await value.getText(); console.log("label: ", label); - if(label.includes("Error: Only public methods can be exposed as resource methods")){ + if(label.includes("Only public methods can be exposed as resource methods")){ privateMethodError = true; } }); + await utils.delay(5000); assert(privateMethodError, "Did not find diagnostic help text."); - // await titleBar.select("Selection", "Select All"); - // await titleBar.select("Edit", "Paste"); - - utils.delay(10000); - }).timeout(275000); }); \ No newline at end of file From ea6aa8acf599c5e0b7329b4a55e745ca980a1918 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 13 Nov 2024 12:32:50 +0530 Subject: [PATCH 11/19] revert state back to original after test --- src/test/GradleSingleModJakartaLSTest.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 045e4354..15bc6731 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -70,8 +70,15 @@ describe('LSP4Jakarta LS test for snippet test', () => { } }); await utils.delay(5000); + assert(privateMethodError, "Did not find diagnostic help text."); + // change back to original state + insertedCode = insertedCode.replace("private String", "public String"); + await editor.clearText(); + await editor.setText(insertedCode); + await utils.delay(2000); + }).timeout(275000); }); \ No newline at end of file From bcf6d60c9534db2d09aa0cef6dde9d088845c6d0 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Tue, 19 Nov 2024 13:42:10 +0530 Subject: [PATCH 12/19] quick fix implementation --- src/test/GradleSingleModJakartaLSTest.ts | 58 ++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 15bc6731..290bbcb3 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,4 +1,4 @@ -import { TextEditor, EditorView, VSBrowser, TitleBar, BottomBarPanel, MarkerType } from 'vscode-extension-tester'; +import { TextEditor, EditorView, VSBrowser, BottomBarPanel, MarkerType, By } from 'vscode-extension-tester'; import * as utils from './utils/testUtils'; import * as path from 'path'; import * as assert from 'assert'; @@ -6,11 +6,9 @@ import * as assert from 'assert'; describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; - let titleBar: TitleBar; let bottomBar: BottomBarPanel; before(() => { - titleBar = new TitleBar(); bottomBar = new BottomBarPanel(); }); @@ -77,8 +75,62 @@ describe('LSP4Jakarta LS test for snippet test', () => { insertedCode = insertedCode.replace("private String", "public String"); await editor.clearText(); await editor.setText(insertedCode); + await bottomBar.closePanel(); await utils.delay(2000); }).timeout(275000); + it('check for qucikfix support', async() => { + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); + + editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; + + let insertedCode = await editor.getText(); + // change the resource method from public to private + insertedCode = insertedCode.replace("public String", "private String"); + await editor.setText(insertedCode); + await utils.delay(3000); + + const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); + // await utils.delay(3000); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: flaggedString }).perform(); + await utils.delay(3000); + + const driver = VSBrowser.instance.driver; + const hoverValue = await editor.findElement(By.className('hover-row status-bar')); + // await utils.delay(2000); + + const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); + await quickFixPopupLink.click(); + + const hoverBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + await hoverBar.findElement(By.className('actionList')); + // await utils.delay(2000); + + const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); + // Setting pointer block element display value as none to choose option from Quickfix menu + if (pointerBlockElementt) { + await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockElementt); + } else { + console.log('pointerBlockElementt not found!'); + } + const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Make method public\")]")); + await fixOption.click(); + await utils.delay(3000); + + const updatedContent = await editor.getText(); + // await utils.delay(3000); + // console.log("Content after Quick fix : ", updatedContent); + assert(updatedContent.includes('public String methodname'), 'quick fix not applied correctly.'); + await utils.delay(3000); + + // change back to original state + insertedCode = insertedCode.replace("private String", "public String"); + await editor.clearText(); + await editor.setText(insertedCode); + await utils.delay(2000); + }).timeout(275000); + }); \ No newline at end of file From c83fdd72e6c5f512df8ce24abdfe416e076d0cca Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 20 Nov 2024 11:01:02 +0530 Subject: [PATCH 13/19] removed comments --- src/test/GradleSingleModJakartaLSTest.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 290bbcb3..fe13f6b0 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -92,7 +92,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { await utils.delay(3000); const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); - // await utils.delay(3000); const actions = VSBrowser.instance.driver.actions(); await actions.move({ origin: flaggedString }).perform(); @@ -100,14 +99,12 @@ describe('LSP4Jakarta LS test for snippet test', () => { const driver = VSBrowser.instance.driver; const hoverValue = await editor.findElement(By.className('hover-row status-bar')); - // await utils.delay(2000); const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); await quickFixPopupLink.click(); const hoverBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); await hoverBar.findElement(By.className('actionList')); - // await utils.delay(2000); const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); // Setting pointer block element display value as none to choose option from Quickfix menu @@ -121,8 +118,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { await utils.delay(3000); const updatedContent = await editor.getText(); - // await utils.delay(3000); - // console.log("Content after Quick fix : ", updatedContent); assert(updatedContent.includes('public String methodname'), 'quick fix not applied correctly.'); await utils.delay(3000); From 3a3ee80970f0089f8da671a1597124b5284f9e66 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 20 Nov 2024 11:07:38 +0530 Subject: [PATCH 14/19] corrections in code --- src/test/GradleSingleModJakartaLSTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index fe13f6b0..e6797a69 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -19,10 +19,10 @@ describe('LSP4Jakarta LS test for snippet test', () => { const textPressent = await editor.getText(); if(textPressent.length > 0){ - editor.clearText(); + await editor.clearText(); } - editor.typeText("rest"); + await editor.typeText("rest"); //open the assistant const assist = await editor.toggleContentAssist(true); From 11ab7e6b76fb62f73e8fd4a1cc1edabfbd112af1 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 20 Nov 2024 11:14:51 +0530 Subject: [PATCH 15/19] corrected hover support code to work in all platforms --- src/test/GradleSingleModJakartaLSTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index e6797a69..06ae5fa5 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -100,7 +100,7 @@ describe('LSP4Jakarta LS test for snippet test', () => { const driver = VSBrowser.instance.driver; const hoverValue = await editor.findElement(By.className('hover-row status-bar')); - const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); + const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); await quickFixPopupLink.click(); const hoverBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); From fdc707579350668bea949d986cc99f5e488a903c Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 20 Nov 2024 11:25:04 +0530 Subject: [PATCH 16/19] cleaning the code --- src/test/GradleSingleModJakartaLSTest.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 06ae5fa5..6e8eee86 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -103,9 +103,6 @@ describe('LSP4Jakarta LS test for snippet test', () => { const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); await quickFixPopupLink.click(); - const hoverBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverBar.findElement(By.className('actionList')); - const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); // Setting pointer block element display value as none to choose option from Quickfix menu if (pointerBlockElementt) { From 5696a01e6d79b4de80099056a7ad8d729d2c2996 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Wed, 20 Nov 2024 11:55:13 +0530 Subject: [PATCH 17/19] changed to support diagnostic from hover --- src/test/GradleSingleModJakartaLSTest.ts | 41 +++++++++++------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 6e8eee86..e6ec8043 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -1,4 +1,4 @@ -import { TextEditor, EditorView, VSBrowser, BottomBarPanel, MarkerType, By } from 'vscode-extension-tester'; +import { TextEditor, EditorView, VSBrowser, By } from 'vscode-extension-tester'; import * as utils from './utils/testUtils'; import * as path from 'path'; import * as assert from 'assert'; @@ -6,11 +6,6 @@ import * as assert from 'assert'; describe('LSP4Jakarta LS test for snippet test', () => { let editor: TextEditor; - let bottomBar: BottomBarPanel; - - before(() => { - bottomBar = new BottomBarPanel(); - }); it('check if correct code is inserted when rest_class snippet is triggered', async() => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); @@ -53,29 +48,29 @@ describe('LSP4Jakarta LS test for snippet test', () => { await editor.setText(insertedCode); await utils.delay(3000); - // opeining the problem window - const problemsView = await bottomBar.openProblemsView(); - // filtering the problems with type error - const errors = await problemsView.getAllVisibleMarkers(MarkerType.Error); + const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: flaggedString }).perform(); await utils.delay(3000); - let privateMethodError = false; - // iterates through errors array and find whether the error Only public methods can be exposed as resource methods exists or not - errors.forEach(async (value) => { - const label = await value.getText(); - console.log("label: ", label); - if(label.includes("Only public methods can be exposed as resource methods")){ - privateMethodError = true; - } - }); - await utils.delay(5000); - - assert(privateMethodError, "Did not find diagnostic help text."); + + const hoverValue = await editor.findElement(By.className('hover-row status-bar')); + + const viewProblemLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'View Problem')]")); + await viewProblemLink.click(); + + const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Only public methods can be exposed as resource methods\")]")); + await utils.delay(2000); + console.log("fixoption reached"); + const diagnostic = await fixOption.getText(); + console.log("dignostic text", diagnostic); + + assert(diagnostic.includes("Only public methods can be exposed as resource methods"), "Did not find diagnostic help text."); // change back to original state insertedCode = insertedCode.replace("private String", "public String"); await editor.clearText(); await editor.setText(insertedCode); - await bottomBar.closePanel(); await utils.delay(2000); }).timeout(275000); From b768cd60015e3791a58f72dc3d5536f613a6259e Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Thu, 21 Nov 2024 11:25:22 +0530 Subject: [PATCH 18/19] removed logs --- src/test/GradleSingleModJakartaLSTest.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index e6ec8043..821491f6 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -61,9 +61,7 @@ describe('LSP4Jakarta LS test for snippet test', () => { const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Only public methods can be exposed as resource methods\")]")); await utils.delay(2000); - console.log("fixoption reached"); const diagnostic = await fixOption.getText(); - console.log("dignostic text", diagnostic); assert(diagnostic.includes("Only public methods can be exposed as resource methods"), "Did not find diagnostic help text."); From a8cba7a6cfd795025baa1aa1bd15fe0376bda8e4 Mon Sep 17 00:00:00 2001 From: gilbysunil14 Date: Mon, 20 Jan 2025 14:01:41 +0530 Subject: [PATCH 19/19] corrected indentation and removed unnecessary logs --- src/test/GradleSingleModJakartaLSTest.ts | 48 +++++++++++++----------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/test/GradleSingleModJakartaLSTest.ts b/src/test/GradleSingleModJakartaLSTest.ts index 821491f6..8cffdd8e 100644 --- a/src/test/GradleSingleModJakartaLSTest.ts +++ b/src/test/GradleSingleModJakartaLSTest.ts @@ -17,42 +17,47 @@ describe('LSP4Jakarta LS test for snippet test', () => { await editor.clearText(); } + await utils.delay(85000); await editor.typeText("rest"); + await utils.delay(6000); //open the assistant const assist = await editor.toggleContentAssist(true); - // toggle can return void, so we need to make sure the object is present - if (assist) { - // to select an item use - await assist.select('rest_class') - } + await utils.delay(6000); + // toggle can return void, so we need to make sure the object is present + if (assist) { + // to select an item use + await assist.select('rest_class'); + } + await utils.delay(6000); - // close the assistant - await editor.toggleContentAssist(false); + // close the assistant + await editor.toggleContentAssist(false); const insertedCode = await editor.getText(); + await utils.delay(6000); assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); await editor.clearText(); await editor.save(); - }).timeout(275000); + }).timeout(475000); it('check for diagnostic support', async() => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); - + editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; let insertedCode = await editor.getText(); // change the resource method from public to private insertedCode = insertedCode.replace("public String", "private String"); await editor.setText(insertedCode); - await utils.delay(3000); + await utils.delay(6000); const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); const actions = VSBrowser.instance.driver.actions(); await actions.move({ origin: flaggedString }).perform(); - await utils.delay(3000); + await utils.delay(6000); const hoverValue = await editor.findElement(By.className('hover-row status-bar')); @@ -60,7 +65,7 @@ describe('LSP4Jakarta LS test for snippet test', () => { await viewProblemLink.click(); const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Only public methods can be exposed as resource methods\")]")); - await utils.delay(2000); + await utils.delay(6000); const diagnostic = await fixOption.getText(); assert(diagnostic.includes("Only public methods can be exposed as resource methods"), "Did not find diagnostic help text."); @@ -69,13 +74,12 @@ describe('LSP4Jakarta LS test for snippet test', () => { insertedCode = insertedCode.replace("private String", "public String"); await editor.clearText(); await editor.setText(insertedCode); - await utils.delay(2000); - - }).timeout(275000); + await utils.delay(4000); + }).timeout(475000); it('check for qucikfix support', async() => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); - + editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; let insertedCode = await editor.getText(); @@ -88,7 +92,7 @@ describe('LSP4Jakarta LS test for snippet test', () => { const actions = VSBrowser.instance.driver.actions(); await actions.move({ origin: flaggedString }).perform(); - await utils.delay(3000); + await utils.delay(6000); const driver = VSBrowser.instance.driver; const hoverValue = await editor.findElement(By.className('hover-row status-bar')); @@ -101,21 +105,21 @@ describe('LSP4Jakarta LS test for snippet test', () => { if (pointerBlockElementt) { await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockElementt); } else { - console.log('pointerBlockElementt not found!'); + console.log('Element not found!'); } const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Make method public\")]")); await fixOption.click(); - await utils.delay(3000); + await utils.delay(6000); const updatedContent = await editor.getText(); assert(updatedContent.includes('public String methodname'), 'quick fix not applied correctly.'); - await utils.delay(3000); + await utils.delay(6000); // change back to original state insertedCode = insertedCode.replace("private String", "public String"); await editor.clearText(); await editor.setText(insertedCode); - await utils.delay(2000); - }).timeout(275000); + await utils.delay(4000); + }).timeout(475000); }); \ No newline at end of file