From 08aefcd64a7e9b6385bece3c0449365630a1d722 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 12 Nov 2024 23:01:34 +0530 Subject: [PATCH 01/44] code to open server.xml and entry for logging --- src/test/GradleTestDevModeActionsLCLS.ts | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 src/test/GradleTestDevModeActionsLCLS.ts diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts new file mode 100755 index 00000000..e4461a6b --- /dev/null +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -0,0 +1,71 @@ +import { EditorView, SideBarView, TextEditor, VSBrowser, BottomBarPanel, MarkerType, Workbench } from "vscode-extension-tester"; +import * as utils from './utils/testUtils'; +import * as constants from './definitions/constants'; + +const { Keys } = require('vscode-extension-tester'); +const path = require('path'); +const assert = require('assert'); + +describe('Quick Fix Test for Server XML', function () { + let editor: TextEditor; + let filePath: string; + let originalContent: string; + + // before(async function () { + + // }); + it('should apply quick fix for invalid value in server.xml', async () => { + + + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')) + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + originalContent = await editor.getText(); + const wrongtext = ""; + await editor.typeTextAt(17, 5, wrongtext); + await utils.delay(15000); + + // await editor.moveCursor(17, 33); + + // await utils.delay(30000); + // await editor.moveCursor(17, 1); + // await utils.delay(30000); + + // await editor.click(); + + + + const problemsView = await new BottomBarPanel().openProblemsView(); + await utils.delay(30000); + console.log("Problems view :" + problemsView) + + const errors = await problemsView.getAllVisibleMarkers(MarkerType.Any); + await utils.delay(30000); + // await problemsView.collapseAll(); + // const markers = await problemsView.getAllVisibleMarkers(MarkerType.Any); + const error = errors[1]; + await utils.delay(30000); + const text = await error.getText(); + + console.log("updated text marker:" + text) + const correctedStanza = ''; + const updatedContent = await editor.getText(); + if (text == 'cvc-datatype-valid.1.2.3: \'wrong\' is not a valid value of union type \'booleanType\'.') { + console.log("updated content:" + text) + + } + console.log("updated content:" + updatedContent) + assert(updatedContent.includes(correctedStanza), 'The server.xml was not corrected with the expected quick fix.'); + + + + }).timeout(100000); + + after(async function () { + await editor.clearText(); + await editor.setText(originalContent); + editor.save(); + }); +}); From c1a82a4d42975515340873b31cd7acc5dab1d273 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 15 Nov 2024 01:40:36 +0530 Subject: [PATCH 02/44] code added for hover and quicfix --- src/test/GradleTestDevModeActionsLCLS.ts | 134 ++++++++++++++--------- 1 file changed, 85 insertions(+), 49 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index e4461a6b..82e57afb 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -1,6 +1,9 @@ -import { EditorView, SideBarView, TextEditor, VSBrowser, BottomBarPanel, MarkerType, Workbench } from "vscode-extension-tester"; + +import { EditorView, SideBarView, TextEditor, VSBrowser, MarkerType, BottomBarPanel } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; +import { By, until } from 'selenium-webdriver'; +import { moveCursor } from "readline"; const { Keys } = require('vscode-extension-tester'); const path = require('path'); @@ -11,61 +14,94 @@ describe('Quick Fix Test for Server XML', function () { let filePath: string; let originalContent: string; - // before(async function () { - - // }); it('should apply quick fix for invalid value in server.xml', async () => { - - + // Step 1: Open the project and file const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')) + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + // Step 2: Open the editor editor = await new EditorView().openEditor('server.xml') as TextEditor; originalContent = await editor.getText(); - const wrongtext = ""; - await editor.typeTextAt(17, 5, wrongtext); - await utils.delay(15000); - - // await editor.moveCursor(17, 33); - - // await utils.delay(30000); - // await editor.moveCursor(17, 1); - // await utils.delay(30000); - - // await editor.click(); - - - const problemsView = await new BottomBarPanel().openProblemsView(); - await utils.delay(30000); - console.log("Problems view :" + problemsView) - - const errors = await problemsView.getAllVisibleMarkers(MarkerType.Any); - await utils.delay(30000); - // await problemsView.collapseAll(); - // const markers = await problemsView.getAllVisibleMarkers(MarkerType.Any); - const error = errors[1]; - await utils.delay(30000); - const text = await error.getText(); - - console.log("updated text marker:" + text) - const correctedStanza = ''; - const updatedContent = await editor.getText(); - if (text == 'cvc-datatype-valid.1.2.3: \'wrong\' is not a valid value of union type \'booleanType\'.') { - console.log("updated content:" + text) + + const wrongtext = ""; + await editor.typeTextAt(17, 5, wrongtext); + await utils.delay(8000); + const element = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + await utils.delay(5000); + console.log("element value:" + element); + element.click(); + const tagname = element.getTagName(); + console.log("tagname:" + tagname); + await editor.click(); + console.log("uafter editor click"); + + const el = await editor.moveCursor(17, 35); + + const actions = VSBrowser.instance.driver.actions(); + const quickfi = await actions.move({ origin: element }).perform(); + + await utils.delay(2000); + + // const eleme = editor.findElement(By.); + const driver = VSBrowser.instance.driver; + const quickFixPopupLink = editor.findElement(By.className('hover-row status-bar')); + console.log("uafter quickFixPopupLink"); + await utils.delay(3000); + const elem=await quickFixPopupLink.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); + + await utils.delay(2000); + elem.click(); + console.log("uafter elem"); + const val=editor.findElement(By.className('context-view monaco-component bottom left fixed')); + console.log("uafter val"); + await utils.delay(2000); + + const actionList= await val.findElement(By.className('actionList')); + await utils.delay(2000); + // // val.click(); + // const t=ele.isDisplayed(); + // console.log("uafter t value "+t); + // const v= await ele.findElement(By.xpath("//*[contains(text(), 'false')]")); + // await utils.delay(2000); + // const ds=v?.isDisplayed(); + // console.log("uafter displayed "+ds); + // v.click(); + // await utils.delay(2000); + // const assistant = await editor.toggleContentAssist(true); + // await utils.delay(2000); + // if (assistant) { + // await utils.delay(5000); + // // const ele=await assistant.click('Replace with \'false\''); + // const ele=await assistant.select('Replace with \'true\''); + // await assistant.getText(); + // // ele?.click; + // console.log('after ele click'+ele); + // // const e=await assistant.select('false'); + // } + // await editor.toggleContentAssist(false); + // await editor.getDriver().actions().sendKeys(Keys.CONTROL, '.').perform(); + // await utils.delay(2000); // Wait for the quick fix menu to appear + + // // Select the first quick fix option (e.g., 'Replace with false') + // const quickFixOption = await VSBrowser.instance.driver.findElement(By.name("//*[contains(text(), 'Replace with \'false\'')]")); + // await utils.delay(1000); + // await quickFixOption.click(); + + const fixOption = await actionList.findElement(By.xpath("//*[contains(text(), \"'false'\")]")); + const loc=fixOption.getLocation; + console.log("before displayed "+loc); + // v.click(); + if(await fixOption.isSelected()){ + + fixOption.click(); + console.log("uafter displayed "); + } - console.log("updated content:" + updatedContent) - assert(updatedContent.includes(correctedStanza), 'The server.xml was not corrected with the expected quick fix.'); - - - - }).timeout(100000); - - after(async function () { - await editor.clearText(); - await editor.setText(originalContent); - editor.save(); - }); + await utils.delay(5000); + const updatedContent = await editor.getText(); + assert.notStrictEqual(updatedContent, originalContent, 'Content should be updated after applying quick fix'); + }).timeout(150000); }); From 121f17b76d0a19c0cefc3c1ec3421a9ac9b6b3e0 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 16:54:56 +0530 Subject: [PATCH 03/44] Code added to open server.xml --- src/test/GradleTestDevModeActionsLCLS.ts | 96 ++---------------------- 1 file changed, 8 insertions(+), 88 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index 82e57afb..be930626 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -1,107 +1,27 @@ -import { EditorView, SideBarView, TextEditor, VSBrowser, MarkerType, BottomBarPanel } from "vscode-extension-tester"; +import { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; -import { By, until } from 'selenium-webdriver'; -import { moveCursor } from "readline"; -const { Keys } = require('vscode-extension-tester'); const path = require('path'); const assert = require('assert'); -describe('Quick Fix Test for Server XML', function () { +describe('LCLS Test for Gradle Project', function () { let editor: TextEditor; - let filePath: string; - let originalContent: string; - + it('should apply quick fix for invalid value in server.xml', async () => { - // Step 1: Open the project and file const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); - // Step 2: Open the editor editor = await new EditorView().openEditor('server.xml') as TextEditor; - originalContent = await editor.getText(); - - const wrongtext = ""; - await editor.typeTextAt(17, 5, wrongtext); - await utils.delay(8000); - const element = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - await utils.delay(5000); - console.log("element value:" + element); - element.click(); - const tagname = element.getTagName(); - console.log("tagname:" + tagname); - await editor.click(); - console.log("uafter editor click"); - - const el = await editor.moveCursor(17, 35); - - const actions = VSBrowser.instance.driver.actions(); - const quickfi = await actions.move({ origin: element }).perform(); - - await utils.delay(2000); - - // const eleme = editor.findElement(By.); - const driver = VSBrowser.instance.driver; - const quickFixPopupLink = editor.findElement(By.className('hover-row status-bar')); - console.log("uafter quickFixPopupLink"); - await utils.delay(3000); - const elem=await quickFixPopupLink.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); - - await utils.delay(2000); - elem.click(); - console.log("uafter elem"); - const val=editor.findElement(By.className('context-view monaco-component bottom left fixed')); - console.log("uafter val"); - await utils.delay(2000); - - const actionList= await val.findElement(By.className('actionList')); - await utils.delay(2000); - // // val.click(); - // const t=ele.isDisplayed(); - // console.log("uafter t value "+t); - // const v= await ele.findElement(By.xpath("//*[contains(text(), 'false')]")); - // await utils.delay(2000); - // const ds=v?.isDisplayed(); - // console.log("uafter displayed "+ds); - // v.click(); - // await utils.delay(2000); - // const assistant = await editor.toggleContentAssist(true); - // await utils.delay(2000); - // if (assistant) { - // await utils.delay(5000); - // // const ele=await assistant.click('Replace with \'false\''); - // const ele=await assistant.select('Replace with \'true\''); - // await assistant.getText(); - // // ele?.click; - // console.log('after ele click'+ele); - // // const e=await assistant.select('false'); - // } - // await editor.toggleContentAssist(false); - // await editor.getDriver().actions().sendKeys(Keys.CONTROL, '.').perform(); - // await utils.delay(2000); // Wait for the quick fix menu to appear - - // // Select the first quick fix option (e.g., 'Replace with false') - // const quickFixOption = await VSBrowser.instance.driver.findElement(By.name("//*[contains(text(), 'Replace with \'false\'')]")); - // await utils.delay(1000); - // await quickFixOption.click(); + const correcttext = ""; - const fixOption = await actionList.findElement(By.xpath("//*[contains(text(), \"'false'\")]")); - const loc=fixOption.getLocation; - console.log("before displayed "+loc); - // v.click(); - if(await fixOption.isSelected()){ - - fixOption.click(); - console.log("uafter displayed "); - - } - await utils.delay(5000); const updatedContent = await editor.getText(); - assert.notStrictEqual(updatedContent, originalContent, 'Content should be updated after applying quick fix'); - }).timeout(150000); + await utils.delay(3000); + console.log("Content after Quick fix : ", updatedContent); + assert(updatedContent.includes(correcttext), 'quick fix not applied correctly.'); + }).timeout(25000); }); From 277109386058274cce3253337ca6615dd99dafd0 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 16:58:00 +0530 Subject: [PATCH 04/44] Code Added for write text in server.xml --- src/test/GradleTestDevModeActionsLCLS.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index be930626..621e283a 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -8,7 +8,7 @@ const assert = require('assert'); describe('LCLS Test for Gradle Project', function () { let editor: TextEditor; - + it('should apply quick fix for invalid value in server.xml', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); @@ -18,10 +18,16 @@ describe('LCLS Test for Gradle Project', function () { const wrongtext = ""; const correcttext = ""; - + await editor.typeTextAt(17, 5, wrongtext); + await utils.delay(2000); + const LoggingTagElement = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + await utils.delay(3000); + LoggingTagElement.click(); + await editor.click(); + const updatedContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); assert(updatedContent.includes(correcttext), 'quick fix not applied correctly.'); - }).timeout(25000); + }).timeout(25000); }); From 80d8e87ac4c48825477586b1ddc76e55a605ec41 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 16:59:04 +0530 Subject: [PATCH 05/44] Code for hover data --- src/test/GradleTestDevModeActionsLCLS.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index 621e283a..99c1c954 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -24,7 +24,23 @@ describe('LCLS Test for Gradle Project', function () { await utils.delay(3000); LoggingTagElement.click(); await editor.click(); + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: LoggingTagElement }).perform(); + await utils.delay(3000); + + const driver = VSBrowser.instance.driver; + const hoverValue = editor.findElement(By.className('hover-row status-bar')); + await utils.delay(2000); + const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); + quickFixPopupLink.click(); + + const hoverBar = editor.findElement(By.className('context-view monaco-component bottom left fixed')); + const actionList = await hoverBar.findElement(By.className('actionList')); + actionList.click(); + + await utils.delay(2000); + const updatedContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); From 01d668f32ef42536b113ba7af859bc98c298789b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 17:00:37 +0530 Subject: [PATCH 06/44] Code for quick fix --- src/test/GradleTestDevModeActionsLCLS.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index 99c1c954..9f32caa2 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -40,7 +40,17 @@ describe('LCLS Test for Gradle Project', function () { actionList.click(); await utils.delay(2000); - + const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); + + 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(), \"Replace with 'false'\")]")); + await fixOption.click(); + + const updatedContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); From 3f5e62fb28eb5dca99cfb4fda945e2412f071f4d Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 17:35:04 +0530 Subject: [PATCH 07/44] Code formatted --- src/test/GradleTestDevModeActionsLCLS.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index 9f32caa2..dd1e5a4c 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -16,9 +16,9 @@ describe('LCLS Test for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; - const wrongtext = ""; - const correcttext = ""; - await editor.typeTextAt(17, 5, wrongtext); + const stanzaSnippet = ""; + const expectedText = ""; + await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(2000); const LoggingTagElement = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); @@ -50,10 +50,9 @@ describe('LCLS Test for Gradle Project', function () { const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'false'\")]")); await fixOption.click(); - const updatedContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); - assert(updatedContent.includes(correcttext), 'quick fix not applied correctly.'); + assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); }).timeout(25000); }); From dbba2a0dc6856d6b658acec8c356e98cffc14487 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 18:03:05 +0530 Subject: [PATCH 08/44] removed unwanted code --- src/test/GradleTestDevModeActionsLCLS.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index dd1e5a4c..b488e6e7 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -17,13 +17,12 @@ describe('LCLS Test for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnippet = ""; - const expectedText = ""; + const expectedText = ""; await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(2000); const LoggingTagElement = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); - LoggingTagElement.click(); - await editor.click(); + const actions = VSBrowser.instance.driver.actions(); await actions.move({ origin: LoggingTagElement }).perform(); await utils.delay(3000); @@ -33,21 +32,19 @@ describe('LCLS Test for Gradle Project', function () { await utils.delay(2000); const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); - quickFixPopupLink.click(); + await quickFixPopupLink.click(); const hoverBar = editor.findElement(By.className('context-view monaco-component bottom left fixed')); - const actionList = await hoverBar.findElement(By.className('actionList')); - actionList.click(); - + await hoverBar.findElement(By.className('actionList')); await utils.delay(2000); - const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); + const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); 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(), \"Replace with 'false'\")]")); + const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); await fixOption.click(); const updatedContent = await editor.getText(); From 3e4affe5c309437c21634a97e6c13c0d3584c142 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 18 Nov 2024 18:16:36 +0530 Subject: [PATCH 09/44] Copyright and docuementation --- src/test/GradleTestDevModeActionsLCLS.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts index b488e6e7..e08f7a97 100755 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ b/src/test/GradleTestDevModeActionsLCLS.ts @@ -1,4 +1,12 @@ - +/** + * 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 { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; @@ -20,11 +28,11 @@ describe('LCLS Test for Gradle Project', function () { const expectedText = ""; await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(2000); - const LoggingTagElement = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: LoggingTagElement }).perform(); + await actions.move({ origin: flaggedString }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; @@ -39,6 +47,7 @@ describe('LCLS Test for Gradle Project', function () { 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 { From 150019ca4ca5a0ed83e53f276d6f292557c00ca2 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 20 Nov 2024 20:37:34 +0530 Subject: [PATCH 10/44] Renamed file --- src/test/GradleSingleModLCLSTest.ts | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 src/test/GradleSingleModLCLSTest.ts diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts new file mode 100755 index 00000000..e08f7a97 --- /dev/null +++ b/src/test/GradleSingleModLCLSTest.ts @@ -0,0 +1,64 @@ +/** + * 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 { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; +import * as utils from './utils/testUtils'; +import * as constants from './definitions/constants'; + +const path = require('path'); +const assert = require('assert'); + +describe('LCLS Test for Gradle Project', function () { + let editor: TextEditor; + + it('should apply quick fix for invalid value in server.xml', async () => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const stanzaSnippet = ""; + const expectedText = ""; + await editor.typeTextAt(17, 5, stanzaSnippet); + await utils.delay(2000); + const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + 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 = 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 = 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(), \"Replace with 'true'\")]")); + await fixOption.click(); + + const updatedContent = await editor.getText(); + await utils.delay(3000); + console.log("Content after Quick fix : ", updatedContent); + assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); + }).timeout(25000); +}); From 7fdc278cb330285e8888b37bdd8ee109df4862e6 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 20 Nov 2024 20:38:40 +0530 Subject: [PATCH 11/44] Renamed file to GradleSingleModLCLSTest --- src/test/GradleTestDevModeActionsLCLS.ts | 64 ------------------------ 1 file changed, 64 deletions(-) delete mode 100755 src/test/GradleTestDevModeActionsLCLS.ts diff --git a/src/test/GradleTestDevModeActionsLCLS.ts b/src/test/GradleTestDevModeActionsLCLS.ts deleted file mode 100755 index e08f7a97..00000000 --- a/src/test/GradleTestDevModeActionsLCLS.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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 { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; -import * as utils from './utils/testUtils'; -import * as constants from './definitions/constants'; - -const path = require('path'); -const assert = require('assert'); - -describe('LCLS Test for Gradle Project', function () { - let editor: TextEditor; - - it('should apply quick fix for invalid value in server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); - - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const stanzaSnippet = ""; - const expectedText = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); - await utils.delay(2000); - const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - 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 = 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 = 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(), \"Replace with 'true'\")]")); - await fixOption.click(); - - const updatedContent = await editor.getText(); - await utils.delay(3000); - console.log("Content after Quick fix : ", updatedContent); - assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); - }).timeout(25000); -}); From 108bfd5666a7f5f6e26c8a552bded8a263990f09 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 20 Nov 2024 21:41:39 +0530 Subject: [PATCH 12/44] added code to update the old content --- src/test/GradleSingleModLCLSTest.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index e08f7a97..084d4e3b 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -23,7 +23,7 @@ describe('LCLS Test for Gradle Project', function () { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - + const actualContent = await editor.getText(); const stanzaSnippet = ""; const expectedText = ""; await editor.typeTextAt(17, 5, stanzaSnippet); @@ -60,5 +60,9 @@ describe('LCLS Test for Gradle Project', function () { await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); + editor.clearText(); + editor.setText(actualContent); + console.log("Content restored"); + }).timeout(25000); }); From 23d1ce7537c295c295325635ec1b31867fe61908 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 20 Nov 2024 22:45:52 +0530 Subject: [PATCH 13/44] hover support for server.xml Liberty Server Attribute --- src/test/GradleSingleModLCLSTest.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 084d4e3b..d135ea5f 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -65,4 +65,30 @@ describe('LCLS Test for Gradle Project', function () { console.log("Content restored"); }).timeout(25000); + + it('should show hover support for server.xml Liberty Server Attribute', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint. +Source: ol-24.0.0.11.xsd`; + + console.log(hoverExpectedOutcome); + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + await utils.delay(3000); + focusTargetLement.click(); + await editor.click(); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetLement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); + + assert(hoverValue === (hoverExpectedOutcome), 'Did not get expected hover data.'); + + }).timeout(25000); }); From 6eba89dffb6b73f5bbfc789a1c6df64112494c8b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 19:56:26 +0530 Subject: [PATCH 14/44] updated code for quick fix element --- src/test/GradleSingleModLCLSTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index d135ea5f..92047ac7 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -39,7 +39,7 @@ describe('LCLS Test for Gradle Project', function () { const hoverValue = editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - 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 = editor.findElement(By.className('context-view monaco-component bottom left fixed')); From 13bb97765d36338067a7eb293fa76528aa2fe1f1 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 19:48:48 +0530 Subject: [PATCH 15/44] Added code for new config folder --- src/test/GradleSingleModLCLSTest.ts | 112 ++++++++++++------ .../src/main/liberty/config/server.env | 0 src/test/utils/testUtils.ts | 35 +++++- 3 files changed, 109 insertions(+), 38 deletions(-) create mode 100644 src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.env diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 92047ac7..f4c9a038 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -14,81 +14,119 @@ import * as constants from './definitions/constants'; const path = require('path'); const assert = require('assert'); -describe('LCLS Test for Gradle Project', function () { +describe('LCLS tests for Gradle Project', function () { let editor: TextEditor; - it('should apply quick fix for invalid value in server.xml', async () => { + before(() => { + utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'),path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + }); + + it('Should apply quick fix for invalid value in server.xml', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const actualContent = await editor.getText(); - const stanzaSnippet = ""; - const expectedText = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); + const actualSeverXMLContent = await editor.getText(); + const stanzaSnipet = ""; + const expectedHoverData = ""; + await editor.typeTextAt(17, 5, stanzaSnipet); await utils.delay(2000); - const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flaggedString }).perform(); + await actions.move({ origin: flagedString }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverValue = editor.findElement(By.className('hover-row status-bar')); + const hoverTxt= 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 qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await qckFixPopupLink.click(); - const hoverBar = editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverBar.findElement(By.className('actionList')); + const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + await hoverTaskBar.findElement(By.className('actionList')); await utils.delay(2000); - const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); + const pointerBlockedElement = 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); + if (pointerBlockedElement) { + await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); } else { console.log('pointerBlockElementt not found!'); } - const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - await fixOption.click(); + const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + await qckfixOption.click(); - const updatedContent = await editor.getText(); + const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); - console.log("Content after Quick fix : ", updatedContent); - assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); - editor.clearText(); - editor.setText(actualContent); + console.log("Content after Quick fix : ", updatedSeverXMLContent); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly.'); + await editor.clearText(); + await editor.setText(actualSeverXMLContent); console.log("Content restored"); - }).timeout(25000); + }).timeout(38000); + + it('Should show hover support for server.env', async () => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const testHverTarget = "WLP_LOGGING_CONSOLE_LOGLEVEL=AUDIT"; + const hverExpectdOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; + await editor.typeTextAt(1, 1, testHverTarget); + await utils.delay(2000); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'LOGLEVEL')]")); + await utils.delay(3000); + focusTargtElemnt.click(); + await editor.click(); + + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); + await utils.delay(5000); + + const hverContent = editor.findElement(By.className('hover-contents')); + const hverValue = await hverContent.getText(); + console.log("Hover text:" + hverValue); + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + await editor.clearText(); - it('should show hover support for server.xml Liberty Server Attribute', async () => { + }).timeout(35000); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + it('Should show hover support for server.xml Liberty Server Attribute', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint. + const hverExpectdOutcome = `Configuration properties for an HTTP endpoint. Source: ol-24.0.0.11.xsd`; - console.log(hoverExpectedOutcome); - const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + console.log(hverExpectdOutcome); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); await utils.delay(3000); - focusTargetLement.click(); + focusTargtElemnt.click(); await editor.click(); - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: focusTargetLement }).perform(); + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); await utils.delay(5000); - const hoverContents = editor.findElement(By.className('hover-contents')); - const hoverValue = await hoverContents.getText(); + const hverContent = editor.findElement(By.className('hover-contents')); + const hoverValue = await hverContent.getText(); console.log("Hover text:" + hoverValue); - assert(hoverValue === (hoverExpectedOutcome), 'Did not get expected hover data.'); + assert(hoverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + + }).timeout(35000); - }).timeout(25000); + after(() => { + utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + console.log("Removed new config folder:"); + }); + }); diff --git a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.env b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.env new file mode 100644 index 00000000..e69de29b diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index a2a0135b..8a5b26ea 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -5,6 +5,7 @@ import { MAVEN_PROJECT, STOP_DASHBOARD_MAC_ACTION } from '../definitions/consta 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) ); @@ -192,4 +193,36 @@ export async function clearCommandPalette() { expect(buttons.length).equals(2); await dialog.pushButton('Clear'); } - \ No newline at end of file + +/** + * Remove newly created Project folder with content + */ +export async function removeConfigDir(projectPath: string): Promise { + try { + await fs.accessSync(projectPath); + const projectContent = await fs.readdirSync(projectPath); + await Promise.all( + projectContent.map(async (projectFiles) => { + const projectContentPath = path.join(projectPath, projectFiles); + const stats = await fs.lstatSync(projectContentPath); + if (stats.isDirectory()) { + await removeConfigDir(projectContentPath); + } else { + await fs.unlinkSync(projectContentPath); + } + }) + ); + await fs.rmdirSync(projectPath); + } catch (error) { + console.error(`Error removing new project: ${error}`); + } +} + +/** + * Copy config directory and create new config + */ +export async function copyConfig(existingConfigPath: string, copyConfigPath: string): Promise { + fse.copy(existingConfigPath, copyConfigPath) + .then(() => console.log("New config folder created :" + copyConfigPath)) + .catch(err => console.log("Error creating config folder")); +} \ No newline at end of file From 008cb5c1db3e486e7dc802f2d8732a325f63130b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 19:50:26 +0530 Subject: [PATCH 16/44] updated variable and code format --- src/test/GradleSingleModLCLSTest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index f4c9a038..11244ff6 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -117,10 +117,10 @@ Source: ol-24.0.0.11.xsd`; await utils.delay(5000); const hverContent = editor.findElement(By.className('hover-contents')); - const hoverValue = await hverContent.getText(); - console.log("Hover text:" + hoverValue); + const hverValue = await hverContent.getText(); + console.log("Hover text:" + hverValue); - assert(hoverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); }).timeout(35000); From c452b386e15781cf9ec673fd12ddd8cca37ef7fc Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 20:33:27 +0530 Subject: [PATCH 17/44] Added test case for hover support for server.xml Liberty Server Feature --- src/test/GradleSingleModLCLSTest.ts | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 11244ff6..bbe6e69e 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -124,6 +124,36 @@ Source: ol-24.0.0.11.xsd`; }).timeout(35000); + it('Should show hover support for server.xml Liberty Server Feature', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification. +Enabled by: microProfile-5.0, microProfile-6.0, microProfile-6.1 +Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; + const testHverTarget = 'mpHealth-4.0'; + + await editor.typeTextAt(15, 35, '\n'); + await utils.delay(1000); + await editor.typeTextAt(16, 9, testHverTarget); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); + await utils.delay(3000); + focusTargtElemnt.click(); + await editor.click(); + + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); + await utils.delay(5000); + + const hverContent = editor.findElement(By.className('hover-contents')); + const hverValue = await hverContent.getText(); + console.log("Hover text:" + hverValue); + + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + + }).timeout(33000); + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 368ac77a273eeefd926ee217389302e6b78d24ad Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 21:04:34 +0530 Subject: [PATCH 18/44] test case added - type ahead support in server.xml Liberty Server Feature --- src/test/GradleSingleModLCLSTest.ts | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index bbe6e69e..db1a1c5d 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -154,6 +154,49 @@ Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; }).timeout(33000); + it('Should show type ahead support in server.xml Liberty Server Feature', async () => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + const serverxmlContent = await editor.getText(); + const featureTag = " { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 767952add5c48bc311941da6e2bcec55b1b00c36 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 21:53:37 +0530 Subject: [PATCH 19/44] updated test case --- src/test/GradleSingleModLCLSTest.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index db1a1c5d..d44c391d 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -63,7 +63,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly.'); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for appsWriteJson.'); await editor.clearText(); await editor.setText(actualSeverXMLContent); console.log("Content restored"); @@ -93,7 +93,7 @@ describe('LCLS tests for Gradle Project', function () { const hverContent = editor.findElement(By.className('hover-contents')); const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data for server.env - LOGLEVEL'); await editor.clearText(); }).timeout(35000); @@ -120,7 +120,7 @@ Source: ol-24.0.0.11.xsd`; const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data for Liberty Server Attribute -httpEndpoint'); }).timeout(35000); @@ -150,7 +150,7 @@ Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data.'); + assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature - mpHealth.'); }).timeout(33000); @@ -189,8 +189,8 @@ Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; const updatedServerxmlContent = await editor.getText(); await utils.delay(3000); - console.log("Content after Quick fix : ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(addFeature), 'quick fix not applied correctly.'); + console.log("Content after type ahead support : ", updatedServerxmlContent); + assert(updatedServerxmlContent.includes(addFeature), 'Type ahead support is not worked as expected in server.xml Liberty Server Feature - el-3.0.'); editor.clearText(); editor.setText(serverxmlContent); console.log("Content restored"); From 358f41d440b74e3a245a338851060fbaa4c4f5f3 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 6 Dec 2024 13:42:01 +0530 Subject: [PATCH 20/44] Updated test case --- src/test/GradleSingleModLCLSTest.ts | 65 +++++++++-------------------- 1 file changed, 20 insertions(+), 45 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index d44c391d..ed8be9a8 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -18,7 +18,7 @@ describe('LCLS tests for Gradle Project', function () { let editor: TextEditor; before(() => { - utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'),path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); it('Should apply quick fix for invalid value in server.xml', async () => { @@ -33,14 +33,14 @@ describe('LCLS tests for Gradle Project', function () { await editor.typeTextAt(17, 5, stanzaSnipet); await utils.delay(2000); const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - await utils.delay(3000); + await utils.delay(7000); const actions = VSBrowser.instance.driver.actions(); await actions.move({ origin: flagedString }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverTxt= await editor.findElement(By.className('hover-row status-bar')); + const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); @@ -63,50 +63,23 @@ describe('LCLS tests for Gradle Project', function () { const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for appsWriteJson.'); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); await editor.clearText(); await editor.setText(actualSeverXMLContent); + await utils.delay(3000); console.log("Content restored"); }).timeout(38000); - it('Should show hover support for server.env', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - editor = await new EditorView().openEditor('server.env') as TextEditor; - - const testHverTarget = "WLP_LOGGING_CONSOLE_LOGLEVEL=AUDIT"; - const hverExpectdOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; - await editor.typeTextAt(1, 1, testHverTarget); - await utils.delay(2000); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'LOGLEVEL')]")); - await utils.delay(3000); - focusTargtElemnt.click(); - await editor.click(); - - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); - await utils.delay(5000); - - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data for server.env - LOGLEVEL'); - await editor.clearText(); - - }).timeout(35000); - it('Should show hover support for server.xml Liberty Server Attribute', async () => { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const hverExpectdOutcome = `Configuration properties for an HTTP endpoint. -Source: ol-24.0.0.11.xsd`; + const actualSeverXMLContent = await editor.getText(); + const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; - console.log(hverExpectdOutcome); + console.log(hovrExpctdOutcome); const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); await utils.delay(3000); focusTargtElemnt.click(); @@ -117,10 +90,14 @@ Source: ol-24.0.0.11.xsd`; await utils.delay(5000); const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoveredText = await hverContent.getText(); + console.log("Hover text:" + hoveredText); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data for Liberty Server Attribute -httpEndpoint'); + assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); + await editor.clearText(); + await editor.setText(actualSeverXMLContent); + await utils.delay(3000); + console.log("Content restored"); }).timeout(35000); @@ -129,9 +106,7 @@ Source: ol-24.0.0.11.xsd`; await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification. -Enabled by: microProfile-5.0, microProfile-6.0, microProfile-6.1 -Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; + const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; const testHverTarget = 'mpHealth-4.0'; await editor.typeTextAt(15, 35, '\n'); @@ -150,7 +125,7 @@ Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); - assert(hverValue === (hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature - mpHealth.'); + assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); }).timeout(33000); @@ -200,6 +175,6 @@ Enables: cdi-3.0, jndi-1.0, json-1.0, jsonp-2.0, mpConfig-3.0`; after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); - }); - -}); + }); + +}); \ No newline at end of file From a5e0e5f56c4246474431ae9158d411374baae117 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 6 Dec 2024 15:18:48 +0530 Subject: [PATCH 21/44] Test case added for type ahead support config stanza --- src/test/GradleSingleModLCLSTest.ts | 71 +++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index ed8be9a8..640c852c 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -16,18 +16,31 @@ const assert = require('assert'); describe('LCLS tests for Gradle Project', function () { let editor: TextEditor; + let actualSeverXMLContent: string; before(() => { utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); + it('Should coppy content of server.xml', async () => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + actualSeverXMLContent = await editor.getText(); + + assert(actualSeverXMLContent.length!==0, 'Content of server.xml is not in coppied.'); + console.log('Sever.xml content:',actualSeverXMLContent); + + }).timeout(10000); + it('Should apply quick fix for invalid value in server.xml', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const actualSeverXMLContent = await editor.getText(); const stanzaSnipet = ""; const expectedHoverData = ""; await editor.typeTextAt(17, 5, stanzaSnipet); @@ -64,9 +77,9 @@ describe('LCLS tests for Gradle Project', function () { await utils.delay(3000); console.log("Content after Quick fix : ", updatedSeverXMLContent); assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); - await editor.clearText(); - await editor.setText(actualSeverXMLContent); - await utils.delay(3000); + + editor.clearText(); + editor.setText(actualSeverXMLContent); console.log("Content restored"); }).timeout(38000); @@ -76,7 +89,6 @@ describe('LCLS tests for Gradle Project', function () { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const actualSeverXMLContent = await editor.getText(); const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; console.log(hovrExpctdOutcome); @@ -94,9 +106,9 @@ describe('LCLS tests for Gradle Project', function () { console.log("Hover text:" + hoveredText); assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); - await editor.clearText(); - await editor.setText(actualSeverXMLContent); - await utils.delay(3000); + + editor.clearText(); + editor.setText(actualSeverXMLContent); console.log("Content restored"); }).timeout(35000); @@ -127,6 +139,10 @@ describe('LCLS tests for Gradle Project', function () { assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + }).timeout(33000); it('Should show type ahead support in server.xml Liberty Server Feature', async () => { @@ -135,7 +151,6 @@ describe('LCLS tests for Gradle Project', function () { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const serverxmlContent = await editor.getText(); const featureTag = " { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + const stanzaSnipet = "log"; + + const insertedConfig = ""; + await editor.typeTextAt(17, 5, stanzaSnipet); + await utils.delay(5000); + //open the assistant + let asist = await editor.toggleContentAssist(true); + // toggle can return void, so we need to make sure the object is present + if (asist) { + // to select an item use + await asist.select('logging') + } + // close the assistant + await editor.toggleContentAssist(false); + + // close the assistant + await editor.toggleContentAssist(false); + + const updatedServerxmlContent = await editor.getText(); + await utils.delay(3000); + console.log("Updated content in Sever.xml : ", updatedServerxmlContent); + assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(25000); + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 2e03f597d3ab181a38b9e81d072a75fb119b9ab7 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 6 Dec 2024 16:07:59 +0530 Subject: [PATCH 22/44] Test case added for server.env --- src/test/GradleSingleModLCLSTest.ts | 431 ++++++++++++++++++---------- 1 file changed, 273 insertions(+), 158 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 640c852c..7931f840 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -35,193 +35,308 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(10000); - it('Should apply quick fix for invalid value in server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = ""; - const expectedHoverData = ""; - await editor.typeTextAt(17, 5, stanzaSnipet); - await utils.delay(2000); - const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - await utils.delay(7000); - - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flagedString }).perform(); - await utils.delay(3000); - - const driver = VSBrowser.instance.driver; - const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); - await utils.delay(2000); - - const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await qckFixPopupLink.click(); - - const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverTaskBar.findElement(By.className('actionList')); - await utils.delay(2000); - - const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); - // Setting pointer block element display value as none to choose option from Quickfix menu - if (pointerBlockedElement) { - await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); - } else { - console.log('pointerBlockElementt not found!'); - } - const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - await qckfixOption.click(); - - const updatedSeverXMLContent = await editor.getText(); - await utils.delay(3000); - console.log("Content after Quick fix : ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); + // it('Should apply quick fix for invalid value in server.xml', async () => { + // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + // section.expand(); + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + // editor = await new EditorView().openEditor('server.xml') as TextEditor; + // const stanzaSnipet = ""; + // const expectedHoverData = ""; + // await editor.typeTextAt(17, 5, stanzaSnipet); + // await utils.delay(2000); + // const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + // await utils.delay(7000); + + // const actions = VSBrowser.instance.driver.actions(); + // await actions.move({ origin: flagedString }).perform(); + // await utils.delay(3000); + + // const driver = VSBrowser.instance.driver; + // const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + // await utils.delay(2000); + + // const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + // await qckFixPopupLink.click(); + + // const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + // await hoverTaskBar.findElement(By.className('actionList')); + // await utils.delay(2000); + + // const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); + // // Setting pointer block element display value as none to choose option from Quickfix menu + // if (pointerBlockedElement) { + // await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); + // } else { + // console.log('pointerBlockElementt not found!'); + // } + // const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + // await qckfixOption.click(); + + // const updatedSeverXMLContent = await editor.getText(); + // await utils.delay(3000); + // console.log("Content after Quick fix : ", updatedSeverXMLContent); + // assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); - - }).timeout(38000); - - it('Should show hover support for server.xml Liberty Server Attribute', async () => { - - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; - - console.log(hovrExpctdOutcome); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); - await utils.delay(3000); - focusTargtElemnt.click(); - await editor.click(); - - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); - await utils.delay(5000); - - const hverContent = editor.findElement(By.className('hover-contents')); - const hoveredText = await hverContent.getText(); - console.log("Hover text:" + hoveredText); + // editor.clearText(); + // editor.setText(actualSeverXMLContent); + // console.log("Content restored"); - assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); + // }).timeout(38000); - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + // it('Should show hover support for server.xml Liberty Server Attribute', async () => { - }).timeout(35000); - - it('Should show hover support for server.xml Liberty Server Feature', async () => { - - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; - const testHverTarget = 'mpHealth-4.0'; + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + // editor = await new EditorView().openEditor('server.xml') as TextEditor; - await editor.typeTextAt(15, 35, '\n'); - await utils.delay(1000); - await editor.typeTextAt(16, 9, testHverTarget); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); - await utils.delay(3000); - focusTargtElemnt.click(); - await editor.click(); - - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); - await utils.delay(5000); + // const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + // console.log(hovrExpctdOutcome); + // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + // await utils.delay(3000); + // focusTargtElemnt.click(); + // await editor.click(); - assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); + // const actns = VSBrowser.instance.driver.actions(); + // await actns.move({ origin: focusTargtElemnt }).perform(); + // await utils.delay(5000); - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); - - }).timeout(33000); - - it('Should show type ahead support in server.xml Liberty Server Feature', async () => { + // const hverContent = editor.findElement(By.className('hover-contents')); + // const hoveredText = await hverContent.getText(); + // console.log("Hover text:" + hoveredText); + + // assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); + + // editor.clearText(); + // editor.setText(actualSeverXMLContent); + // console.log("Content restored"); + + // }).timeout(35000); + + // it('Should show hover support for server.xml Liberty Server Feature', async () => { + + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + // editor = await new EditorView().openEditor('server.xml') as TextEditor; + + // const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; + // const testHverTarget = 'mpHealth-4.0'; + + // await editor.typeTextAt(15, 35, '\n'); + // await utils.delay(1000); + // await editor.typeTextAt(16, 9, testHverTarget); + // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); + // await utils.delay(3000); + // focusTargtElemnt.click(); + // await editor.click(); + + // const actns = VSBrowser.instance.driver.actions(); + // await actns.move({ origin: focusTargtElemnt }).perform(); + // await utils.delay(5000); + + // const hverContent = editor.findElement(By.className('hover-contents')); + // const hverValue = await hverContent.getText(); + // console.log("Hover text:" + hverValue); + + // assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); + + // editor.clearText(); + // editor.setText(actualSeverXMLContent); + // console.log("Content restored"); + + // }).timeout(33000); + + // it('Should show type ahead support in server.xml Liberty Server Feature', async () => { + // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + // section.expand(); + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + // editor = await new EditorView().openEditor('server.xml') as TextEditor; + // const featureTag = " { + // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + // section.expand(); + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + // editor = await new EditorView().openEditor('server.xml') as TextEditor; + // const stanzaSnipet = "log"; + + // const insertedConfig = ""; + // await editor.typeTextAt(17, 5, stanzaSnipet); + // await utils.delay(5000); + // //open the assistant + // let asist = await editor.toggleContentAssist(true); + // // toggle can return void, so we need to make sure the object is present + // if (asist) { + // // to select an item use + // await asist.select('logging') + // } + // // close the assistant + // await editor.toggleContentAssist(false); + + // // close the assistant + // await editor.toggleContentAssist(false); + + // const updatedServerxmlContent = await editor.getText(); + // await utils.delay(3000); + // console.log("Updated content in Sever.xml : ", updatedServerxmlContent); + // assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); + + // editor.clearText(); + // editor.setText(actualSeverXMLContent); + // console.log("Content restored"); + + // }).timeout(25000); + + // it('Should show hover support for server.env', async () => { + // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + // section.expand(); + + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + // editor = await new EditorView().openEditor('server.env') as TextEditor; + + // const testHverTarget = "WLP_LOGGING_CONSOLE_LOGLEVEL=AUDIT"; + // const hverExpectdOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; + // await editor.typeTextAt(1, 1, testHverTarget); + // await utils.delay(2000); + // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'LOGLEVEL')]")); + // await utils.delay(3000); + // focusTargtElemnt.click(); + // await editor.click(); + + // const actns = VSBrowser.instance.driver.actions(); + // await actns.move({ origin: focusTargtElemnt }).perform(); + // await utils.delay(5000); + + // const hverContent = editor.findElement(By.className('hover-contents')); + // const hverValue = await hverContent.getText(); + // console.log("Hover text:" + hverValue); + // assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data for server.env.'); + // await editor.clearText(); + + // }).timeout(35000); + + it('should show liberty-ls diagnostic support in server.env', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const featureTag = " { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "log"; + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); + await utils.delay(3000); + focusTargetLement.click(); + await editor.click(); - const insertedConfig = ""; - await editor.typeTextAt(17, 5, stanzaSnipet); + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetLement }).perform(); await utils.delay(5000); - //open the assistant - let asist = await editor.toggleContentAssist(true); - // toggle can return void, so we need to make sure the object is present - if (asist) { - // to select an item use - await asist.select('logging') - } - // close the assistant - await editor.toggleContentAssist(false); - // close the assistant - await editor.toggleContentAssist(false); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); - const updatedServerxmlContent = await editor.getText(); - await utils.delay(3000); - console.log("Updated content in Sever.xml : ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); + assert(hoverValue.includes(expectedHverData), 'Diagnostic is not showing as expected in server.env'); + await editor.clearText(); - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + }).timeout(35000); - }).timeout(25000); + // it('Should show type ahead support in server.env Liberty Server Configuration Stanza', async () => { + // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + // section.expand(); + // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + + // editor = await new EditorView().openEditor('server.env') as TextEditor; + + // const envStanzaSnipet = "WLP_LOGGING_CON";; + // const insertConfig = "=SIM"; + // const envCfgNameChoserSnipet = "WLP_LOGGING_CONSOLE_FORMAT"; + // const expectedServrEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=SIMPLE'; + + // await editor.typeTextAt(1, 1, envStanzaSnipet); + // await utils.delay(5000); + // //open the assistant + // let asist = await editor.toggleContentAssist(true); + // // toggle can return void, so we need to make sure the object is present + // if (asist) { + // // to select an item use + // await asist.select(envCfgNameChoserSnipet); + // } + // // close the assistant + // await editor.toggleContentAssist(false); + + // await editor.typeTextAt(1, 27, insertConfig); + // await utils.delay(2500); + // asist = await editor.toggleContentAssist(true); + // // toggle can return void, so we need to make sure the object is present + // if (asist) { + // // to select an item use + // await asist.select('SIMPLE'); + // } + // // close the assistant + // await editor.toggleContentAssist(false); + + // const updatedSeverEnvContent = await editor.getText(); + // await utils.delay(3000); + // console.log("Content after Quick fix : ", updatedSeverEnvContent); + // assert(updatedSeverEnvContent.includes(expectedServrEnvString), 'Snippet is not as expected.'); + // await editor.clearText(); + + // }).timeout(25000); after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From b1d39e1ba7312c12911ccd6812d4388a1209fdc3 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 11:57:22 +0530 Subject: [PATCH 23/44] Test cases added for server.env --- src/test/GradleSingleModLCLSTest.ts | 520 ++++++++++++++-------------- 1 file changed, 254 insertions(+), 266 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 7931f840..c29504f3 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -30,254 +30,245 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; actualSeverXMLContent = await editor.getText(); - assert(actualSeverXMLContent.length!==0, 'Content of server.xml is not in coppied.'); - console.log('Sever.xml content:',actualSeverXMLContent); + assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in coppied.'); + console.log('Sever.xml content:', actualSeverXMLContent); }).timeout(10000); - // it('Should apply quick fix for invalid value in server.xml', async () => { - // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - // section.expand(); - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + it('Should apply quick fix for invalid value in server.xml', async () => { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + const stanzaSnipet = ""; + const expectedHoverData = ""; + await editor.typeTextAt(17, 5, stanzaSnipet); + await utils.delay(2000); + const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + await utils.delay(7000); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: flagedString }).perform(); + await utils.delay(3000); + + const driver = VSBrowser.instance.driver; + const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + await utils.delay(2000); + + const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await qckFixPopupLink.click(); + + const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + await hoverTaskBar.findElement(By.className('actionList')); + await utils.delay(2000); + + const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); + // Setting pointer block element display value as none to choose option from Quickfix menu + if (pointerBlockedElement) { + await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); + } else { + console.log('pointerBlockElementt not found!'); + } + const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + await qckfixOption.click(); + + const updatedSeverXMLContent = await editor.getText(); + await utils.delay(3000); + console.log("Content after Quick fix : ", updatedSeverXMLContent); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(38000); + + it('Should show hover support for server.xml Liberty Server Attribute', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; + + console.log(hovrExpctdOutcome); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + await utils.delay(3000); + focusTargtElemnt.click(); + await editor.click(); + + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); + await utils.delay(5000); + + const hverContent = editor.findElement(By.className('hover-contents')); + const hoveredText = await hverContent.getText(); + console.log("Hover text:" + hoveredText); + + assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(35000); + + it('Should show hover support for server.xml Liberty Server Feature', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; + const testHverTarget = 'mpHealth-4.0'; + + await editor.typeTextAt(15, 35, '\n'); + await utils.delay(1000); + await editor.typeTextAt(16, 9, testHverTarget); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); + await utils.delay(3000); + focusTargtElemnt.click(); + await editor.click(); + + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); + await utils.delay(5000); + + const hverContent = editor.findElement(By.className('hover-contents')); + const hverValue = await hverContent.getText(); + console.log("Hover text:" + hverValue); - // editor = await new EditorView().openEditor('server.xml') as TextEditor; - // const stanzaSnipet = ""; - // const expectedHoverData = ""; - // await editor.typeTextAt(17, 5, stanzaSnipet); - // await utils.delay(2000); - // const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - // await utils.delay(7000); + assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); - // const actions = VSBrowser.instance.driver.actions(); - // await actions.move({ origin: flagedString }).perform(); - // await utils.delay(3000); + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); - // const driver = VSBrowser.instance.driver; - // const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); - // await utils.delay(2000); + }).timeout(33000); - // const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - // await qckFixPopupLink.click(); - - // const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - // await hoverTaskBar.findElement(By.className('actionList')); - // await utils.delay(2000); - - // const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); - // // Setting pointer block element display value as none to choose option from Quickfix menu - // if (pointerBlockedElement) { - // await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); - // } else { - // console.log('pointerBlockElementt not found!'); - // } - // const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - // await qckfixOption.click(); - - // const updatedSeverXMLContent = await editor.getText(); - // await utils.delay(3000); - // console.log("Content after Quick fix : ", updatedSeverXMLContent); - // assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); - - // editor.clearText(); - // editor.setText(actualSeverXMLContent); - // console.log("Content restored"); - - // }).timeout(38000); - - // it('Should show hover support for server.xml Liberty Server Attribute', async () => { - - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - // editor = await new EditorView().openEditor('server.xml') as TextEditor; - - // const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; - - // console.log(hovrExpctdOutcome); - // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); - // await utils.delay(3000); - // focusTargtElemnt.click(); - // await editor.click(); - - // const actns = VSBrowser.instance.driver.actions(); - // await actns.move({ origin: focusTargtElemnt }).perform(); - // await utils.delay(5000); - - // const hverContent = editor.findElement(By.className('hover-contents')); - // const hoveredText = await hverContent.getText(); - // console.log("Hover text:" + hoveredText); - - // assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); - - // editor.clearText(); - // editor.setText(actualSeverXMLContent); - // console.log("Content restored"); - - // }).timeout(35000); - - // it('Should show hover support for server.xml Liberty Server Feature', async () => { - - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); - // editor = await new EditorView().openEditor('server.xml') as TextEditor; - - // const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; - // const testHverTarget = 'mpHealth-4.0'; - - // await editor.typeTextAt(15, 35, '\n'); - // await utils.delay(1000); - // await editor.typeTextAt(16, 9, testHverTarget); - // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); - // await utils.delay(3000); - // focusTargtElemnt.click(); - // await editor.click(); - - // const actns = VSBrowser.instance.driver.actions(); - // await actns.move({ origin: focusTargtElemnt }).perform(); - // await utils.delay(5000); - - // const hverContent = editor.findElement(By.className('hover-contents')); - // const hverValue = await hverContent.getText(); - // console.log("Hover text:" + hverValue); - - // assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); - - // editor.clearText(); - // editor.setText(actualSeverXMLContent); - // console.log("Content restored"); - - // }).timeout(33000); - - // it('Should show type ahead support in server.xml Liberty Server Feature', async () => { - // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - // section.expand(); - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - - // editor = await new EditorView().openEditor('server.xml') as TextEditor; - // const featureTag = " { - // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - // section.expand(); - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - - // editor = await new EditorView().openEditor('server.xml') as TextEditor; - // const stanzaSnipet = "log"; - - // const insertedConfig = ""; - // await editor.typeTextAt(17, 5, stanzaSnipet); - // await utils.delay(5000); - // //open the assistant - // let asist = await editor.toggleContentAssist(true); - // // toggle can return void, so we need to make sure the object is present - // if (asist) { - // // to select an item use - // await asist.select('logging') - // } - // // close the assistant - // await editor.toggleContentAssist(false); - - // // close the assistant - // await editor.toggleContentAssist(false); - - // const updatedServerxmlContent = await editor.getText(); - // await utils.delay(3000); - // console.log("Updated content in Sever.xml : ", updatedServerxmlContent); - // assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); - - // editor.clearText(); - // editor.setText(actualSeverXMLContent); - // console.log("Content restored"); - - // }).timeout(25000); - - // it('Should show hover support for server.env', async () => { - // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - // section.expand(); - - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - // editor = await new EditorView().openEditor('server.env') as TextEditor; - - // const testHverTarget = "WLP_LOGGING_CONSOLE_LOGLEVEL=AUDIT"; - // const hverExpectdOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; - // await editor.typeTextAt(1, 1, testHverTarget); - // await utils.delay(2000); - // const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'LOGLEVEL')]")); - // await utils.delay(3000); - // focusTargtElemnt.click(); - // await editor.click(); - - // const actns = VSBrowser.instance.driver.actions(); - // await actns.move({ origin: focusTargtElemnt }).perform(); - // await utils.delay(5000); - - // const hverContent = editor.findElement(By.className('hover-contents')); - // const hverValue = await hverContent.getText(); - // console.log("Hover text:" + hverValue); - // assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data for server.env.'); - // await editor.clearText(); - - // }).timeout(35000); - - it('should show liberty-ls diagnostic support in server.env', async () => { + it('Should show type ahead support in server.xml Liberty Server Feature', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + const featureTag = " { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + + editor = await new EditorView().openEditor('server.xml') as TextEditor; + const stanzaSnipet = "log"; + const insertedConfig = ""; + await editor.typeTextAt(17, 5, stanzaSnipet); + await utils.delay(5000); + //open the assistant + let asist = await editor.toggleContentAssist(true); + // toggle can return void, so we need to make sure the object is present + if (asist) { + // to select an item use + await asist.select('logging') + } + // close the assistant + await editor.toggleContentAssist(false); + + // close the assistant + await editor.toggleContentAssist(false); + + const updatedServerxmlContent = await editor.getText(); + await utils.delay(3000); + console.log("Updated content in Sever.xml : ", updatedServerxmlContent); + assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(35000); + + it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); editor = await new EditorView().openEditor('server.env') as TextEditor; - const envStanzaSnipet = "WLP_LOGGING_CON";; - const insertConfig = "=wrong"; - const envCfgNameChoserSnipet = "WLP_LOGGING_CONSOLE_FORMAT"; - const expectedHverData ='The value `wrong` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = "=TBA"; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; - await editor.typeTextAt(1, 1, envStanzaSnipet); + await editor.typeTextAt(1, 1, configNameSnippet); await utils.delay(5000); //open the assistant let asist = await editor.toggleContentAssist(true); // toggle can return void, so we need to make sure the object is present if (asist) { // to select an item use - await asist.select(envCfgNameChoserSnipet); + await asist.select(envCfgNameChooserSnippet); } // close the assistant await editor.toggleContentAssist(false); await editor.typeTextAt(1, 27, insertConfig); + await utils.delay(2500); + asist = await editor.toggleContentAssist(true); + if (asist) { + await asist.select('TBASIC'); + } + await editor.toggleContentAssist(false); + + const updatedSeverEnvContent = await editor.getText(); await utils.delay(3000); - const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); + assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); + await editor.clearText(); + + }).timeout(35000); + + it('Should show hover support for server.env Liberty Server config setting', async () => { + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const ExpectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; + await editor.clearText(); + const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; + await editor.typeTextAt(1, 1, testHoverTarget); + await utils.delay(5000); + console.log(ExpectedHoverOutcome); + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); await utils.delay(3000); focusTargetLement.click(); await editor.click(); @@ -290,53 +281,50 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text:" + hoverValue); - assert(hoverValue.includes(expectedHverData), 'Diagnostic is not showing as expected in server.env'); + assert(hoverValue === (ExpectedHoverOutcome), 'Did not get expected hover data for server.env'); await editor.clearText(); }).timeout(35000); - // it('Should show type ahead support in server.env Liberty Server Configuration Stanza', async () => { - // const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - // section.expand(); - // await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - - // editor = await new EditorView().openEditor('server.env') as TextEditor; - - // const envStanzaSnipet = "WLP_LOGGING_CON";; - // const insertConfig = "=SIM"; - // const envCfgNameChoserSnipet = "WLP_LOGGING_CONSOLE_FORMAT"; - // const expectedServrEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=SIMPLE'; - - // await editor.typeTextAt(1, 1, envStanzaSnipet); - // await utils.delay(5000); - // //open the assistant - // let asist = await editor.toggleContentAssist(true); - // // toggle can return void, so we need to make sure the object is present - // if (asist) { - // // to select an item use - // await asist.select(envCfgNameChoserSnipet); - // } - // // close the assistant - // await editor.toggleContentAssist(false); - - // await editor.typeTextAt(1, 27, insertConfig); - // await utils.delay(2500); - // asist = await editor.toggleContentAssist(true); - // // toggle can return void, so we need to make sure the object is present - // if (asist) { - // // to select an item use - // await asist.select('SIMPLE'); - // } - // // close the assistant - // await editor.toggleContentAssist(false); - - // const updatedSeverEnvContent = await editor.getText(); - // await utils.delay(3000); - // console.log("Content after Quick fix : ", updatedSeverEnvContent); - // assert(updatedSeverEnvContent.includes(expectedServrEnvString), 'Snippet is not as expected.'); - // await editor.clearText(); - - // }).timeout(25000); + it('Should show diagnostic support in server.env ', async () => { + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = '=sample_value_is_updating_as_nodata'; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; + + await editor.typeTextAt(1, 1, configNameSnippet); + await utils.delay(5000); + //open the assistant + let asist = await editor.toggleContentAssist(true); + // toggle can return void, so we need to make sure the object is present + if (asist) { + // to select an item use + await asist.select(envCfgNameChooserSnippet); + } + // close the assistant + await editor.toggleContentAssist(false); + + await editor.typeTextAt(1, 27, insertConfig); + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); + await utils.delay(3000); + focusTargetLement.click(); + await editor.click(); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetLement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); + + assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); + await editor.clearText(); + + }).timeout(35000); after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From ebcad9dc765c045492a9368644991d68d459d946 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 17:29:45 +0530 Subject: [PATCH 24/44] Test case added for server.env LCLS --- src/test/GradleSingleModLCLSTest.ts | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index c29504f3..ea312de6 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -35,6 +35,36 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(10000); + it('Should show diagnostic for server.xml invalid value', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hverExpectdOutcome = `'wrong' is not a valid value of union type 'booleanType'.`; + const testHverTarget = ''; + + await editor.typeTextAt(17, 5, testHverTarget); + const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); + await utils.delay(3000); + focusTargtElemnt.click(); + await editor.click(); + + const actns = VSBrowser.instance.driver.actions(); + await actns.move({ origin: focusTargtElemnt }).perform(); + await utils.delay(5000); + + const hverContent = editor.findElement(By.className('hover-contents')); + const hverValue = await hverContent.getText(); + console.log("Hover text:" + hverValue); + + assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected diagnostic in server.xml'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(35000); + it('Should apply quick fix for invalid value in server.xml', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); @@ -115,7 +145,7 @@ describe('LCLS tests for Gradle Project', function () { it('Should show hover support for server.xml Liberty Server Feature', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; @@ -195,6 +225,7 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnipet = "log"; + const insertedConfig = ""; await editor.typeTextAt(17, 5, stanzaSnipet); await utils.delay(5000); From 084360360f070a878916b0803fe9441a1e377819 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 20:27:10 +0530 Subject: [PATCH 25/44] chanaged server.xml path --- src/test/GradleSingleModLCLSTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index ea312de6..4d9ec685 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -37,7 +37,7 @@ describe('LCLS tests for Gradle Project', function () { it('Should show diagnostic for server.xml invalid value', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; const hverExpectdOutcome = `'wrong' is not a valid value of union type 'booleanType'.`; @@ -145,7 +145,7 @@ describe('LCLS tests for Gradle Project', function () { it('Should show hover support for server.xml Liberty Server Feature', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; From 33c6213901eef0731ce1319633522c22d26f3919 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 17 Jan 2025 16:31:42 +0530 Subject: [PATCH 26/44] typo error and copyright hear year updated --- src/test/GradleSingleModLCLSTest.ts | 6 +++--- src/test/utils/testUtils.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 4d9ec685..31081cb5 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 IBM Corporation. + * Copyright (c) 2025 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 @@ -22,7 +22,7 @@ describe('LCLS tests for Gradle Project', function () { utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); - it('Should coppy content of server.xml', async () => { + it('Should copy content of server.xml', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); @@ -30,7 +30,7 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; actualSeverXMLContent = await editor.getText(); - assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in coppied.'); + assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in copied.'); console.log('Sever.xml content:', actualSeverXMLContent); }).timeout(10000); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 8a5b26ea..ddbd7a34 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -199,20 +199,20 @@ export async function clearCommandPalette() { */ export async function removeConfigDir(projectPath: string): Promise { try { - await fs.accessSync(projectPath); - const projectContent = await fs.readdirSync(projectPath); + fs.accessSync(projectPath); + const projectContent = fs.readdirSync(projectPath); await Promise.all( projectContent.map(async (projectFiles) => { const projectContentPath = path.join(projectPath, projectFiles); - const stats = await fs.lstatSync(projectContentPath); + const stats = fs.lstatSync(projectContentPath); if (stats.isDirectory()) { await removeConfigDir(projectContentPath); } else { - await fs.unlinkSync(projectContentPath); + fs.unlinkSync(projectContentPath); } }) ); - await fs.rmdirSync(projectPath); + fs.rmdirSync(projectPath); } catch (error) { console.error(`Error removing new project: ${error}`); } From dad152d0e37891776df881689e0e2bf0a7fe74f9 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 10:53:28 +0530 Subject: [PATCH 27/44] Updated testUtils --- src/test/utils/testUtils.ts | 42 +++++-------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index ddbd7a34..0e5f6a33 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -1,11 +1,10 @@ import path = require('path'); import { Workbench, InputBox, DefaultTreeItem, ModalDialog } from 'vscode-extension-tester'; import * as fs from 'fs'; -import { MAVEN_PROJECT, STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; +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) ); @@ -169,13 +168,13 @@ export function getMvnProjectPath(): string { /* Stop Server Liberty dashboard post Attach Debugger*/ /* As the Window view changes using command to stop server instead of devmode action */ -export async function stopLibertyserver() { - console.log("Stop Server action for MAVEN_PROJECT : " + MAVEN_PROJECT); +export async function stopLibertyserver(projectName: string) { + console.log("Stop Server action for Project : " + projectName); const workbench = new Workbench(); await workbench.executeCommand(STOP_DASHBOARD_MAC_ACTION); const input = InputBox.create(); (await input).clear(); - (await input).setText(MAVEN_PROJECT); + (await input).setText(projectName); (await input).confirm(); (await input).click(); await delay(10000); @@ -194,35 +193,4 @@ export async function clearCommandPalette() { await dialog.pushButton('Clear'); } -/** - * Remove newly created Project folder with content - */ -export async function removeConfigDir(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 removeConfigDir(projectContentPath); - } else { - fs.unlinkSync(projectContentPath); - } - }) - ); - fs.rmdirSync(projectPath); - } catch (error) { - console.error(`Error removing new project: ${error}`); - } -} - -/** - * Copy config directory and create new config - */ -export async function copyConfig(existingConfigPath: string, copyConfigPath: string): Promise { - fse.copy(existingConfigPath, copyConfigPath) - .then(() => console.log("New config folder created :" + copyConfigPath)) - .catch(err => console.log("Error creating config folder")); -} \ No newline at end of file + \ No newline at end of file From fa5caebc1862e6268c05176a139a945ed1e64f90 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 22:53:09 +0530 Subject: [PATCH 28/44] Updated test cases --- src/test/GradleSingleModLCLSTest.ts | 248 +++++++++++----------------- src/test/definitions/constants.ts | 6 + src/test/utils/testUtils.ts | 57 ++++++- 3 files changed, 160 insertions(+), 151 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 31081cb5..f44b92f8 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -16,81 +16,75 @@ const assert = require('assert'); describe('LCLS tests for Gradle Project', function () { let editor: TextEditor; - let actualSeverXMLContent: string; + let actualServerXMLContent: string; before(() => { - utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); it('Should copy content of server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); editor = await new EditorView().openEditor('server.xml') as TextEditor; - actualSeverXMLContent = await editor.getText(); + actualServerXMLContent = await editor.getText(); - assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in copied.'); - console.log('Sever.xml content:', actualSeverXMLContent); + assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); + console.log('Sever.xml content is:', actualServerXMLContent); - }).timeout(10000); + }).timeout(25000); it('Should show diagnostic for server.xml invalid value', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const hverExpectdOutcome = `'wrong' is not a valid value of union type 'booleanType'.`; - const testHverTarget = ''; + const expectedOutcomeValue = `'wrong' is not a valid value of union type 'booleanType'.`; + const hoverTargetValue = ''; - await editor.typeTextAt(17, 5, testHverTarget); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); + await editor.typeTextAt(17, 5, hoverTargetValue); + const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverFoundOutcome = await hoverContents.getText(); + console.log("Hover text is:" + hoverFoundOutcome); - assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected diagnostic in server.xml'); + assert(hoverFoundOutcome.includes(expectedOutcomeValue), 'Did not get expected diagnostic in server.xml'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).timeout(35000); it('Should apply quick fix for invalid value in server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = ""; - const expectedHoverData = ""; - await editor.typeTextAt(17, 5, stanzaSnipet); + const stanzaSnippet = ""; + const hoverExpectedSnippet = ""; + await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(2000); - const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const hoverTargetValue = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(7000); - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flagedString }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: hoverTargetValue }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await qckFixPopupLink.click(); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await quickFixPopupLink.click(); - const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverTaskBar.findElement(By.className('actionList')); + const hoverWindowTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + await hoverWindowTaskBar.findElement(By.className('actionList')); await utils.delay(2000); const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); @@ -98,146 +92,120 @@ describe('LCLS tests for Gradle Project', function () { if (pointerBlockedElement) { await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); } else { - console.log('pointerBlockElementt not found!'); + console.log('pointerBlockElement is not found!'); } - const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - await qckfixOption.click(); + const quickfixOptionValues = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + await quickfixOptionValues.click(); const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix : ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); + assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).timeout(38000); it('Should show hover support for server.xml Liberty Server Attribute', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`; + const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint.`; - console.log(hovrExpctdOutcome); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hoveredText = await hverContent.getText(); - console.log("Hover text:" + hoveredText); + const hoverContent = editor.findElement(By.className('hover-contents')); + const hoveredTextValue = await hoverContent.getText(); + console.log("Hover text is: " + hoveredTextValue); - assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.'); + assert(hoveredTextValue.includes(hoverExpectedOutcome), 'Did not get expected hover data Liberty Server Attribute.'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).timeout(35000); it('Should show hover support for server.xml Liberty Server Feature', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - - const hverExpectdOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; - const testHverTarget = 'mpHealth-4.0'; + const hoverOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; + const testHoverTargetTag = 'mpHealth-4.0'; await editor.typeTextAt(15, 35, '\n'); await utils.delay(1000); - await editor.typeTextAt(16, 9, testHverTarget); - const focusTargtElemnt = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); + await editor.typeTextAt(16, 9, testHoverTargetTag); + const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoveredValue = await hoverContents.getText(); + console.log("Hover text is :" + hoveredValue); - assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); + assert(hoveredValue.includes(hoverOutcome), 'Did not get expected hover data Liberty Server Feature.'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).timeout(33000); it('Should show type ahead support in server.xml Liberty Server Feature', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - editor = await new EditorView().openEditor('server.xml') as TextEditor; + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; const featureTag = " { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "log"; + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; + const stanzaSnippet = "log"; - const insertedConfig = ""; - await editor.typeTextAt(17, 5, stanzaSnipet); + const insertedConfigValue = ""; + await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(5000); //open the assistant - let asist = await editor.toggleContentAssist(true); - // toggle can return void, so we need to make sure the object is present - if (asist) { - // to select an item use - await asist.select('logging') - } - // close the assistant - await editor.toggleContentAssist(false); + await utils.callAssitantAction(editor, 'logging') // close the assistant await editor.toggleContentAssist(false); @@ -245,16 +213,16 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); await utils.delay(3000); console.log("Updated content in Sever.xml : ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(insertedConfig), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); + assert(updatedServerxmlContent.includes(insertedConfigValue), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); - }).timeout(35000); + }).timeout(25000); it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor('server.env') as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; @@ -265,21 +233,12 @@ describe('LCLS tests for Gradle Project', function () { await editor.typeTextAt(1, 1, configNameSnippet); await utils.delay(5000); //open the assistant - let asist = await editor.toggleContentAssist(true); - // toggle can return void, so we need to make sure the object is present - if (asist) { - // to select an item use - await asist.select(envCfgNameChooserSnippet); - } - // close the assistant - await editor.toggleContentAssist(false); + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); await editor.typeTextAt(1, 27, insertConfig); await utils.delay(2500); - asist = await editor.toggleContentAssist(true); - if (asist) { - await asist.select('TBASIC'); - } + await utils.callAssitantAction(editor, 'TBASIC'); + await editor.toggleContentAssist(false); const updatedSeverEnvContent = await editor.getText(); @@ -290,8 +249,8 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(35000); it('Should show hover support for server.env Liberty Server config setting', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - editor = await new EditorView().openEditor('server.env') as TextEditor; + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const ExpectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; await editor.clearText(); @@ -310,7 +269,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverContents = editor.findElement(By.className('hover-contents')); const hoverValue = await hoverContents.getText(); - console.log("Hover text:" + hoverValue); + console.log("Hover text is:" + hoverValue); assert(hoverValue === (ExpectedHoverOutcome), 'Did not get expected hover data for server.env'); await editor.clearText(); @@ -318,8 +277,8 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(35000); it('Should show diagnostic support in server.env ', async () => { - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.env')); - editor = await new EditorView().openEditor('server.env') as TextEditor; + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; const insertConfig = '=sample_value_is_updating_as_nodata'; @@ -329,28 +288,23 @@ describe('LCLS tests for Gradle Project', function () { await editor.typeTextAt(1, 1, configNameSnippet); await utils.delay(5000); //open the assistant - let asist = await editor.toggleContentAssist(true); - // toggle can return void, so we need to make sure the object is present - if (asist) { - // to select an item use - await asist.select(envCfgNameChooserSnippet); - } + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); // close the assistant await editor.toggleContentAssist(false); await editor.typeTextAt(1, 27, insertConfig); - const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); + const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); await utils.delay(3000); - focusTargetLement.click(); + focusTargetElement.click(); await editor.click(); const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: focusTargetLement }).perform(); + await actions.move({ origin: focusTargetElement }).perform(); await utils.delay(5000); const hoverContents = editor.findElement(By.className('hover-contents')); const hoverValue = await hoverContents.getText(); - console.log("Hover text:" + hoverValue); + console.log("Hover text is:" + hoverValue); assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); await editor.clearText(); @@ -358,7 +312,7 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(35000); after(() => { - utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); }); diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index d421e824..5df574ec 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -1,3 +1,4 @@ + /** * Copyright (c) 2020, 2022 IBM Corporation. * @@ -40,3 +41,8 @@ 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 CONFIG = "config"; +export const CONFIG_TWO = "config2"; +export const BOOTSTRAP_PROPERTIES = "bootstrap.properties"; +export const SERVER_XML = "server.xml"; +export const SERVER_ENV = "server.env"; diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 0e5f6a33..e058705e 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -1,10 +1,11 @@ import path = require('path'); -import { Workbench, InputBox, DefaultTreeItem, ModalDialog } from 'vscode-extension-tester'; +import { Workbench, InputBox, DefaultTreeItem, ModalDialog, SideBarView, VSBrowser, TextEditor } from 'vscode-extension-tester'; import * as fs from 'fs'; -import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; +import * as constants 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) ); @@ -171,7 +172,7 @@ export function getMvnProjectPath(): string { export async function stopLibertyserver(projectName: string) { console.log("Stop Server action for Project : " + projectName); const workbench = new Workbench(); - await workbench.executeCommand(STOP_DASHBOARD_MAC_ACTION); + await workbench.executeCommand(constants.STOP_DASHBOARD_MAC_ACTION); const input = InputBox.create(); (await input).clear(); (await input).setText(projectName); @@ -193,4 +194,52 @@ export async function clearCommandPalette() { await dialog.pushButton('Clear'); } - \ No newline at end of file +/** + * Remove specific directory + */ +export async function removeDirectoryByPath(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 removeDirectoryByPath(projectContentPath); + } else { + fs.unlinkSync(projectContentPath); + } + }) + ); + fs.rmdirSync(projectPath); + } catch (error) { + console.error(`Error removing new project: ${error}`); + } +} + +/** + * Copy a specific directory + */ +export async function copyDirectoryByPath(existingConfigPath: string, copyConfigPath: string): Promise { + fse.copy(existingConfigPath, copyConfigPath) + .then(() => console.log("New config folder created :" + copyConfigPath)) + .catch(err => console.log("Error creating config folder")); +} +/** + * Open config files from specified parent directory + */ +export async function openConfigFile(parentDir: string, configFileName: string) { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); +} + +export async function callAssitantAction(editor: TextEditor, selectValue: string) { + let 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(selectValue); + } +} From a0f1d58791ffdde6c247b3da6931e926848ba2ca Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 23:57:23 +0530 Subject: [PATCH 29/44] description added for methods --- src/test/GradleSingleModLCLSTest.ts | 16 +++++----- src/test/utils/testUtils.ts | 49 +++++++++++++++++++---------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index f44b92f8..7e364246 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -import { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; +import { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; @@ -23,11 +23,10 @@ describe('LCLS tests for Gradle Project', function () { }); it('Should copy content of server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; actualServerXMLContent = await editor.getText(); - assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); console.log('Sever.xml content is:', actualServerXMLContent); @@ -59,12 +58,12 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - }).timeout(35000); + }).timeout(38000); it('Should apply quick fix for invalid value in server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnippet = ""; const hoverExpectedSnippet = ""; await editor.typeTextAt(17, 5, stanzaSnippet); @@ -99,7 +98,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); - console.log("Content after Quick fix : ", updatedSeverXMLContent); + console.log("Content after Quick fix is: ", updatedSeverXMLContent); assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.'); editor.clearText(); @@ -112,7 +111,6 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint.`; - const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); await utils.delay(3000); focusTargetedElement.click(); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index e058705e..9fab361f 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -195,15 +195,17 @@ export async function clearCommandPalette() { } /** - * Remove specific directory + * + * @param projectPath + * Remove specific directory with contents */ -export async function removeDirectoryByPath(projectPath: string): Promise { +export async function removeDirectoryByPath(dirPath: string): Promise { try { - fs.accessSync(projectPath); - const projectContent = fs.readdirSync(projectPath); + fs.accessSync(dirPath); + const dirContent = fs.readdirSync(dirPath); await Promise.all( - projectContent.map(async (projectFiles) => { - const projectContentPath = path.join(projectPath, projectFiles); + dirContent.map(async (dirFiles) => { + const projectContentPath = path.join(dirPath, dirFiles); const stats = fs.lstatSync(projectContentPath); if (stats.isDirectory()) { await removeDirectoryByPath(projectContentPath); @@ -212,22 +214,29 @@ export async function removeDirectoryByPath(projectPath: string): Promise } }) ); - fs.rmdirSync(projectPath); + fs.rmdirSync(dirPath); } catch (error) { - console.error(`Error removing new project: ${error}`); + console.error(`Error removing directory: ${error}`); } } /** - * Copy a specific directory + * + * @param existingConfigPath + * @param copyConfigPath + * Copy a specific directory */ -export async function copyDirectoryByPath(existingConfigPath: string, copyConfigPath: string): Promise { - fse.copy(existingConfigPath, copyConfigPath) - .then(() => console.log("New config folder created :" + copyConfigPath)) - .catch(err => console.log("Error creating config folder")); +export async function copyDirectoryByPath(existingDirPath: string, copyDirPath: string): Promise { + fse.copy(existingDirPath, copyDirPath) + .then(() => console.log("Folder content copied :" + copyDirPath)) + .catch(err => console.log("Error occuried while copying content")); } + /** - * Open config files from specified parent directory + * + * @param parentDir + * @param configFileName + * Open specific config file from parent directory */ export async function openConfigFile(parentDir: string, configFileName: string) { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); @@ -235,11 +244,17 @@ export async function openConfigFile(parentDir: string, configFileName: string) await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); } +/** + * + * @param editor + * @param selectValue + * Function to call toggle assistant to select value from suggestion list + */ export async function callAssitantAction(editor: TextEditor, selectValue: string) { let 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(selectValue); + // to select an item use + await assist.select(selectValue); } -} +} \ No newline at end of file From 4e8f0f9ed57b8a8c815be83d0e8d4b7f9f2d9f86 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 28 Jan 2025 15:03:05 +0530 Subject: [PATCH 30/44] addressed review comments --- src/test/GradleSingleModLCLSTest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 7e364246..8fcfca3e 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -250,12 +250,12 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - const ExpectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; + const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; await editor.clearText(); const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; await editor.typeTextAt(1, 1, testHoverTarget); await utils.delay(5000); - console.log(ExpectedHoverOutcome); + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); await utils.delay(3000); focusTargetLement.click(); @@ -269,7 +269,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue === (ExpectedHoverOutcome), 'Did not get expected hover data for server.env'); + assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); await editor.clearText(); }).timeout(35000); From e2ba37562880d3d61842c0b77d6d4da1d192ac94 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 16:41:27 +0530 Subject: [PATCH 31/44] Server.env test cases updated to diffrent file --- src/test/GradleSingleModLclsServerEnvTest.ts | 123 +++++++++++++++++++ src/test/definitions/constants.ts | 37 ++++++ src/test/utils/testUtils.ts | 20 +++ 3 files changed, 180 insertions(+) create mode 100755 src/test/GradleSingleModLclsServerEnvTest.ts diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts new file mode 100755 index 00000000..8aba00b7 --- /dev/null +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2025 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 { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester"; +import * as utils from './utils/testUtils'; +import * as constants from './definitions/constants'; + +const path = require('path'); +const assert = require('assert'); + +describe('LCLS tests for Gradle Project - Server.env', function () { + let editor: TextEditor; + let actualServerXMLContent: string; + + before(() => { + utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + }); + + it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = "=TBA"; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; + + await editor.typeTextAt(1, 1, configNameSnippet); + await utils.delay(5000); + //open the assistant + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); + + await editor.typeTextAt(1, 27, insertConfig); + await utils.delay(2500); + await utils.callAssitantAction(editor, 'TBASIC'); + + await editor.toggleContentAssist(false); + + const updatedSeverEnvContent = await editor.getText(); + await utils.delay(3000); + assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); + await editor.clearText(); + await utils.closeEditor(constants.SERVER_ENV); + + }).timeout(45000); + + it('Should show hover support for server.env Liberty Server config setting', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; + + const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; + await editor.clearText(); + const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; + await editor.typeTextAt(1, 1, testHoverTarget); + await utils.delay(5000); + + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); + await utils.delay(3000); + focusTargetLement.click(); + await editor.click(); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetLement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text is:" + hoverValue); + + assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); + await editor.clearText(); + await utils.closeEditor(constants.SERVER_ENV); + + }).timeout(35000); + + it('Should show diagnostic support in server.env ', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; + + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = '=sample_value_is_updating_as_nodata'; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; + + await editor.typeTextAt(1, 1, configNameSnippet); + await utils.delay(5000); + //open the assistant + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); + // close the assistant + await editor.toggleContentAssist(false); + + await editor.typeTextAt(1, 27, insertConfig); + const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); + await utils.delay(3000); + focusTargetElement.click(); + await editor.click(); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetElement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text is:" + hoverValue); + + assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); + await editor.clearText(); + await utils.closeEditor(constants.SERVER_ENV); + + }).timeout(35000); + + after(() => { + utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + console.log("Removed new config folder:"); + }); + +}); \ No newline at end of file diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 5df574ec..86a35a12 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -46,3 +46,40 @@ export const CONFIG_TWO = "config2"; export const BOOTSTRAP_PROPERTIES = "bootstrap.properties"; export const SERVER_XML = "server.xml"; export const SERVER_ENV = "server.env"; +export const CLOSE_EDITOR = "View: Close Editor"; +export const CONFIRM_MESSAGES = { + [SERVER_XML]: 'Do you want to save the changes you made to server.xml?', + [SERVER_ENV]: 'Do you want to save the changes you made to server.env?', + [BOOTSTRAP_PROPERTIES]: 'Do you want to save the changes you made to bootstrap.properties?' +}; +export const EXPECTED_OUTCOME_WRONG = "'wrong' is not a valid value of union type 'booleanType'."; +export const TARGETED_VALUE_LOGGING = ''; +export const FOCUS_WRONG = "//*[contains(text(), 'wrong')]"; +export const SNIPPET_LOGGING = ""; +export const FOCUS_QUICKFIX = "//*[contains(text(), 'Quick Fix')]"; +export const LOGGING_TRUE = "//*[contains(text(), \"Replace with 'true'\")]"; +export const FOCUS_HTTPENDPOINT = "//*[contains(text(), 'httpEndpoint')]"; +export const FOCUS_MPHEALTH = "//*[contains(text(), 'mpHealth')]"; +export const FEATURE_MPHEALTH = 'mpHealth-4.0'; +export const NEWLINE = '\n'; +export const DESCRIPTION_MPHEALTH = "Description: This feature provides support for the MicroProfile Health specification."; +export const DESCRIPTION_HTTPENDPOINT = `Configuration properties for an HTTP endpoint.`; +export const FEATURE_EL = "el-3.0"; +export const LOGGING_TAG = ""; +export const LOGGING = 'logging'; +export const FEATURE_TAG = 'feature'; +export const EL_VALUE = 'el-3.0'; +export const PLATFORM_JAKARTA_VALUE = "jakartaee-11.0"; +export const DESCRIPTION_PLATFORM = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`; +export const FOCUS_JAKARTA = "//*[contains(text(), '\jakarta\')]"; +export const PLATFORM_JAKARTA = "jakarta"; +export const PLATFORM_JAKARTA_ERROR = `ERROR: The platform "jakarta" does not exist.`; +export const FOCUS_JAKARTA_ELEVEN= "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; +export const FEATURE_SERVLET = "servlet"; +export const SERVLET_ERROR = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`; +export const FOCUS_SERVLET ="//*[contains(text(), '\servlet\')]"; +export const SERVLET_VALUE= "servlet-3.1"; +export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with servlet-3.1\")]"; +export const PLATFORM ="platform"; +export const JAKARTA_ELEVEN ='jakartaee-11.0'; +export const PLATFORM_JAKARTA_NINE= "jakartaee-9.1"; diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 9fab361f..5ff7ea51 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -244,6 +244,26 @@ export async function openConfigFile(parentDir: string, configFileName: string) await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); } +/** + * Function to close currently opened config file tab + */ +export async function closeEditor(fileType: string) { + const workbench = new Workbench(); + await workbench.openCommandPrompt(); + await delay(3000); + await workbench.executeCommand(constants.CLOSE_EDITOR); + await delay(3000); + const dialog = new ModalDialog(); + const message = await dialog.getMessage(); + + if (fileType in constants.CONFIRM_MESSAGES) { + expect(message).contains(constants.CONFIRM_MESSAGES[fileType as keyof typeof constants.CONFIRM_MESSAGES]); + } + const buttons = await dialog.getButtons(); + expect(buttons.length).equals(3); + await dialog.pushButton('Don\'t Save'); +} + /** * * @param editor From fefa988f781ff8aa6cf1241e0ff24d67b13585b7 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 16:42:02 +0530 Subject: [PATCH 32/44] removed server.xml test cases --- src/test/GradleSingleModLCLSTest.ts | 317 ---------------------------- 1 file changed, 317 deletions(-) delete mode 100755 src/test/GradleSingleModLCLSTest.ts diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts deleted file mode 100755 index 8fcfca3e..00000000 --- a/src/test/GradleSingleModLCLSTest.ts +++ /dev/null @@ -1,317 +0,0 @@ -/** - * Copyright (c) 2025 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 { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester"; -import * as utils from './utils/testUtils'; -import * as constants from './definitions/constants'; - -const path = require('path'); -const assert = require('assert'); - -describe('LCLS tests for Gradle Project', function () { - let editor: TextEditor; - let actualServerXMLContent: string; - - before(() => { - utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); - }); - - it('Should copy content of server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) - editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - - actualServerXMLContent = await editor.getText(); - assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); - console.log('Sever.xml content is:', actualServerXMLContent); - - }).timeout(25000); - - it('Should show diagnostic for server.xml invalid value', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - - const expectedOutcomeValue = `'wrong' is not a valid value of union type 'booleanType'.`; - const hoverTargetValue = ''; - - await editor.typeTextAt(17, 5, hoverTargetValue); - const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); - await utils.delay(3000); - focusTargetedElement.click(); - await editor.click(); - - const driverActionList = VSBrowser.instance.driver.actions(); - await driverActionList.move({ origin: focusTargetedElement }).perform(); - await utils.delay(5000); - - const hoverContents = editor.findElement(By.className('hover-contents')); - const hoverFoundOutcome = await hoverContents.getText(); - console.log("Hover text is:" + hoverFoundOutcome); - - assert(hoverFoundOutcome.includes(expectedOutcomeValue), 'Did not get expected diagnostic in server.xml'); - - editor.clearText(); - editor.setText(actualServerXMLContent); - console.log("server.xml content is restored"); - - }).timeout(38000); - - it('Should apply quick fix for invalid value in server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) - editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - - const stanzaSnippet = ""; - const hoverExpectedSnippet = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); - await utils.delay(2000); - const hoverTargetValue = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); - await utils.delay(7000); - - const driverActionList = VSBrowser.instance.driver.actions(); - await driverActionList.move({ origin: hoverTargetValue }).perform(); - await utils.delay(3000); - - const driver = VSBrowser.instance.driver; - const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); - await utils.delay(2000); - - const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await quickFixPopupLink.click(); - - const hoverWindowTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverWindowTaskBar.findElement(By.className('actionList')); - await utils.delay(2000); - - const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); - // Setting pointer block element display value as none to choose option from Quickfix menu - if (pointerBlockedElement) { - await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); - } else { - console.log('pointerBlockElement is not found!'); - } - const quickfixOptionValues = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - await quickfixOptionValues.click(); - - const updatedSeverXMLContent = await editor.getText(); - await utils.delay(3000); - console.log("Content after Quick fix is: ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.'); - - editor.clearText(); - editor.setText(actualServerXMLContent); - console.log("server.xml content is restored"); - - }).timeout(38000); - - it('Should show hover support for server.xml Liberty Server Attribute', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - - const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint.`; - const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); - await utils.delay(3000); - focusTargetedElement.click(); - await editor.click(); - - const driverActionList = VSBrowser.instance.driver.actions(); - await driverActionList.move({ origin: focusTargetedElement }).perform(); - await utils.delay(5000); - - const hoverContent = editor.findElement(By.className('hover-contents')); - const hoveredTextValue = await hoverContent.getText(); - console.log("Hover text is: " + hoveredTextValue); - - assert(hoveredTextValue.includes(hoverExpectedOutcome), 'Did not get expected hover data Liberty Server Attribute.'); - - editor.clearText(); - editor.setText(actualServerXMLContent); - console.log("server.xml content is restored"); - - }).timeout(35000); - - it('Should show hover support for server.xml Liberty Server Feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - - const hoverOutcome = `Description: This feature provides support for the MicroProfile Health specification.`; - const testHoverTargetTag = 'mpHealth-4.0'; - - await editor.typeTextAt(15, 35, '\n'); - await utils.delay(1000); - await editor.typeTextAt(16, 9, testHoverTargetTag); - const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'mpHealth')]")); - await utils.delay(3000); - focusTargetElement.click(); - await editor.click(); - - const driverActionList = VSBrowser.instance.driver.actions(); - await driverActionList.move({ origin: focusTargetElement }).perform(); - await utils.delay(5000); - - const hoverContents = editor.findElement(By.className('hover-contents')); - const hoveredValue = await hoverContents.getText(); - console.log("Hover text is :" + hoveredValue); - - assert(hoveredValue.includes(hoverOutcome), 'Did not get expected hover data Liberty Server Feature.'); - - editor.clearText(); - editor.setText(actualServerXMLContent); - console.log("server.xml content is restored"); - - }).timeout(33000); - - it('Should show type ahead support in server.xml Liberty Server Feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - - editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const featureTag = " { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - - editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = "log"; - - const insertedConfigValue = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); - await utils.delay(5000); - //open the assistant - await utils.callAssitantAction(editor, 'logging') - - // close the assistant - await editor.toggleContentAssist(false); - - const updatedServerxmlContent = await editor.getText(); - await utils.delay(3000); - console.log("Updated content in Sever.xml : ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(insertedConfigValue), 'Type ahead support is not worked as expected in server.xml Liberty Server Configuration Stanza'); - - editor.clearText(); - editor.setText(actualServerXMLContent); - console.log("server.xml content is restored"); - - }).timeout(25000); - - it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor('server.env') as TextEditor; - - const configNameSnippet = 'WLP_LOGGING_CON'; - const insertConfig = "=TBA"; - const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; - const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; - - await editor.typeTextAt(1, 1, configNameSnippet); - await utils.delay(5000); - //open the assistant - await utils.callAssitantAction(editor, envCfgNameChooserSnippet); - - await editor.typeTextAt(1, 27, insertConfig); - await utils.delay(2500); - await utils.callAssitantAction(editor, 'TBASIC'); - - await editor.toggleContentAssist(false); - - const updatedSeverEnvContent = await editor.getText(); - await utils.delay(3000); - assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); - await editor.clearText(); - - }).timeout(35000); - - it('Should show hover support for server.env Liberty Server config setting', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - - const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; - await editor.clearText(); - const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; - await editor.typeTextAt(1, 1, testHoverTarget); - await utils.delay(5000); - - const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); - await utils.delay(3000); - focusTargetLement.click(); - await editor.click(); - - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: focusTargetLement }).perform(); - await utils.delay(5000); - - const hoverContents = editor.findElement(By.className('hover-contents')); - const hoverValue = await hoverContents.getText(); - console.log("Hover text is:" + hoverValue); - - assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); - await editor.clearText(); - - }).timeout(35000); - - it('Should show diagnostic support in server.env ', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - - const configNameSnippet = 'WLP_LOGGING_CON'; - const insertConfig = '=sample_value_is_updating_as_nodata'; - const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; - const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; - - await editor.typeTextAt(1, 1, configNameSnippet); - await utils.delay(5000); - //open the assistant - await utils.callAssitantAction(editor, envCfgNameChooserSnippet); - // close the assistant - await editor.toggleContentAssist(false); - - await editor.typeTextAt(1, 27, insertConfig); - const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); - await utils.delay(3000); - focusTargetElement.click(); - await editor.click(); - - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: focusTargetElement }).perform(); - await utils.delay(5000); - - const hoverContents = editor.findElement(By.className('hover-contents')); - const hoverValue = await hoverContents.getText(); - console.log("Hover text is:" + hoverValue); - - assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); - await editor.clearText(); - - }).timeout(35000); - - after(() => { - utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); - console.log("Removed new config folder:"); - }); - -}); \ No newline at end of file From a243593102ad7cef41b0ebc58bf0c751d20e08d2 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 17:15:58 +0530 Subject: [PATCH 33/44] test case time - delay updated --- src/test/GradleSingleModLclsServerEnvTest.ts | 51 ++++++++------------ 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index 8aba00b7..c0dbfa36 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -24,43 +24,37 @@ describe('LCLS tests for Gradle Project - Server.env', function () { it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor('server.env') as TextEditor; - - const configNameSnippet = 'WLP_LOGGING_CON'; - const insertConfig = "=TBA"; - const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; - const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; + editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - await editor.typeTextAt(1, 1, configNameSnippet); + await editor.typeTextAt(1, 1, constants.WLP_LOGGING_CON); await utils.delay(5000); //open the assistant - await utils.callAssitantAction(editor, envCfgNameChooserSnippet); + await utils.callAssitantAction(editor, constants.WLP_LOGGING_CONSOLE_FORMAT); - await editor.typeTextAt(1, 27, insertConfig); + await editor.typeTextAt(1, 27, constants.TBA); await utils.delay(2500); - await utils.callAssitantAction(editor, 'TBASIC'); - + await utils.callAssitantAction(editor, constants.TBASIC); + await editor.toggleContentAssist(false); const updatedSeverEnvContent = await editor.getText(); await utils.delay(3000); - assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); + assert(updatedSeverEnvContent.includes(constants.CONSOLE_FORMAT_TBASIC), 'Type ahead support is not working as expected in server.env'); await editor.clearText(); await utils.closeEditor(constants.SERVER_ENV); - }).timeout(45000); + }).timeout(50000); it('Should show hover support for server.env Liberty Server config setting', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; await editor.clearText(); - const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; - await editor.typeTextAt(1, 1, testHoverTarget); + + await editor.typeTextAt(1, 1, constants.LOGLEVEL_WITH_VALUE); await utils.delay(5000); - - const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); + + const focusTargetLement = editor.findElement(By.xpath(constants.FOCUS_LOGLEVEL)); await utils.delay(3000); focusTargetLement.click(); await editor.click(); @@ -73,30 +67,25 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); + assert(hoverValue.includes(constants.LOG_LEVEL_INFO_MSG), 'Did not get expected hover data for server.env'); await editor.clearText(); await utils.closeEditor(constants.SERVER_ENV); - }).timeout(35000); + }).timeout(45000); it('Should show diagnostic support in server.env ', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - const configNameSnippet = 'WLP_LOGGING_CON'; - const insertConfig = '=sample_value_is_updating_as_nodata'; - const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; - const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; - - await editor.typeTextAt(1, 1, configNameSnippet); + await editor.typeTextAt(1, 1, constants.WLP_LOGGING_CON); await utils.delay(5000); //open the assistant - await utils.callAssitantAction(editor, envCfgNameChooserSnippet); + await utils.callAssitantAction(editor, constants.WLP_LOGGING_CONSOLE_FORMAT); // close the assistant await editor.toggleContentAssist(false); - await editor.typeTextAt(1, 27, insertConfig); - const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); + await editor.typeTextAt(1, 27, constants.VALUE_NODATA); + const focusTargetElement = editor.findElement(By.xpath(constants.FOCUS_NODATA)); await utils.delay(3000); focusTargetElement.click(); await editor.click(); @@ -109,11 +98,11 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); + assert(hoverValue.includes(constants.CONSOLE_FORMAT_DIAGNOSTIC), 'Did not get expected diagnostic as expected in server.env file'); await editor.clearText(); await utils.closeEditor(constants.SERVER_ENV); - }).timeout(35000); + }).timeout(45000); after(() => { utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From cbb74bcd4de61bdfe7b1671295472b31cb7769ff Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 17:16:18 +0530 Subject: [PATCH 34/44] constant - file updated --- src/test/definitions/constants.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 86a35a12..abe4b12b 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -83,3 +83,14 @@ export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with export const PLATFORM ="platform"; export const JAKARTA_ELEVEN ='jakartaee-11.0'; export const PLATFORM_JAKARTA_NINE= "jakartaee-9.1"; +export const WLP_LOGGING_CONSOLE_FORMAT='WLP_LOGGING_CONSOLE_FORMAT'; +export const CONSOLE_FORMAT_TBASIC='WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; +export const TBASIC='TBASIC'; +export const TBA="=TBA"; +export const WLP_LOGGING_CON= 'WLP_LOGGING_CON'; +export const LOG_LEVEL_INFO_MSG= 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; +export const FOCUS_LOGLEVEL ="//*[contains(text(), 'CONSOLE_LOGLEVEL')]"; +export const LOGLEVEL_WITH_VALUE= 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; +export const CONSOLE_FORMAT_DIAGNOSTIC ='The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; +export const FOCUS_NODATA = "//*[contains(text(), 'nodata')]"; +export const VALUE_NODATA = '=sample_value_is_updating_as_nodata' \ No newline at end of file From 9f92154756f0878099f83365146456e5d81265d3 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 17:17:02 +0530 Subject: [PATCH 35/44] formated - constants --- src/test/definitions/constants.ts | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index abe4b12b..782090d6 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -10,7 +10,7 @@ */ export const MAVEN_PROJECT = "liberty.maven.test.wrapper.app"; -export const GRADLE_PROJECT= "liberty.gradle.test.wrapper.app"; +export const GRADLE_PROJECT = "liberty.gradle.test.wrapper.app"; export const START_DASHBOARD_ACTION = "Start"; export const STOP_DASHBOARD_ACTION = "Stop"; export const START_DASHBOARD_MAC_ACTION = "Liberty: Start"; @@ -38,7 +38,7 @@ export const GRADLE_TEST_REPORT_TITLE = "liberty.gradle.test.wrapper.app test re export const ATTACH_DEBUGGER_DASHBOARD_ACTION = "Attach debugger"; export const ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION = "Liberty: Attach debugger"; /** Maven: Dev mode debug port argument key. */ -export const MAVEN_DEVMODE_DEBUG_PORT_PARM = "-DdebugPort"; +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 CONFIG = "config"; @@ -74,23 +74,23 @@ export const DESCRIPTION_PLATFORM = `Description: This platform resolves the Lib export const FOCUS_JAKARTA = "//*[contains(text(), '\jakarta\')]"; export const PLATFORM_JAKARTA = "jakarta"; export const PLATFORM_JAKARTA_ERROR = `ERROR: The platform "jakarta" does not exist.`; -export const FOCUS_JAKARTA_ELEVEN= "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; +export const FOCUS_JAKARTA_ELEVEN = "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; export const FEATURE_SERVLET = "servlet"; export const SERVLET_ERROR = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`; -export const FOCUS_SERVLET ="//*[contains(text(), '\servlet\')]"; -export const SERVLET_VALUE= "servlet-3.1"; +export const FOCUS_SERVLET = "//*[contains(text(), '\servlet\')]"; +export const SERVLET_VALUE = "servlet-3.1"; export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with servlet-3.1\")]"; -export const PLATFORM ="platform"; -export const JAKARTA_ELEVEN ='jakartaee-11.0'; -export const PLATFORM_JAKARTA_NINE= "jakartaee-9.1"; -export const WLP_LOGGING_CONSOLE_FORMAT='WLP_LOGGING_CONSOLE_FORMAT'; -export const CONSOLE_FORMAT_TBASIC='WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; -export const TBASIC='TBASIC'; -export const TBA="=TBA"; -export const WLP_LOGGING_CON= 'WLP_LOGGING_CON'; -export const LOG_LEVEL_INFO_MSG= 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; -export const FOCUS_LOGLEVEL ="//*[contains(text(), 'CONSOLE_LOGLEVEL')]"; -export const LOGLEVEL_WITH_VALUE= 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; -export const CONSOLE_FORMAT_DIAGNOSTIC ='The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; +export const PLATFORM = "platform"; +export const JAKARTA_ELEVEN = 'jakartaee-11.0'; +export const PLATFORM_JAKARTA_NINE = "jakartaee-9.1"; +export const WLP_LOGGING_CONSOLE_FORMAT = 'WLP_LOGGING_CONSOLE_FORMAT'; +export const CONSOLE_FORMAT_TBASIC = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; +export const TBASIC = 'TBASIC'; +export const TBA = "=TBA"; +export const WLP_LOGGING_CON = 'WLP_LOGGING_CON'; +export const LOG_LEVEL_INFO_MSG = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; +export const FOCUS_LOGLEVEL = "//*[contains(text(), 'CONSOLE_LOGLEVEL')]"; +export const LOGLEVEL_WITH_VALUE = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; +export const CONSOLE_FORMAT_DIAGNOSTIC = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; export const FOCUS_NODATA = "//*[contains(text(), 'nodata')]"; export const VALUE_NODATA = '=sample_value_is_updating_as_nodata' \ No newline at end of file From aa9a0cbc289870c1f2d8397f8e9b045580e7ab4d Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 21:01:32 +0530 Subject: [PATCH 36/44] constant file updated --- src/test/definitions/constants.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 782090d6..08f63190 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -93,4 +93,13 @@ export const FOCUS_LOGLEVEL = "//*[contains(text(), 'CONSOLE_LOGLEVEL')]"; export const LOGLEVEL_WITH_VALUE = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; export const CONSOLE_FORMAT_DIAGNOSTIC = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; export const FOCUS_NODATA = "//*[contains(text(), 'nodata')]"; -export const VALUE_NODATA = '=sample_value_is_updating_as_nodata' \ No newline at end of file +export const VALUE_NODATA = '=sample_value_is_updating_as_nodata'; +export const WS_LOGGING_CON = "com.ibm.ws.logging.con"; +export const VALUE_WRONG = "=wrong"; +export const WS_LOGGING_CONSOLE_FORMAT = "com.ibm.ws.logging.console.format"; +export const WS_LOGGING_CONSOLE_DIAGNOSTIC = "The value `wrong` is not valid for the property `com.ibm.ws.logging.console.format`."; +export const WS_LOGGING_CONSOLE_VALUE = "com.ibm.ws.logging.console.log.level=OFF"; +export const FOCUS_WS_LOGLEVEL = "//*[contains(text(), 'ws.logging.console.log.level')]"; +export const WS_LOGLEVEL_TBASIC = 'com.ibm.ws.logging.trace.format=TBASIC'; +export const WS_LOG_TRACE_FORMAT = 'com.ibm.ws.logging.trace.format'; +export const WS_LOGGING_T = "com.ibm.ws.logging.t"; \ No newline at end of file From d1d8d5c038bff5ce6217f79190b6f1573c5e6fd9 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 22:50:46 +0530 Subject: [PATCH 37/44] GHA build failure fix --- src/test/GradleSingleModLclsServerEnvTest.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index c0dbfa36..c1d07438 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -41,7 +41,6 @@ describe('LCLS tests for Gradle Project - Server.env', function () { await utils.delay(3000); assert(updatedSeverEnvContent.includes(constants.CONSOLE_FORMAT_TBASIC), 'Type ahead support is not working as expected in server.env'); await editor.clearText(); - await utils.closeEditor(constants.SERVER_ENV); }).timeout(50000); @@ -69,7 +68,6 @@ describe('LCLS tests for Gradle Project - Server.env', function () { assert(hoverValue.includes(constants.LOG_LEVEL_INFO_MSG), 'Did not get expected hover data for server.env'); await editor.clearText(); - await utils.closeEditor(constants.SERVER_ENV); }).timeout(45000); @@ -102,11 +100,12 @@ describe('LCLS tests for Gradle Project - Server.env', function () { await editor.clearText(); await utils.closeEditor(constants.SERVER_ENV); - }).timeout(45000); + }).timeout(55000); - after(() => { + after(async () => { utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); + utils.delay(5000); }); }); \ No newline at end of file From 41ced4909c96b757d3124c75519cff0fa1ed7b6b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 30 Jan 2025 00:21:14 +0530 Subject: [PATCH 38/44] GHA build failure fix --- src/test/GradleSingleModLclsServerEnvTest.ts | 55 ++++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index c1d07438..b9cc99ec 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -24,36 +24,42 @@ describe('LCLS tests for Gradle Project - Server.env', function () { it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = "=TBA"; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; - await editor.typeTextAt(1, 1, constants.WLP_LOGGING_CON); + await editor.typeTextAt(1, 1, configNameSnippet); await utils.delay(5000); //open the assistant - await utils.callAssitantAction(editor, constants.WLP_LOGGING_CONSOLE_FORMAT); + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); - await editor.typeTextAt(1, 27, constants.TBA); + await editor.typeTextAt(1, 27, insertConfig); await utils.delay(2500); - await utils.callAssitantAction(editor, constants.TBASIC); - + await utils.callAssitantAction(editor, 'TBASIC'); + await editor.toggleContentAssist(false); const updatedSeverEnvContent = await editor.getText(); await utils.delay(3000); - assert(updatedSeverEnvContent.includes(constants.CONSOLE_FORMAT_TBASIC), 'Type ahead support is not working as expected in server.env'); + assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); await editor.clearText(); - }).timeout(50000); + }).timeout(35000); it('Should show hover support for server.env Liberty Server config setting', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; + const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; await editor.clearText(); - - await editor.typeTextAt(1, 1, constants.LOGLEVEL_WITH_VALUE); + const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; + await editor.typeTextAt(1, 1, testHoverTarget); await utils.delay(5000); - - const focusTargetLement = editor.findElement(By.xpath(constants.FOCUS_LOGLEVEL)); + + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); await utils.delay(3000); focusTargetLement.click(); await editor.click(); @@ -66,24 +72,29 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(constants.LOG_LEVEL_INFO_MSG), 'Did not get expected hover data for server.env'); + assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); await editor.clearText(); - }).timeout(45000); + }).timeout(35000); it('Should show diagnostic support in server.env ', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; - await editor.typeTextAt(1, 1, constants.WLP_LOGGING_CON); + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = '=sample_value_is_updating_as_nodata'; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; + + await editor.typeTextAt(1, 1, configNameSnippet); await utils.delay(5000); //open the assistant - await utils.callAssitantAction(editor, constants.WLP_LOGGING_CONSOLE_FORMAT); + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); // close the assistant await editor.toggleContentAssist(false); - await editor.typeTextAt(1, 27, constants.VALUE_NODATA); - const focusTargetElement = editor.findElement(By.xpath(constants.FOCUS_NODATA)); + await editor.typeTextAt(1, 27, insertConfig); + const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]")); await utils.delay(3000); focusTargetElement.click(); await editor.click(); @@ -96,16 +107,14 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(constants.CONSOLE_FORMAT_DIAGNOSTIC), 'Did not get expected diagnostic as expected in server.env file'); + assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); await editor.clearText(); - await utils.closeEditor(constants.SERVER_ENV); - }).timeout(55000); + }).timeout(35000); - after(async () => { + after(() => { utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); - utils.delay(5000); }); }); \ No newline at end of file From d6baa4ec36d0a84614db1c8b750e601a9c73f7df Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 12:39:35 +0530 Subject: [PATCH 39/44] GHA build failure - fix --- src/test/GradleSingleModLclsServerEnvTest.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index b9cc99ec..3edf5a51 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -7,22 +7,34 @@ * * SPDX-License-Identifier: EPL-2.0 */ -import { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester"; +import { By, EditorView, SideBarView, TextEditor, ViewSection, VSBrowser } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; +import { expect } from "chai"; const path = require('path'); const assert = require('assert'); describe('LCLS tests for Gradle Project - Server.env', function () { let editor: TextEditor; - let actualServerXMLContent: string; + let sidebar: SideBarView; + let section: ViewSection; before(() => { + sidebar = new SideBarView(); utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); - it('Should show type ahead support in server.env for a Liberty Server Configuration Stanza', async () => { + 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(30000); + + it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => { + await utils.delay(8000); await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor('server.env') as TextEditor; @@ -44,7 +56,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const updatedSeverEnvContent = await editor.getText(); await utils.delay(3000); - assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Type ahead support is not working as expected in server.env'); + assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env'); await editor.clearText(); }).timeout(35000); From c08854e2e195fab6303d3b2a297dbd20b1a27372 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 12:47:57 +0530 Subject: [PATCH 40/44] GHA build failure fix --- src/test/GradleSingleModLclsServerEnvTest.ts | 15 ++++++++++++--- src/test/utils/testUtils.ts | 10 +++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index 3edf5a51..0043726a 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -35,7 +35,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => { await utils.delay(8000); - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor('server.env') as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; @@ -57,12 +57,15 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const updatedSeverEnvContent = await editor.getText(); await utils.delay(3000); assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env'); + await editor.clearText(); + await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.delay(8000); }).timeout(35000); it('Should show hover support for server.env Liberty Server config setting', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; @@ -85,12 +88,15 @@ describe('LCLS tests for Gradle Project - Server.env', function () { console.log("Hover text is:" + hoverValue); assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); + await editor.clearText(); + await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.delay(8000); }).timeout(35000); it('Should show diagnostic support in server.env ', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; @@ -120,7 +126,10 @@ describe('LCLS tests for Gradle Project - Server.env', function () { console.log("Hover text is:" + hoverValue); assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); + await editor.clearText(); + await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.delay(8000); }).timeout(35000); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index d07fc15d..20e4e8e6 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -245,18 +245,18 @@ export async function copyDirectoryByPath(existingDirPath: string, copyDirPath: * * @param parentDir * @param configFileName - * Open specific config file from parent directory + * Open specific file from parent directory */ -export async function openConfigFile(parentDir: string, configFileName: string) { +export async function openFileByPath(parentDir: string, fileName: string) { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); + await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, fileName)); } /** - * Function to close currently opened config file tab + * Function to close currently opened file tab */ -export async function closeEditor(fileType: string) { +export async function closeFileTab(fileType: string) { const workbench = new Workbench(); await workbench.openCommandPrompt(); await delay(3000); From cfa3ce6cf2d701003056ad809521d7bb4ce354de Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 12:55:27 +0530 Subject: [PATCH 41/44] GHA build failure - fix delay added --- src/test/GradleSingleModLclsServerEnvTest.ts | 76 ++++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index 0043726a..b108096c 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -25,46 +25,16 @@ describe('LCLS tests for Gradle Project - Server.env', function () { utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); - it('getViewControl works with the correct label', async() => { + it('getViewControl works with the correct label', async () => { const contentPart = sidebar.getContent(); - section = await contentPart.getSection('Liberty Dashboard'); + section = await contentPart.getSection('Liberty Dashboard'); console.log("Found Liberty Dashboard...."); - expect(section).not.undefined; - - }).timeout(30000); + expect(section).not.undefined; - it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => { - await utils.delay(8000); - await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); - editor = await new EditorView().openEditor('server.env') as TextEditor; - - const configNameSnippet = 'WLP_LOGGING_CON'; - const insertConfig = "=TBA"; - const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; - const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; - - await editor.typeTextAt(1, 1, configNameSnippet); - await utils.delay(5000); - //open the assistant - await utils.callAssitantAction(editor, envCfgNameChooserSnippet); - - await editor.typeTextAt(1, 27, insertConfig); - await utils.delay(2500); - await utils.callAssitantAction(editor, 'TBASIC'); - - await editor.toggleContentAssist(false); - - const updatedSeverEnvContent = await editor.getText(); - await utils.delay(3000); - assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env'); - - await editor.clearText(); - await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); - await utils.delay(8000); - - }).timeout(35000); + }).timeout(30000); it('Should show hover support for server.env Liberty Server config setting', async () => { + await utils.delay(8000); await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; @@ -73,7 +43,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; await editor.typeTextAt(1, 1, testHoverTarget); await utils.delay(5000); - + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]")); await utils.delay(3000); focusTargetLement.click(); @@ -93,7 +63,37 @@ describe('LCLS tests for Gradle Project - Server.env', function () { await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); await utils.delay(8000); - }).timeout(35000); + }).timeout(85000); + + it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => { + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); + editor = await new EditorView().openEditor('server.env') as TextEditor; + + const configNameSnippet = 'WLP_LOGGING_CON'; + const insertConfig = "=TBA"; + const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT'; + const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; + + await editor.typeTextAt(1, 1, configNameSnippet); + await utils.delay(5000); + //open the assistant + await utils.callAssitantAction(editor, envCfgNameChooserSnippet); + + await editor.typeTextAt(1, 27, insertConfig); + await utils.delay(2500); + await utils.callAssitantAction(editor, 'TBASIC'); + + await editor.toggleContentAssist(false); + + const updatedSeverEnvContent = await editor.getText(); + await utils.delay(3000); + assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env'); + + await editor.clearText(); + await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.delay(8000); + + }).timeout(85000); it('Should show diagnostic support in server.env ', async () => { await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); @@ -131,7 +131,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); await utils.delay(8000); - }).timeout(35000); + }).timeout(85000); after(() => { utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From b47dd2bc2b83e3dc33829e6538daf800e703b47c Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 13:01:18 +0530 Subject: [PATCH 42/44] Changed config path --- src/test/GradleSingleModLclsServerEnvTest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index b108096c..7ae24b75 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -35,7 +35,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { it('Should show hover support for server.env Liberty Server config setting', async () => { await utils.delay(8000); - await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; @@ -66,7 +66,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { }).timeout(85000); it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => { - await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV); editor = await new EditorView().openEditor('server.env') as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; @@ -96,7 +96,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { }).timeout(85000); it('Should show diagnostic support in server.env ', async () => { - await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_ENV); + await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; const configNameSnippet = 'WLP_LOGGING_CON'; From dbd33fbe85f89b97f340de214d01ac22ee17c512 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 15:16:56 +0530 Subject: [PATCH 43/44] increased time delay --- src/test/GradleSingleModLclsServerEnvTest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/GradleSingleModLclsServerEnvTest.ts b/src/test/GradleSingleModLclsServerEnvTest.ts index 7ae24b75..83d091fa 100755 --- a/src/test/GradleSingleModLclsServerEnvTest.ts +++ b/src/test/GradleSingleModLclsServerEnvTest.ts @@ -34,7 +34,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { }).timeout(30000); it('Should show hover support for server.env Liberty Server config setting', async () => { - await utils.delay(8000); + await utils.delay(15000); await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV); editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor; @@ -60,7 +60,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { assert(hoverValue.includes(expectedHoverOutcome), 'Did not get expected hover data for server.env'); await editor.clearText(); - await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.closeFileTab(constants.SERVER_ENV); await utils.delay(8000); }).timeout(85000); @@ -90,7 +90,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env'); await editor.clearText(); - await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.closeFileTab(constants.SERVER_ENV); await utils.delay(8000); }).timeout(85000); @@ -128,7 +128,7 @@ describe('LCLS tests for Gradle Project - Server.env', function () { assert(hoverValue.includes(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file'); await editor.clearText(); - await utils.closeFileTab(constants.BOOTSTRAP_PROPERTIES); + await utils.closeFileTab(constants.SERVER_ENV); await utils.delay(8000); }).timeout(85000); From 883c9ae67beba2adb89d063cd5dd6ab01e1fd6d2 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 19:36:43 +0530 Subject: [PATCH 44/44] review comments addressed --- src/test/definitions/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 08f63190..71a502ca 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -1,6 +1,6 @@ /** - * Copyright (c) 2020, 2022 IBM Corporation. + * Copyright (c) 2020, 2025 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