From 08aefcd64a7e9b6385bece3c0449365630a1d722 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 12 Nov 2024 23:01:34 +0530 Subject: [PATCH 01/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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 f238c5282705667e9717b07d742abf981e7065d8 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 19:51:53 +0530 Subject: [PATCH 13/40] updated quick fix element name --- 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 084d4e3b..2ec1c209 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 41114d827443474a3e2dc4a0541d2f325099d99f Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 20:37:14 +0530 Subject: [PATCH 14/40] Timeout value updated --- 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 2ec1c209..75fe4acb 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -60,9 +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); + await editor.clearText(); + await editor.setText(actualContent); console.log("Content restored"); - }).timeout(25000); + }).timeout(27000); }); From fab341bb6712f0a5844b9b71bd824e856b87dc0a Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 21:18:38 +0530 Subject: [PATCH 15/40] Timeout value updated --- 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 75fe4acb..19f03f7e 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -64,5 +64,5 @@ describe('LCLS Test for Gradle Project', function () { await editor.setText(actualContent); console.log("Content restored"); - }).timeout(27000); + }).timeout(28000); }); From 26b5cdb54a0e644abd82d525c0239c0daa16f15c Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 21:41:59 +0530 Subject: [PATCH 16/40] GHA build fix - timeout value updated --- 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 19f03f7e..eeeb53dd 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -64,5 +64,5 @@ describe('LCLS Test for Gradle Project', function () { await editor.setText(actualContent); console.log("Content restored"); - }).timeout(28000); + }).timeout(38000); }); From 7c60cd83e7dc5bba24311c75e2f5f0ccd72434a4 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 25 Nov 2024 14:23:28 +0530 Subject: [PATCH 17/40] Added mpHealth --- src/test/GradleSingleModLCLSTest.ts | 2 +- .../src/main/liberty/config/server.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index eeeb53dd..ce542fb6 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -26,7 +26,7 @@ describe('LCLS Test for Gradle Project', function () { const actualContent = await editor.getText(); const stanzaSnippet = ""; const expectedText = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); + await editor.typeTextAt(18, 5, stanzaSnippet); await utils.delay(2000); const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); diff --git a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml index d2d5ea81..02ee70d9 100755 --- a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml +++ b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml @@ -13,6 +13,7 @@ jsp-2.3 + mpHealth-4.0 From 13498f5bc360ee109a7382ce676cd46be6e24d4d Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 25 Nov 2024 20:25:36 +0530 Subject: [PATCH 18/40] await added for find element --- 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 ce542fb6..2f963382 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -28,7 +28,7 @@ describe('LCLS Test for Gradle Project', function () { const expectedText = ""; await editor.typeTextAt(18, 5, stanzaSnippet); await utils.delay(2000); - const flaggedString = editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(3000); const actions = VSBrowser.instance.driver.actions(); @@ -36,13 +36,13 @@ describe('LCLS Test for Gradle Project', function () { await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverValue = editor.findElement(By.className('hover-row status-bar')); + const hoverValue = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); await quickFixPopupLink.click(); - const hoverBar = editor.findElement(By.className('context-view monaco-component bottom left fixed')); + const hoverBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); await hoverBar.findElement(By.className('actionList')); await utils.delay(2000); From 499247db752479962ad3f60308fb81894c46adce Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 4 Dec 2024 22:51:03 +0530 Subject: [PATCH 19/40] updated server.xml file --- .../src/main/liberty/config/server.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml index 02ee70d9..d2d5ea81 100755 --- a/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml +++ b/src/test/resources/gradle/liberty.gradle.test.wrapper.app/src/main/liberty/config/server.xml @@ -13,7 +13,6 @@ jsp-2.3 - mpHealth-4.0 From 9c3b83ade48e8d7cfe6ecd2da51522c8a4e4a24a Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 4 Dec 2024 23:06:31 +0530 Subject: [PATCH 20/40] updated - added code for new config folder --- src/test/GradleSingleModLCLSTest.ts | 53 +++++++++++++++++------------ src/test/utils/testUtils.ts | 31 +++++++++++++++++ 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 2f963382..6db333fc 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -17,52 +17,63 @@ const assert = require('assert'); describe('LCLS Test 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')); + }); + 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(18, 5, stanzaSnippet); + const actualSeverXMLContent = await editor.getText(); + const stanzaSnipet = ""; + const expectedHoverData = ""; + await editor.typeTextAt(17, 5, stanzaSnipet); await utils.delay(2000); - const flaggedString = await 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 = 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 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 = await 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.'); + console.log("Content after Quick fix : ", updatedSeverXMLContent); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly.'); await editor.clearText(); - await editor.setText(actualContent); + await editor.setText(actualSeverXMLContent); console.log("Content restored"); }).timeout(38000); + + after(() => { + + utils.removeProjectFolderWithContent(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + console.log("Removed new config folder:"); + + }); }); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index a2a0135b..af60da64 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,34 @@ export async function clearCommandPalette() { expect(buttons.length).equals(2); await dialog.pushButton('Clear'); } + +/** + * Remove newly created Project folder with content + */ +export async function removeProjectFolderWithContent(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 removeProjectFolderWithContent(projectContentPath); + } else { + await fs.unlinkSync(projectContentPath); + } + }) + ); + await fs.rmdirSync(projectPath); + } catch (error) { + console.error(`Error removing new project: ${error}`); + } +} + +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 4d2fa917635272c825f3bdb8146894aec7750030 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 4 Dec 2024 23:22:43 +0530 Subject: [PATCH 21/40] updated the function removeConfigDir --- src/test/GradleSingleModLCLSTest.ts | 2 +- src/test/utils/testUtils.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 6db333fc..2f05a1fc 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -72,7 +72,7 @@ describe('LCLS Test for Gradle Project', function () { after(() => { - utils.removeProjectFolderWithContent(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); }); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index af60da64..dac3e348 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -197,7 +197,7 @@ export async function clearCommandPalette() { /** * Remove newly created Project folder with content */ -export async function removeProjectFolderWithContent(projectPath: string): Promise { +export async function removeConfigDir(projectPath: string): Promise { try { await fs.accessSync(projectPath); const projectContent = await fs.readdirSync(projectPath); @@ -206,7 +206,7 @@ export async function removeProjectFolderWithContent(projectPath: string): Promi const projectContentPath = path.join(projectPath, projectFiles); const stats = await fs.lstatSync(projectContentPath); if (stats.isDirectory()) { - await removeProjectFolderWithContent(projectContentPath); + await removeConfigDir(projectContentPath); } else { await fs.unlinkSync(projectContentPath); } @@ -218,6 +218,9 @@ export async function removeProjectFolderWithContent(projectPath: string): Promi } } +/** + * 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)) From 35150494b28690399be505f46f914b3f03f2b91b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 5 Dec 2024 19:33:34 +0530 Subject: [PATCH 22/40] server.env file added --- src/test/GradleSingleModLCLSTest.ts | 9 ++++----- .../src/main/liberty/config/server.env | 0 2 files changed, 4 insertions(+), 5 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 2f05a1fc..97ea7abe 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -14,14 +14,14 @@ 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; 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 () => { + 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')); @@ -71,9 +71,8 @@ describe('LCLS Test for Gradle Project', function () { }).timeout(38000); 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 From a582ac64ed6c637908c12549af73080eafa8a8ea Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 6 Dec 2024 13:26:41 +0530 Subject: [PATCH 23/40] GHA build failure - Increased timeout value --- src/test/GradleSingleModLCLSTest.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 97ea7abe..9c4a5a67 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,16 +63,17 @@ 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 the invalid value in server.xml.'); await editor.clearText(); await editor.setText(actualSeverXMLContent); + await utils.delay(3000); console.log("Content restored"); }).timeout(38000); - + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); - }); -}); + +}); \ No newline at end of file From b193cc55fd9e5422d9aa8750ba578c1c28294d58 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 6 Dec 2024 15:24:58 +0530 Subject: [PATCH 24/40] Added test case to coppy server.xml content --- src/test/GradleSingleModLCLSTest.ts | 52 ++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 9c4a5a67..b78ec0da 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,13 +77,42 @@ 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); - + + 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); + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 288d1e0e8d45528c0b2c778a3cbfd1da92db5726 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 12:50:14 +0530 Subject: [PATCH 25/40] Diagnostic server.xml test case added --- src/test/GradleSingleModLCLSTest.ts | 65 +++++++++++++++-------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index b78ec0da..0eb64099 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 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 = `'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 hover data Liberty Server Feature.'); + + 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,41 +107,12 @@ 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"); - - }).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); + }).timeout(38000); after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From 4492afc6166d66d52d21028cbe48322d8503014a Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 13:04:44 +0530 Subject: [PATCH 26/40] updated test case --- 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 0eb64099..c5c88730 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -35,7 +35,7 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(10000); - it('Should show hover support for server.xml Liberty Server Feature', async () => { + 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; @@ -57,7 +57,7 @@ describe('LCLS tests for Gradle Project', function () { const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); - assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.'); + assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected diagnostic in server.xml'); editor.clearText(); editor.setText(actualSeverXMLContent); From 45f2c84790cdeeeb1181ce656bd6c9a51ad2bd16 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 9 Dec 2024 20:30:36 +0530 Subject: [PATCH 27/40] changed server.xml path --- 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 c5c88730..89569aed 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'.`; From bf7369b26de711e9dab115860ced72cde64f91e1 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 10:43:01 +0530 Subject: [PATCH 28/40] Diagnostic support for server platform --- src/test/GradleSingleModLCLSTest.ts | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 89569aed..35f7aa7f 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -114,6 +114,38 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(38000); + it('Should show diagnostic for invalid value in server.xml for server platform', 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 = "jakarta"; + const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`; + 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(), '\jakarta\')]")); + 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 platform'); + + 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 1b8f9b21e1de9cc03355abc54a346bb5d17db98b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 10:53:19 +0530 Subject: [PATCH 29/40] Quickfix support test case added for server platform --- src/test/GradleSingleModLCLSTest.ts | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 35f7aa7f..9867007e 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -146,6 +146,56 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(38000); + it('Should apply quick fix for invalid value in server.xml for server platform', 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 = "jakarta"; + const expectedHoverData = "jakartaee-11.0"; + 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(), '\jakarta\')]")); + 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 platform with jakartaee-11.0\")]")); + 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 platform.'); + + 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 4ad15753c99af7dd85897ef34c2b6cf04baf78ab Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 11:08:02 +0530 Subject: [PATCH 30/40] hover support server platform --- src/test/GradleSingleModLCLSTest.ts | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 9867007e..2cd7292d 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -114,6 +114,38 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(38000); + it('Should show hover text in server.xml for server platform', 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 = "jakartaee-11.0"; + const expectedDiagnosticData = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`; + 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(), '\jakarta\')]")); + 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 hover text in server.xml server platform'); + + editor.clearText(); + editor.setText(actualSeverXMLContent); + console.log("Content restored"); + + }).timeout(38000); + it('Should show diagnostic for invalid value in server.xml for server platform', async () => { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); From bc06620989e2086a8666043bd16bc4bc7b7e2739 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 11:20:39 +0530 Subject: [PATCH 31/40] Daiganostic support 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 2cd7292d..7ebe06ba 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -228,6 +228,38 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(38000); + 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); + after(() => { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 145afdd2cc5a16bb568675cc54af03e53197b90a Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 11:24:33 +0530 Subject: [PATCH 32/40] quickfix 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 7ebe06ba..0e9f0b69 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -259,6 +259,56 @@ describe('LCLS tests for Gradle Project', function () { 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')); From bf6f968263d7bbf5bffc421b00a6d731c88dbf00 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 14:58:16 +0530 Subject: [PATCH 33/40] type ahead suppoer server platform --- src/test/GradleSingleModLCLSTest.ts | 45 ++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 0e9f0b69..fe1b8684 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -259,7 +259,7 @@ describe('LCLS tests for Gradle Project', function () { 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(); @@ -310,6 +310,49 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(38000); + it('Should show type ahead support in server.xml Liberty Server platform', 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 = " { utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); From 62a005e0a2c84583ac09d0103331ce2a90b840d7 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:28:59 +0530 Subject: [PATCH 34/40] Test case for valid server feature entry with platform entry --- src/test/GradleSingleModLCLSTest.ts | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index fe1b8684..b468e4b7 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -353,6 +353,49 @@ describe('LCLS tests for Gradle Project', function () { }).timeout(35000); + it('Valid server feature entry with platform entry 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 = "servlet"; + const expectedSnippetFeature = "servlet"; + const expectedSnippetPlatform = "jakartaee-9.1"; + 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); + if(hverValue.includes(expectedDiagnosticData)){ + const stanzaSnipetPlatform = "jakartaee-9.1"; + await editor.typeTextAt(16, 35, '\n'); + await editor.typeTextAt(17, 9, stanzaSnipetPlatform); + await utils.delay(2000); + } + console.log("expected text:" + expectedSnippetFeature); + const updatedServerxmlContent = await editor.getText(); + console.log("expected text:" + updatedServerxmlContent); + + const asrt= assert(updatedServerxmlContent.includes(expectedSnippetFeature) && updatedServerxmlContent.includes(expectedSnippetPlatform), 'Did not get expected diagnostic 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 3ea5a2691c115a847c3bda99a8f0a182bd92fb6b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:33:23 +0530 Subject: [PATCH 35/40] removed unwanted variable --- src/test/GradleSingleModLCLSTest.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index b468e4b7..bed83612 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -121,7 +121,7 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnipet = "jakartaee-11.0"; - const expectedDiagnosticData = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`; + const expectedDiagnosticData = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`; await editor.typeTextAt(15, 35, '\n'); await editor.typeTextAt(16, 9, stanzaSnipet); await utils.delay(2000); @@ -153,7 +153,7 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnipet = "jakarta"; - const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`; + const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`; await editor.typeTextAt(15, 35, '\n'); await editor.typeTextAt(16, 9, stanzaSnipet); await utils.delay(2000); @@ -235,7 +235,7 @@ describe('LCLS tests for Gradle Project', function () { 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`; + 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); @@ -362,7 +362,7 @@ describe('LCLS tests for Gradle Project', function () { const stanzaSnipet = "servlet"; const expectedSnippetFeature = "servlet"; const expectedSnippetPlatform = "jakartaee-9.1"; - 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`; + 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); @@ -378,7 +378,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); - if(hverValue.includes(expectedDiagnosticData)){ + if (hverValue.includes(expectedDiagnosticData)) { const stanzaSnipetPlatform = "jakartaee-9.1"; await editor.typeTextAt(16, 35, '\n'); await editor.typeTextAt(17, 9, stanzaSnipetPlatform); @@ -388,8 +388,8 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); console.log("expected text:" + updatedServerxmlContent); - const asrt= assert(updatedServerxmlContent.includes(expectedSnippetFeature) && updatedServerxmlContent.includes(expectedSnippetPlatform), 'Did not get expected diagnostic in server.xml server feature'); - + assert(updatedServerxmlContent.includes(expectedSnippetFeature) && updatedServerxmlContent.includes(expectedSnippetPlatform), 'Did not get expected diagnostic in server.xml server feature'); + editor.clearText(); editor.setText(actualSeverXMLContent); console.log("Content restored"); From bd658a3a5430e629ec9b662a37fa67ccab8ca7a3 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:35:38 +0530 Subject: [PATCH 36/40] updated text for the false case --- src/test/GradleSingleModLCLSTest.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index bed83612..08836913 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -360,8 +360,8 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnipet = "servlet"; - const expectedSnippetFeature = "servlet"; - const expectedSnippetPlatform = "jakartaee-9.1"; + const expectedFeatureEntry = "servlet"; + const expectedPlatformEntry = "jakartaee-9.1"; 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); @@ -384,11 +384,10 @@ describe('LCLS tests for Gradle Project', function () { await editor.typeTextAt(17, 9, stanzaSnipetPlatform); await utils.delay(2000); } - console.log("expected text:" + expectedSnippetFeature); const updatedServerxmlContent = await editor.getText(); console.log("expected text:" + updatedServerxmlContent); - assert(updatedServerxmlContent.includes(expectedSnippetFeature) && updatedServerxmlContent.includes(expectedSnippetPlatform), 'Did not get expected diagnostic in server.xml server feature'); + assert(updatedServerxmlContent.includes(expectedFeatureEntry) && updatedServerxmlContent.includes(expectedPlatformEntry), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); editor.clearText(); editor.setText(actualSeverXMLContent); From 448672be06b47575ea47e6d65420c896fca749f1 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:36:37 +0530 Subject: [PATCH 37/40] removed unwanted variable --- src/test/GradleSingleModLCLSTest.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 08836913..2b4745fb 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -360,7 +360,6 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor('server.xml') as TextEditor; const stanzaSnipet = "servlet"; - const expectedFeatureEntry = "servlet"; const expectedPlatformEntry = "jakartaee-9.1"; 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'); @@ -387,7 +386,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); console.log("expected text:" + updatedServerxmlContent); - assert(updatedServerxmlContent.includes(expectedFeatureEntry) && updatedServerxmlContent.includes(expectedPlatformEntry), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); + assert(updatedServerxmlContent.includes(stanzaSnipet) && updatedServerxmlContent.includes(expectedPlatformEntry), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); editor.clearText(); editor.setText(actualSeverXMLContent); From 67d39c574d494a97c2b36fd6e8fa67790065e81c Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:39:07 +0530 Subject: [PATCH 38/40] updated wordings --- 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 2b4745fb..ac1263f4 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -384,7 +384,7 @@ describe('LCLS tests for Gradle Project', function () { await utils.delay(2000); } const updatedServerxmlContent = await editor.getText(); - console.log("expected text:" + updatedServerxmlContent); + console.log("Updated server.xml content:" + updatedServerxmlContent); assert(updatedServerxmlContent.includes(stanzaSnipet) && updatedServerxmlContent.includes(expectedPlatformEntry), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); From 07faf049b9069306963c236c00cf46b55544a608 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 18:49:10 +0530 Subject: [PATCH 39/40] removed unwanted code --- src/test/GradleSingleModLCLSTest.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index ac1263f4..2d853897 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -359,11 +359,11 @@ 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 stanzaSnipet = "servlet"; - const expectedPlatformEntry = "jakartaee-9.1"; + const stanzaSnipetFeature = "servlet"; + const stanzaSnipetPlatform = "jakartaee-9.1"; 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 editor.typeTextAt(16, 9, stanzaSnipetFeature); await utils.delay(2000); const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); await utils.delay(3000); @@ -378,7 +378,6 @@ describe('LCLS tests for Gradle Project', function () { const hverValue = await hverContent.getText(); console.log("Hover text:" + hverValue); if (hverValue.includes(expectedDiagnosticData)) { - const stanzaSnipetPlatform = "jakartaee-9.1"; await editor.typeTextAt(16, 35, '\n'); await editor.typeTextAt(17, 9, stanzaSnipetPlatform); await utils.delay(2000); @@ -386,7 +385,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); console.log("Updated server.xml content:" + updatedServerxmlContent); - assert(updatedServerxmlContent.includes(stanzaSnipet) && updatedServerxmlContent.includes(expectedPlatformEntry), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); + assert(updatedServerxmlContent.includes(stanzaSnipetFeature) && updatedServerxmlContent.includes(stanzaSnipetPlatform), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); editor.clearText(); editor.setText(actualSeverXMLContent); From 4a91deecfc3128a39b3db93d7c0096bf1e895f93 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 16 Dec 2024 19:07:23 +0530 Subject: [PATCH 40/40] GHA build fix - timeout value updated --- 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 2d853897..e3e66d03 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -33,7 +33,7 @@ describe('LCLS tests for Gradle Project', function () { assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in coppied.'); console.log('Sever.xml content:', actualSeverXMLContent); - }).timeout(10000); + }).timeout(15000); it('Should show diagnostic for server.xml invalid value', async () => {