|
1 | 1 | import { expect } from 'chai'; |
2 | | -import { InputBox, Workbench,SideBarView, ViewItem, ViewSection,EditorView, DefaultTreeItem , DebugView } from 'vscode-extension-tester'; |
| 2 | +import { InputBox, Workbench,SideBarView, ViewItem, ViewSection,EditorView, DefaultTreeItem , DebugView, VSBrowser } from 'vscode-extension-tester'; |
3 | 3 | import * as utils from './utils/testUtils'; |
4 | 4 | import * as constants from './definitions/constants'; |
5 | 5 | import path = require('path'); |
| 6 | +import * as fs from 'fs'; |
6 | 7 |
|
7 | 8 | describe('Devmode action tests for Maven Project', () => { |
8 | 9 | let sidebar: SideBarView; |
@@ -67,6 +68,37 @@ it('Start maven project from liberty dashboard', async () => { |
67 | 68 |
|
68 | 69 | }).timeout(550000); |
69 | 70 |
|
| 71 | +it('start maven with docker from liberty dashboard', async () => { |
| 72 | + |
| 73 | + if((process.platform === 'darwin' ) || (process.platform === 'win32')) |
| 74 | + { |
| 75 | + //skip running for platforms , enable them for linux after resolving docker setup in GHA |
| 76 | + return true; |
| 77 | + } |
| 78 | + |
| 79 | + |
| 80 | + await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITHDOCKER, constants.START_DASHBOARD_MAC_ACTION_WITHDOCKER); |
| 81 | + await utils.delay(60000); |
| 82 | + const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); |
| 83 | + if(!serverStartStatus) |
| 84 | + console.log("Server started message not found in the terminal"); |
| 85 | + else |
| 86 | + { |
| 87 | + console.log("Server succuessfully started"); |
| 88 | + await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); |
| 89 | + const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); |
| 90 | + if(!serverStopStatus){ |
| 91 | + console.error("Server stopped message not found in the terminal"); |
| 92 | + } |
| 93 | + else |
| 94 | + console.log("Server stopped successfully"); |
| 95 | + expect (serverStopStatus).to.be.true; |
| 96 | +} |
| 97 | + expect (serverStartStatus).to.be.true; |
| 98 | + |
| 99 | + |
| 100 | +}).timeout(350000); |
| 101 | + |
70 | 102 | it('Run tests for sample maven project', async () => { |
71 | 103 |
|
72 | 104 | await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION, constants.START_DASHBOARD_MAC_ACTION); |
@@ -188,6 +220,10 @@ it('View Integration test report for maven project', async () => { |
188 | 220 |
|
189 | 221 | }).timeout(10000); |
190 | 222 |
|
| 223 | +/** |
| 224 | + * All future test cases should be written before the test that attaches the debugger, as this will switch the UI to the debugger view. |
| 225 | + * If, for any reason, a test case needs to be written after the debugger test, ensure that the UI is switched back to the explorer view before executing the subsequent tests. |
| 226 | + */ |
191 | 227 | it('attach debugger for start with custom parameter event', async () => { |
192 | 228 | console.log("start attach debugger"); |
193 | 229 | let isServerRunning: Boolean = true; |
@@ -238,37 +274,38 @@ it('attach debugger for start with custom parameter event', async () => { |
238 | 274 | expect(attachStatus).to.be.true; |
239 | 275 | }).timeout(350000); |
240 | 276 |
|
241 | | - it('start maven with docker from liberty dashboard', async () => { |
| 277 | + /** |
| 278 | + * The following after hook copies the screenshot from the temporary folder in which it is saved to a known permanent location in the project folder. |
| 279 | + * The MavenTestDevModeAction is the last test file that will be executed. Hence the after hook placed here |
| 280 | + * ensures that all the screenshots will be copied to a known permanent location in the project folder. |
| 281 | + */ |
| 282 | + after(() => { |
| 283 | + const sourcePath = VSBrowser.instance.getScreenshotsDir(); |
| 284 | + const destinationPath = './screenshots'; |
242 | 285 |
|
243 | | - if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux')) |
244 | | - { |
245 | | - //skip running for platforms , enable them for linux after resolving docker setup in GHA |
246 | | - return true; |
247 | | - } |
248 | | - |
249 | | - |
250 | | - await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITHDOCKER, constants.START_DASHBOARD_MAC_ACTION_WITHDOCKER); |
251 | | - await utils.delay(60000); |
252 | | - const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING); |
253 | | - if(!serverStartStatus) |
254 | | - console.log("Server started message not found in the terminal"); |
255 | | - else |
256 | | - { |
257 | | - console.log("Server succuessfully started"); |
258 | | - await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION); |
259 | | - const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); |
260 | | - if(!serverStopStatus){ |
261 | | - console.error("Server stopped message not found in the terminal"); |
| 286 | + copyFolderContents(sourcePath, destinationPath); |
| 287 | + }); |
| 288 | + |
| 289 | + function copyFolderContents(sourceFolder: string, destinationFolder: string): void { |
| 290 | + if (!fs.existsSync(sourceFolder)) { |
| 291 | + return; |
| 292 | + } |
| 293 | + |
| 294 | + if (!fs.existsSync(destinationFolder)) { |
| 295 | + fs.mkdirSync(destinationFolder); |
262 | 296 | } |
263 | | - else |
264 | | - console.log("Server stopped successfully"); |
265 | | - expect (serverStopStatus).to.be.true; |
266 | | -} |
267 | | - expect (serverStartStatus).to.be.true; |
268 | | - |
269 | | - |
270 | | -}).timeout(350000); |
271 | 297 |
|
| 298 | + const files = fs.readdirSync(sourceFolder); |
| 299 | + for (const file of files) { |
| 300 | + const sourcePath = path.join(sourceFolder, file); |
| 301 | + const destinationPath = path.join(destinationFolder, file); |
272 | 302 |
|
| 303 | + if (fs.statSync(sourcePath).isDirectory()) { |
| 304 | + copyFolderContents(sourcePath, destinationPath); |
| 305 | + } else { |
| 306 | + fs.copyFileSync(sourcePath, destinationPath); |
| 307 | + } |
| 308 | + } |
| 309 | + } |
273 | 310 | }); |
274 | 311 |
|
0 commit comments