From 08aefcd64a7e9b6385bece3c0449365630a1d722 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 12 Nov 2024 23:01:34 +0530 Subject: [PATCH 01/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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/28] 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 e7e27ebdc0d61f490ff849317934d93e70cf5a4c Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 16:12:46 +0530 Subject: [PATCH 22/28] diagnostic support test case added for server.xml --- src/test/GradleSingleModLCLSTest.ts | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 640c852c..5afab5e9 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -30,11 +30,41 @@ 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 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(); @@ -77,7 +107,7 @@ 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.'); - + editor.clearText(); editor.setText(actualSeverXMLContent); console.log("Content restored"); From 2afeda08eb4800bd52d2f51a068225cdb6add57a Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 20:28:14 +0530 Subject: [PATCH 23/28] changed 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 5afab5e9..575fa227 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 309fd6ac7097572ab585136a80404e41325df3c8 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 10 Dec 2024 11:19:53 +0530 Subject: [PATCH 24/28] server.env file deleted --- .../src/main/liberty/config/server.env | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.env 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 deleted file mode 100644 index e69de29b..00000000 From 1314e8a814fdf7d19390e5ff299669c9c448e98e Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 13 Dec 2024 14:49:28 +0530 Subject: [PATCH 25/28] test case added for quick fix server feature --- src/test/GradleSingleModLCLSTest.ts | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 575fa227..9dfdf1e6 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -253,6 +253,56 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(25000); + it('Should apply quick fix for invalid value in server.xml for 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 stanzaSnipet = "servlet"; + const expectedHoverData = "servlet-3.1"; + await editor.typeTextAt(15, 35, '\n'); + await editor.typeTextAt(16, 9, stanzaSnipet); + await utils.delay(2000); + const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + 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 feature with servlet-3.1\")]")); + 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 server feature.'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(38000); + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 04da61572136c2f4d07f95ee5f28ee7303fbd12f Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 13 Dec 2024 15:04:59 +0530 Subject: [PATCH 26/28] test case added for diagnostic server feature --- src/test/GradleSingleModLCLSTest.ts | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 9dfdf1e6..75518263 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -253,6 +253,38 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(25000); + it('Should show diagnostic for invalid value in server.xml for 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 stanzaSnipet = "servlet"; + const expectedDiagnosticData = `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`; + await editor.typeTextAt(15, 35, '\n'); + await editor.typeTextAt(16, 9, stanzaSnipet); + await utils.delay(2000); + const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + 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(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(38000); + it('Should apply quick fix for invalid value in server.xml for server feature', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); From 27b13f97aa13da5b20304c0e0fd5e6976cd62cdf Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 11:16:48 +0530 Subject: [PATCH 27/28] Test cases updated --- src/test/GradleSingleModLCLSTest.ts | 82 ----------------------------- 1 file changed, 82 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 75518263..575fa227 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -253,88 +253,6 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(25000); - it('Should show diagnostic for invalid value in server.xml for 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 stanzaSnipet = "servlet"; - const expectedDiagnosticData = `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`; - await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnipet); - await utils.delay(2000); - const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); - 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(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature'); - - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); - - }).timeout(38000); - - it('Should apply quick fix for invalid value in server.xml for 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 stanzaSnipet = "servlet"; - const expectedHoverData = "servlet-3.1"; - await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnipet); - await utils.delay(2000); - const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); - 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 feature with servlet-3.1\")]")); - 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 server feature.'); - - editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); - - }).timeout(38000); - after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 803dc04912ef3e47ac31f08037cd86e18d8fbec1 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 17 Jan 2025 16:23:44 +0530 Subject: [PATCH 28/28] updated typo error --- 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 575fa227..f9dcd865 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}`); }