diff --git a/package.json b/package.json index ba0ab602..7a2115a5 100644 --- a/package.json +++ b/package.json @@ -240,7 +240,9 @@ "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-mac-maven-project-with-space": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/MavenTestDevModeActionsWSPath*.js'", + "test-mac-gradle-project-with-space": "npm run test-compile && extest setup-and-run -o .vscode/settings.json 'out/test/GradleTestDevModeActionsPathWS*.js'" }, "devDependencies": { "@types/chai": "^4.3.4", diff --git a/src/test/GradleTestDevModeActionsPathWSInit.ts b/src/test/GradleTestDevModeActionsPathWSInit.ts new file mode 100644 index 00000000..544faeda --- /dev/null +++ b/src/test/GradleTestDevModeActionsPathWSInit.ts @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2024 IBM Corporation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import { WebDriver, VSBrowser } from 'vscode-extension-tester'; +import * as utils from './utils/testUtils'; + +describe('Open Gradle Project - Project name with space', () => { + + let driver: WebDriver; + before(() => { + /** + * Create new gradle project name with space in the new directory + */ + utils.getProjectWithSpaceInDir(utils.getGradleProjectPath(), utils.getGradleProjectPathWithSpace()); + driver = VSBrowser.instance.driver; + + }); + + it('Open Sample Gradle Project - Project name with space', async () => { + await utils.delay(8000); + await VSBrowser.instance.openResources(utils.getGradleProjectPathWithSpace()); + }).timeout(25000); +}); + + diff --git a/src/test/GradleTestDevModeActionsPathWSTasks.ts b/src/test/GradleTestDevModeActionsPathWSTasks.ts new file mode 100644 index 00000000..cc634fad --- /dev/null +++ b/src/test/GradleTestDevModeActionsPathWSTasks.ts @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2024 IBM Corporation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import { expect } from 'chai'; +import { 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- Project name with space', () => { + + 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(25000); + + it('Open dasboard shows items - Gradle', async () => { + + await utils.delay(85000); + await section.expand(); + await utils.delay(6000); + const menu = await section.getVisibleItems(); + expect(menu).not.empty; + item = await section.findItem(constants.GRADLE_PROJECT_WSP) 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.getGradleProjectPathWithSpace(), "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.getGradleProjectPathWithSpace(), "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(); + + 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("Found Breakpoints"); + attachStatus = true; + break; + } + } + + await utils.stopLibertyserver(constants.GRADLE_PROJECT_WSP); + 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(constants.GRADLE_PROJECT_WSP); + } + 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); + + /* + * 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); + + after(() => { + const gradleProjectPath = path.join(__dirname, "..", "..", "src", "test", "resources", "gradle project"); + console.log("Current path __dirname: " + __dirname); + console.log("Removing project from the path: " + gradleProjectPath); + /** + * Remove newly created project after test case execution + */ + utils.removeProjectFolderWithContent(gradleProjectPath); + }); + +}); + diff --git a/src/test/MavenTestDevModeActionsWSPathInit.ts b/src/test/MavenTestDevModeActionsWSPathInit.ts new file mode 100644 index 00000000..7da65acf --- /dev/null +++ b/src/test/MavenTestDevModeActionsWSPathInit.ts @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2024 IBM Corporation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import { WebDriver, VSBrowser } from 'vscode-extension-tester'; +import * as utils from './utils/testUtils'; + +describe('Open Maven Project - path with space', () => { + + let driver: WebDriver; + before(() => { + /** + * Create new gradle project name with space in the new directory + */ + utils.getProjectWithSpaceInDir(utils.getMvnProjectPath(), utils.getMvnProjectDirWithSpace()); + driver = VSBrowser.instance.driver; + + }); + + it('Open Sample Maven Project - path with space', async () => { + await utils.delay(8000); + await VSBrowser.instance.openResources(utils.getMvnProjectDirWithSpace()); + }).timeout(15000); + +}); \ No newline at end of file diff --git a/src/test/MavenTestDevModeActionsWSPathTasks.ts b/src/test/MavenTestDevModeActionsWSPathTasks.ts new file mode 100644 index 00000000..0dabe139 --- /dev/null +++ b/src/test/MavenTestDevModeActionsWSPathTasks.ts @@ -0,0 +1,274 @@ +/** + * Copyright (c) 2024 IBM Corporation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import { expect } from 'chai'; +import { SideBarView, ViewItem, 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 Maven Project - path with space', () => { + + let sidebar: SideBarView; + let debugView: DebugView; + let section: ViewSection; + let menu: ViewItem[]; + 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(15000); + + it('Open dasboard shows items - Maven', async () => { + + await utils.delay(65000); + section.expand(); + await utils.delay(6000); + const menu = await section.getVisibleItems(); + expect(menu).not.empty; + item = await section.findItem(constants.MAVEN_PROJECT) as DefaultTreeItem; + expect(item).not.undefined; + + }).timeout(275000); + + it('Start maven 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(550000); + + it('Run tests for sample maven 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.MAVEN_RUN_TESTS_STRING); + expect(testStatus).to.be.true; + 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('start maven with options from liberty dashboard', async () => { + + const reportPath = path.join(utils.getMvnProjectDirWithSpace(), "target", "site", "failsafe-report.html"); + const reportPath35 = path.join(utils.getMvnProjectDirWithSpace(), "target", "reports", "failsafe.html"); + let deleteReport = await utils.deleteReports(reportPath); + let deleteReport35 = await utils.deleteReports(reportPath35); + expect(deleteReport || deleteReport35).to.be.true; + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM); + await utils.setCustomParameter("-DhotTests=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 terminal "); + else { + console.log("Server succuessfully started"); + let checkFile = await utils.checkIfTestReportExists(reportPath); + let checkFile35 = await utils.checkIfTestReportExists(reportPath35); + expect(checkFile || checkFile35).to.be.true; + 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 ther terminal"); + } + else + console.log("Server stopped successfully"); + expect(serverStopStatus).to.be.true; + } + expect(serverStartStatus).to.be.true; + + }).timeout(350000); + + it('start maven with history from liberty dashboard', async () => { + + const reportPath = path.join(utils.getMvnProjectDirWithSpace(), "target", "site", "failsafe-report.html"); + const reportPath35 = path.join(utils.getMvnProjectDirWithSpace(), "target", "reports", "failsafe.html"); + let deleteReport = await utils.deleteReports(reportPath); + let deleteReport35 = await utils.deleteReports(reportPath35); + expect(deleteReport || deleteReport35).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("-DhotTests=true"); + 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); + let checkFile35 = await utils.checkIfTestReportExists(reportPath35); + expect(checkFile || checkFile35).to.be.true; + 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(serverStartStatus).to.be.true; + + }).timeout(550000); + + it('View Unit test report for maven project', async () => { + + await utils.launchDashboardAction(item, constants.UTR_DASHABOARD_ACTION, constants.UTR_DASHABOARD_MAC_ACTION); + tabs = await new EditorView().getOpenEditorTitles(); + //expect (tabs[1], "Unit test report not found").to.equal(constants.SUREFIRE_REPORT_TITLE); + expect(tabs.indexOf(constants.SUREFIRE_REPORT_TITLE) > -1, "Unit test report not found").to.equal(true); + + }).timeout(10000); + + it('View Integration test report for maven project', async () => { + + await utils.launchDashboardAction(item, constants.ITR_DASHBOARD_ACTION, constants.ITR_DASHBOARD_MAC_ACTION); + tabs = await new EditorView().getOpenEditorTitles(); + //expect (tabs[2], "Integration test report not found").to.equal(constants.FAILSAFE_REPORT_TITLE); + expect(tabs.indexOf(constants.FAILSAFE_REPORT_TITLE) > -1, "Integration test report not found").to.equal(true); + + }).timeout(10000); + + it('attach debugger for start 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(constants.MAVEN_PROJECT); + 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(constants.MAVEN_PROJECT); + } + else + console.log("good to close test - Attach Debugger for start with custom parameter(-DdebugPort=7777) event"); + } + expect(attachStatus).to.be.true; + }).timeout(350000); + + it('start maven 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); + + after(() => { + + const mavenProjectPath = path.join(__dirname, "..", "..", "src", "test", "resources", "maven project"); + console.log("Current path __dirname" + mavenProjectPath); + console.log("Project path to remove" + mavenProjectPath); + /** + * Remove newly created project after test case execution + */ + + utils.removeProjectFolderWithContent(mavenProjectPath); + console.log("Project removed from the path:" + mavenProjectPath); + + }); + +}); \ No newline at end of file diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index d421e824..5488ee36 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -40,3 +40,4 @@ export const ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION = "Liberty: Attach debugger"; export const MAVEN_DEVMODE_DEBUG_PORT_PARM = "-DdebugPort"; /** Gradle: Dev mode debug port argument key. */ export const GRADLE_DEVMODE_DEBUG_PORT_PARM = "--libertyDebugPort"; +export const GRADLE_PROJECT_WSP= "liberty.gradle.te st.wrapper.app"; diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 0e5f6a33..dd87debd 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -5,6 +5,7 @@ import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; import { MapContextMenuforMac } from './macUtils'; import clipboard = require('clipboardy'); import { expect } from 'chai'; +import * as fse from 'fs-extra'; export function delay(millisec: number) { return new Promise( resolve => setTimeout(resolve, millisec) ); @@ -193,4 +194,54 @@ export async function clearCommandPalette() { await dialog.pushButton('Clear'); } - \ No newline at end of file +/** + * Function return project name with space + */ +export function getGradleProjectPathWithSpace(): any { + const gradleProjectPath = path.join(__dirname, "..", "..", "..", "src", "test", "resources", "gradle project", "liberty.gradle.te st.wrapper.app"); + + return gradleProjectPath; +} + +/** + * Create new gradle project name with space in the directory + */ + +export async function getProjectWithSpaceInDir(existingProjectPath: string, copyProjectPath: string): Promise { + fse.copy(existingProjectPath, copyProjectPath) + .then(() => console.log("Project renamed., Gradle Project path is :" + copyProjectPath)) + .catch(err => console.log("Error renaming the project")); +} + +/** + * Remove newly created Project folder with content + */ +export async function removeProjectFolderWithContent(projectPath: string): Promise { + try { + fs.accessSync(projectPath); + const projectContent = fs.readdirSync(projectPath); + await Promise.all( + projectContent.map(async (projectFiles) => { + const projectContentPath = path.join(projectPath, projectFiles); + const stats = fs.lstatSync(projectContentPath); + if (stats.isDirectory()) { + await removeProjectFolderWithContent(projectContentPath); + } else { + fs.unlinkSync(projectContentPath); + } + }) + ); + fs.rmdirSync(projectPath); + } catch (error) { + console.error(`Error removing new project: ${error}`); + } +} + +/** + * Function return project path with space + */ +export function getMvnProjectDirWithSpace(): any { + const mavenProjectPath = path.join(__dirname, "..", "..", "..", "src", "test", "resources", "maven project", "liberty.maven.test.wrapper.app"); + console.log("Maven project path is ", mavenProjectPath); + return mavenProjectPath; +} \ No newline at end of file