From 08aefcd64a7e9b6385bece3c0449365630a1d722 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 12 Nov 2024 23:01:34 +0530 Subject: [PATCH 01/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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/54] 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 () => { From 3452b27e14b3fde5c65fc0d5060f3385d60cddfd Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Fri, 17 Jan 2025 16:34:09 +0530 Subject: [PATCH 41/54] updated typo error and year info --- 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 e3e66d03..ffa678ec 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(15000); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index dac3e348..766edb55 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -199,20 +199,20 @@ export async function clearCommandPalette() { */ export async function removeConfigDir(projectPath: string): Promise { try { - await fs.accessSync(projectPath); - const projectContent = await fs.readdirSync(projectPath); + fs.accessSync(projectPath); + const projectContent = fs.readdirSync(projectPath); await Promise.all( projectContent.map(async (projectFiles) => { const projectContentPath = path.join(projectPath, projectFiles); - const stats = await fs.lstatSync(projectContentPath); + const stats = fs.lstatSync(projectContentPath); if (stats.isDirectory()) { await removeConfigDir(projectContentPath); } else { - await fs.unlinkSync(projectContentPath); + fs.unlinkSync(projectContentPath); } }) ); - await fs.rmdirSync(projectPath); + fs.rmdirSync(projectPath); } catch (error) { console.error(`Error removing new project: ${error}`); } From e7d4d235e1424d02f1a5f70feba2dc3a5d5f48b0 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 22:56:00 +0530 Subject: [PATCH 42/54] updated testUtils --- src/test/utils/testUtils.ts | 41 ++++--------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 766edb55..0e5f6a33 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -1,11 +1,10 @@ import path = require('path'); import { Workbench, InputBox, DefaultTreeItem, ModalDialog } from 'vscode-extension-tester'; import * as fs from 'fs'; -import { MAVEN_PROJECT, STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; +import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; import { MapContextMenuforMac } from './macUtils'; import clipboard = require('clipboardy'); import { expect } from 'chai'; -import * as fse from 'fs-extra'; export function delay(millisec: number) { return new Promise( resolve => setTimeout(resolve, millisec) ); @@ -169,13 +168,13 @@ export function getMvnProjectPath(): string { /* Stop Server Liberty dashboard post Attach Debugger*/ /* As the Window view changes using command to stop server instead of devmode action */ -export async function stopLibertyserver() { - console.log("Stop Server action for MAVEN_PROJECT : " + MAVEN_PROJECT); +export async function stopLibertyserver(projectName: string) { + console.log("Stop Server action for Project : " + projectName); const workbench = new Workbench(); await workbench.executeCommand(STOP_DASHBOARD_MAC_ACTION); const input = InputBox.create(); (await input).clear(); - (await input).setText(MAVEN_PROJECT); + (await input).setText(projectName); (await input).confirm(); (await input).click(); await delay(10000); @@ -194,36 +193,4 @@ export async function clearCommandPalette() { await dialog.pushButton('Clear'); } -/** - * Remove newly created Project folder with content - */ -export async function removeConfigDir(projectPath: string): Promise { - try { - fs.accessSync(projectPath); - const projectContent = fs.readdirSync(projectPath); - await Promise.all( - projectContent.map(async (projectFiles) => { - const projectContentPath = path.join(projectPath, projectFiles); - const stats = fs.lstatSync(projectContentPath); - if (stats.isDirectory()) { - await removeConfigDir(projectContentPath); - } else { - fs.unlinkSync(projectContentPath); - } - }) - ); - fs.rmdirSync(projectPath); - } catch (error) { - console.error(`Error removing new project: ${error}`); - } -} - -/** - * Copy config directory and create new config - */ -export async function copyConfig(existingConfigPath: string, copyConfigPath: string): Promise { - fse.copy(existingConfigPath, copyConfigPath) - .then(() => console.log("New config folder created :" + copyConfigPath)) - .catch(err => console.log("Error creating config folder")); -} \ No newline at end of file From 929473319223931c44bf4bf72831c16b147b495f Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 22:57:30 +0530 Subject: [PATCH 43/54] resolved conflic for testUtils --- src/test/utils/testUtils.ts | 57 ++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 0e5f6a33..2b9e81a9 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -1,10 +1,11 @@ import path = require('path'); -import { Workbench, InputBox, DefaultTreeItem, ModalDialog } from 'vscode-extension-tester'; +import { Workbench, InputBox, DefaultTreeItem, ModalDialog, SideBarView, VSBrowser, TextEditor } from 'vscode-extension-tester'; import * as fs from 'fs'; -import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants'; +import * as constants from '../definitions/constants'; import { MapContextMenuforMac } from './macUtils'; import clipboard = require('clipboardy'); import { expect } from 'chai'; +import * as fse from 'fs-extra'; export function delay(millisec: number) { return new Promise( resolve => setTimeout(resolve, millisec) ); @@ -171,7 +172,7 @@ export function getMvnProjectPath(): string { export async function stopLibertyserver(projectName: string) { console.log("Stop Server action for Project : " + projectName); const workbench = new Workbench(); - await workbench.executeCommand(STOP_DASHBOARD_MAC_ACTION); + await workbench.executeCommand(constants.STOP_DASHBOARD_MAC_ACTION); const input = InputBox.create(); (await input).clear(); (await input).setText(projectName); @@ -193,4 +194,52 @@ export async function clearCommandPalette() { await dialog.pushButton('Clear'); } - \ No newline at end of file +/** + * Remove specific directory + */ +export async function removeDirectoryByPath(projectPath: string): Promise { + try { + fs.accessSync(projectPath); + const projectContent = fs.readdirSync(projectPath); + await Promise.all( + projectContent.map(async (projectFiles) => { + const projectContentPath = path.join(projectPath, projectFiles); + const stats = fs.lstatSync(projectContentPath); + if (stats.isDirectory()) { + await removeDirectoryByPath(projectContentPath); + } else { + fs.unlinkSync(projectContentPath); + } + }) + ); + fs.rmdirSync(projectPath); + } catch (error) { + console.error(`Error removing new project: ${error}`); + } +} + +/** + * Copy a specific directory + */ +export async function copyDirectoryByPath(existingConfigPath: string, copyConfigPath: string): Promise { + fse.copy(existingConfigPath, copyConfigPath) + .then(() => console.log("New config folder created :" + copyConfigPath)) + .catch(err => console.log("Error creating config folder")); +} +/** + * Open config files from specified parent directory + */ +export async function openConfigFile(parentDir: string, configFileName: string) { + const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); + section.expand(); + await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); +} + +export async function callAssitantAction(editor: TextEditor, selectValue: string) { + let assist = await editor.toggleContentAssist(true); + // toggle can return void, so we need to make sure the object is present + if (assist) { + // to select an item use + await assist.select(selectValue); + } +} \ No newline at end of file From f91628fd8c56a06db29aedc55ba8f5e013a8c7f4 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 22:58:42 +0530 Subject: [PATCH 44/54] updated constants --- src/test/definitions/constants.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index d421e824..e6a7fe1f 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -1,3 +1,4 @@ + /** * Copyright (c) 2020, 2022 IBM Corporation. * @@ -40,3 +41,8 @@ export const ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION = "Liberty: Attach debugger"; export const MAVEN_DEVMODE_DEBUG_PORT_PARM = "-DdebugPort"; /** Gradle: Dev mode debug port argument key. */ export const GRADLE_DEVMODE_DEBUG_PORT_PARM = "--libertyDebugPort"; +export const CONFIG = "config"; +export const CONFIG_TWO = "config2"; +export const BOOTSTRAP_PROPERTIES = "bootstrap.properties"; +export const SERVER_XML = "server.xml"; +export const SERVER_ENV = "server.env"; \ No newline at end of file From 525ce4ea350dc92fb7c5e2b9bc3e8ac85c01e850 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 23:39:45 +0530 Subject: [PATCH 45/54] updated - variable names and time delay --- src/test/GradleSingleModLCLSTest.ts | 320 +++++++++++++--------------- 1 file changed, 145 insertions(+), 175 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index ffa678ec..18340b9f 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -import { By, EditorView, SideBarView, TextEditor, VSBrowser } from "vscode-extension-tester"; +import { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester"; import * as utils from './utils/testUtils'; import * as constants from './definitions/constants'; @@ -16,81 +16,75 @@ const assert = require('assert'); describe('LCLS tests for Gradle Project', function () { let editor: TextEditor; - let actualSeverXMLContent: string; + let actualServerXMLContent: string; before(() => { - utils.copyConfig(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); }); it('Should copy content of server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - actualSeverXMLContent = await editor.getText(); + actualServerXMLContent = await editor.getText(); - assert(actualSeverXMLContent.length !== 0, 'Content of server.xml is not in copied.'); - console.log('Sever.xml content:', actualSeverXMLContent); + assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); + console.log('Sever.xml content is:', actualServerXMLContent); - }).timeout(15000); + }).timeout(25000); it('Should show diagnostic for server.xml invalid value', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - editor = await new EditorView().openEditor('server.xml') as TextEditor; + const expectedOutcomeValue = `'wrong' is not a valid value of union type 'booleanType'.`; + const hoverTargetValue = ''; - 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 editor.typeTextAt(17, 5, hoverTargetValue); + const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverFoundOutcome = await hoverContents.getText(); + console.log("Hover text is:" + hoverFoundOutcome); - assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected diagnostic in server.xml'); + assert(hoverFoundOutcome.includes(expectedOutcomeValue), 'Did not get expected diagnostic in server.xml'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).timeout(35000); it('Should apply quick fix for invalid value in server.xml', async () => { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); - - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = ""; - const expectedHoverData = ""; - await editor.typeTextAt(17, 5, stanzaSnipet); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; + + const stanzaSnippet = ""; + const hoverExpectedSnippet = ""; + await editor.typeTextAt(17, 5, stanzaSnippet); await utils.delay(2000); - const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const hoverTargetValue = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); await utils.delay(7000); - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flagedString }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: hoverTargetValue }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await qckFixPopupLink.click(); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await quickFixPopupLink.click(); - const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); - await hoverTaskBar.findElement(By.className('actionList')); + const hoverWindowTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); + await hoverWindowTaskBar.findElement(By.className('actionList')); await utils.delay(2000); const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock')); @@ -98,110 +92,104 @@ describe('LCLS tests for Gradle Project', function () { if (pointerBlockedElement) { await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); } else { - console.log('pointerBlockElementt not found!'); + console.log('pointerBlockElement is not found!'); } - const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); - await qckfixOption.click(); + const quickfixOptionValues = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + await quickfixOptionValues.click(); const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); - console.log("Content after Quick fix : ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml.'); + console.log("Content after Quick fix is: ", updatedSeverXMLContent); + assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); }).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')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "jakartaee-11.0"; + const stanzaSnippet = "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 editor.typeTextAt(16, 9, stanzaSnippet); await utils.delay(2000); - const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); + const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text is:" + hoverValue); - assert(hverValue.includes(expectedDiagnosticData), 'Did not get expected hover text in server.xml server platform'); + assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected hover text in server.xml server platform'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("Content is 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(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "jakarta"; + const stanzaSnippet = "jakarta"; const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`; await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnipet); + await editor.typeTextAt(16, 9, stanzaSnippet); await utils.delay(2000); - const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); + const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); - assert(hverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server platform'); + assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server platform'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("Content is restored"); }).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')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; const 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\')]")); + const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); await utils.delay(7000); - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flagedString }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: flaggedString }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await qckFixPopupLink.click(); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await quickFixPopupLink.click(); const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); await hoverTaskBar.findElement(By.className('actionList')); @@ -212,10 +200,10 @@ describe('LCLS tests for Gradle Project', function () { if (pointerBlockedElement) { await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); } else { - console.log('pointerBlockElementt not found!'); + console.log('PointerBlockedElement is not found!'); } - const qckfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace platform with jakartaee-11.0\")]")); - await qckfixOption.click(); + const quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace platform with jakartaee-11.0\")]")); + await quickfixOption.click(); const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); @@ -223,67 +211,63 @@ describe('LCLS tests for Gradle Project', function () { 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"); + editor.setText(actualServerXMLContent); + console.log("Content is restored"); }).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')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "servlet"; + const stanzaSnippet = "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 editor.typeTextAt(16, 9, stanzaSnippet); await utils.delay(2000); - const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); - assert(hverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature'); + assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("Content is 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')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipet = "servlet"; + const stanzaSnippet = "servlet"; const expectedHoverData = "servlet-3.1"; await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnipet); + await editor.typeTextAt(16, 9, stanzaSnippet); await utils.delay(2000); - const flagedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); await utils.delay(7000); - const actions = VSBrowser.instance.driver.actions(); - await actions.move({ origin: flagedString }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: flaggedString }).perform(); await utils.delay(3000); const driver = VSBrowser.instance.driver; - const hoverTxt = await editor.findElement(By.className('hover-row status-bar')); + const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const qckFixPopupLink = await hoverTxt.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); - await qckFixPopupLink.click(); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + await quickFixPopupLink.click(); const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); await hoverTaskBar.findElement(By.className('actionList')); @@ -296,105 +280,91 @@ describe('LCLS tests for Gradle Project', function () { } 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 quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace feature with servlet-3.1\")]")); + await quickfixOption.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.'); + console.log("Content after Quick fix is: ", updatedSeverXMLContent); + assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix is not applied correctly for the invalid value in server.xml server feature.'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("Content is restored"); }).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')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; const featureTag = " { - const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); - section.expand(); - await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml')); + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - editor = await new EditorView().openEditor('server.xml') as TextEditor; - const stanzaSnipetFeature = "servlet"; - const stanzaSnipetPlatform = "jakartaee-9.1"; + const stanzaSnippetFeature = "servlet"; + const stanzaSnippetPlatform = "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, stanzaSnipetFeature); + await editor.typeTextAt(16, 9, stanzaSnippetFeature); await utils.delay(2000); - const focusTargtElemnt = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); await utils.delay(3000); - focusTargtElemnt.click(); + focusTargetedElement.click(); await editor.click(); - const actns = VSBrowser.instance.driver.actions(); - await actns.move({ origin: focusTargtElemnt }).perform(); + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); await utils.delay(5000); - const hverContent = editor.findElement(By.className('hover-contents')); - const hverValue = await hverContent.getText(); - console.log("Hover text:" + hverValue); - if (hverValue.includes(expectedDiagnosticData)) { + const holverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await holverContents.getText(); + console.log("Hover text is:" + hoverValue); + if (hoverValue.includes(expectedDiagnosticData)) { await editor.typeTextAt(16, 35, '\n'); - await editor.typeTextAt(17, 9, stanzaSnipetPlatform); + await editor.typeTextAt(17, 9, stanzaSnippetPlatform); await utils.delay(2000); } const updatedServerxmlContent = await editor.getText(); - console.log("Updated server.xml content:" + updatedServerxmlContent); + console.log("Updated server.xml content is:" + updatedServerxmlContent); - assert(updatedServerxmlContent.includes(stanzaSnipetFeature) && updatedServerxmlContent.includes(stanzaSnipetPlatform), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); + assert(updatedServerxmlContent.includes(stanzaSnippetFeature) && updatedServerxmlContent.includes(stanzaSnippetPlatform), 'Did not get expected entries in server.xml for versionless combination for server feature and platform'); editor.clearText(); - editor.setText(actualSeverXMLContent); - console.log("Content restored"); + editor.setText(actualServerXMLContent); + console.log("Content is restored"); }).timeout(38000); after(() => { - utils.removeConfigDir(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); + utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); console.log("Removed new config folder:"); }); From 3ebd4afb52ce034437f5fc2ee555209e862e7f62 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 23:50:01 +0530 Subject: [PATCH 46/54] description added for new methods --- src/test/utils/testUtils.ts | 47 ++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 2b9e81a9..9fab361f 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -195,15 +195,17 @@ export async function clearCommandPalette() { } /** - * Remove specific directory + * + * @param projectPath + * Remove specific directory with contents */ -export async function removeDirectoryByPath(projectPath: string): Promise { +export async function removeDirectoryByPath(dirPath: string): Promise { try { - fs.accessSync(projectPath); - const projectContent = fs.readdirSync(projectPath); + fs.accessSync(dirPath); + const dirContent = fs.readdirSync(dirPath); await Promise.all( - projectContent.map(async (projectFiles) => { - const projectContentPath = path.join(projectPath, projectFiles); + dirContent.map(async (dirFiles) => { + const projectContentPath = path.join(dirPath, dirFiles); const stats = fs.lstatSync(projectContentPath); if (stats.isDirectory()) { await removeDirectoryByPath(projectContentPath); @@ -212,22 +214,29 @@ export async function removeDirectoryByPath(projectPath: string): Promise } }) ); - fs.rmdirSync(projectPath); + fs.rmdirSync(dirPath); } catch (error) { - console.error(`Error removing new project: ${error}`); + console.error(`Error removing directory: ${error}`); } } /** - * Copy a specific directory + * + * @param existingConfigPath + * @param copyConfigPath + * Copy a specific directory */ -export async function copyDirectoryByPath(existingConfigPath: string, copyConfigPath: string): Promise { - fse.copy(existingConfigPath, copyConfigPath) - .then(() => console.log("New config folder created :" + copyConfigPath)) - .catch(err => console.log("Error creating config folder")); +export async function copyDirectoryByPath(existingDirPath: string, copyDirPath: string): Promise { + fse.copy(existingDirPath, copyDirPath) + .then(() => console.log("Folder content copied :" + copyDirPath)) + .catch(err => console.log("Error occuried while copying content")); } + /** - * Open config files from specified parent directory + * + * @param parentDir + * @param configFileName + * Open specific config file from parent directory */ export async function openConfigFile(parentDir: string, configFileName: string) { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); @@ -235,11 +244,17 @@ export async function openConfigFile(parentDir: string, configFileName: string) await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); } +/** + * + * @param editor + * @param selectValue + * Function to call toggle assistant to select value from suggestion list + */ export async function callAssitantAction(editor: TextEditor, selectValue: string) { let assist = await editor.toggleContentAssist(true); // toggle can return void, so we need to make sure the object is present if (assist) { - // to select an item use - await assist.select(selectValue); + // to select an item use + await assist.select(selectValue); } } \ No newline at end of file From f48a5baf12d2e5ec9e0e9d5d2c4115ae1eb7c0c8 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Mon, 27 Jan 2025 23:51:24 +0530 Subject: [PATCH 47/54] time delay updated --- 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 18340b9f..1b0583fc 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -27,7 +27,6 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; actualServerXMLContent = await editor.getText(); - assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); console.log('Sever.xml content is:', actualServerXMLContent); @@ -59,7 +58,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - }).timeout(35000); + }).timeout(38000); it('Should apply quick fix for invalid value in server.xml', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) From 7bdc0ca04b8fcc71640e4963baa8f4793b609dd4 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 14:22:21 +0530 Subject: [PATCH 48/54] moved hardcoded values to constant file --- src/test/GradleSingleModLCLSTest.ts | 221 ++++++++++++++++++++-------- src/test/definitions/constants.ts | 44 +++++- src/test/utils/testUtils.ts | 19 +++ 3 files changed, 217 insertions(+), 67 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 1b0583fc..54ba936a 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -30,16 +30,13 @@ describe('LCLS tests for Gradle Project', function () { assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); console.log('Sever.xml content is:', actualServerXMLContent); - }).timeout(25000); + }).timeout(30000); it('Should show diagnostic for server.xml invalid value', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); - const expectedOutcomeValue = `'wrong' is not a valid value of union type 'booleanType'.`; - const hoverTargetValue = ''; - - await editor.typeTextAt(17, 5, hoverTargetValue); - const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]")); + await editor.typeTextAt(17, 5, constants.TARGETED_VALUE_LOGGING); + const focusTargetedElement = editor.findElement(By.xpath(constants.FOCUS_WRONG)); await utils.delay(3000); focusTargetedElement.click(); await editor.click(); @@ -52,11 +49,12 @@ describe('LCLS tests for Gradle Project', function () { const hoverFoundOutcome = await hoverContents.getText(); console.log("Hover text is:" + hoverFoundOutcome); - assert(hoverFoundOutcome.includes(expectedOutcomeValue), 'Did not get expected diagnostic in server.xml'); + assert(hoverFoundOutcome.includes(constants.EXPECTED_OUTCOME_WRONG), 'Did not get expected diagnostic in server.xml'); editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(38000); @@ -64,11 +62,9 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = ""; - const hoverExpectedSnippet = ""; - await editor.typeTextAt(17, 5, stanzaSnippet); + await editor.typeTextAt(17, 5, constants.TARGETED_VALUE_LOGGING); await utils.delay(2000); - const hoverTargetValue = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]")); + const hoverTargetValue = await editor.findElement(By.xpath(constants.FOCUS_WRONG)); await utils.delay(7000); const driverActionList = VSBrowser.instance.driver.actions(); @@ -79,7 +75,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath(constants.FOCUS_QUICKFIX)); await quickFixPopupLink.click(); const hoverWindowTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); @@ -93,30 +89,138 @@ describe('LCLS tests for Gradle Project', function () { } else { console.log('pointerBlockElement is not found!'); } - const quickfixOptionValues = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]")); + const quickfixOptionValues = await editor.findElement(By.xpath(constants.LOGGING_TRUE)); await quickfixOptionValues.click(); const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix is: ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.'); + assert(updatedSeverXMLContent.includes(constants.SNIPPET_LOGGING), 'Quick fix is not applied correctly for the invalid value in server.xml.'); editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); + await utils.closeEditor(constants.SERVER_XML); - }).timeout(38000); + }).timeout(45000); + + it('Should show hover support for server.xml Liberty Server Attribute', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + + const focusTargetedElement = editor.findElement(By.xpath(constants.FOCUS_HTTPENDPOINT)); + await utils.delay(3000); + focusTargetedElement.click(); + await editor.click(); + + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetedElement }).perform(); + await utils.delay(5000); + + const hoverContent = editor.findElement(By.className('hover-contents')); + const hoveredTextValue = await hoverContent.getText(); + console.log("Hover text is: " + hoveredTextValue); + + assert(hoveredTextValue.includes(constants.DESCRIPTION_HTTPENDPOINT), 'Did not get expected hover data Liberty for Server Attribute.'); + + editor.clearText(); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); + await utils.closeEditor(constants.SERVER_XML); + + }).timeout(45000); + + it('Should show hover support for server.xml Liberty Server Feature', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + + await editor.typeTextAt(15, 35, constants.NEWLINE); + await utils.delay(1000); + await editor.typeTextAt(16, 9, constants.FEATURE_MPHEALTH); + const focusTargetElement = editor.findElement(By.xpath(constants.FOCUS_MPHEALTH)); + await utils.delay(3000); + focusTargetElement.click(); + await editor.click(); + + const driverActionList = VSBrowser.instance.driver.actions(); + await driverActionList.move({ origin: focusTargetElement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoveredValue = await hoverContents.getText(); + console.log("Hover text is :" + hoveredValue); + + assert(hoveredValue.includes(constants.DESCRIPTION_MPHEALTH), 'Did not get expected hover data for Liberty Server Feature.'); + + editor.clearText(); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); + await utils.closeEditor(constants.SERVER_XML); + + }).timeout(45000); + + it('Should show type ahead support in server.xml Liberty Server Feature', async () => { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; + + const featureTag = " { + await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + + editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; + const stanzaSnippet = "log"; + + await editor.typeTextAt(17, 5, stanzaSnippet); + await utils.delay(5000); + //open the assistant + await utils.callAssitantAction(editor, constants.LOGGING) + + // close the assistant + await editor.toggleContentAssist(false); + + const updatedServerxmlContent = await editor.getText(); + await utils.delay(3000); + console.log("Updated content in Sever.xml : ", updatedServerxmlContent); + assert(updatedServerxmlContent.includes(constants.LOGGING_TAG), 'Type ahead support is not worked as expected in server.xml for Liberty Server Configuration Stanza'); + + editor.clearText(); + editor.setText(actualServerXMLContent); + console.log("server.xml content is restored"); + await utils.closeEditor(constants.SERVER_XML); + + }).timeout(45000); it('Should show hover text in server.xml for server platform', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = "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, stanzaSnippet); + await editor.typeTextAt(15, 35, constants.NEWLINE); + await editor.typeTextAt(16, 9, constants.PLATFORM_JAKARTA_VALUE); await utils.delay(2000); - const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); + const focusTargetedElement = await editor.findElement(By.xpath(constants.FOCUS_JAKARTA)); await utils.delay(3000); focusTargetedElement.click(); await editor.click(); @@ -129,7 +233,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected hover text in server.xml server platform'); + assert(hoverValue.includes(constants.DESCRIPTION_PLATFORM), 'Did not get expected hover text in server.xml server platform'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -141,12 +245,10 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = "jakarta"; - const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`; await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnippet); + await editor.typeTextAt(16, 9, constants.PLATFORM_JAKARTA); await utils.delay(2000); - const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); + const focusTargetedElement = await editor.findElement(By.xpath(constants.FOCUS_JAKARTA)); await utils.delay(3000); focusTargetedElement.click(); await editor.click(); @@ -159,7 +261,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text:" + hoverValue); - assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server platform'); + assert(hoverValue.includes(constants.PLATFORM_JAKARTA_ERROR), 'Did not get expected diagnostic in server.xml server platform'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -171,12 +273,10 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.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 editor.typeTextAt(15, 35, constants.NEWLINE); + await editor.typeTextAt(16, 9, constants.PLATFORM_JAKARTA); await utils.delay(2000); - const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]")); + const flaggedString = await editor.findElement(By.xpath(constants.FOCUS_JAKARTA)); await utils.delay(7000); const driverActionList = VSBrowser.instance.driver.actions(); @@ -187,7 +287,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath(constants.FOCUS_QUICKFIX)); await quickFixPopupLink.click(); const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); @@ -201,13 +301,13 @@ describe('LCLS tests for Gradle Project', function () { } else { console.log('PointerBlockedElement is not found!'); } - const quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace platform with jakartaee-11.0\")]")); + const quickfixOption = await editor.findElement(By.xpath(constants.JAKARTA_ELEVEN)); await quickfixOption.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.'); + assert(updatedSeverXMLContent.includes(constants.PLATFORM_JAKARTA_VALUE), 'Quick fix not applied correctly for the invalid value in server.xml server platform.'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -219,12 +319,10 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = "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, stanzaSnippet); + await editor.typeTextAt(15, 35, constants.NEWLINE); + await editor.typeTextAt(16, 9, constants.FEATURE_SERVLET); await utils.delay(2000); - const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + const focusTargetedElement = await editor.findElement(By.xpath(constants.FOCUS_SERVLET)); await utils.delay(3000); focusTargetedElement.click(); await editor.click(); @@ -237,7 +335,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text:" + hoverValue); - assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature'); + assert(hoverValue.includes(constants.SERVLET_ERROR), 'Did not get expected diagnostic in server.xml server feature'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -249,12 +347,11 @@ describe('LCLS tests for Gradle Project', function () { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - const stanzaSnippet = "servlet"; - const expectedHoverData = "servlet-3.1"; - await editor.typeTextAt(15, 35, '\n'); - await editor.typeTextAt(16, 9, stanzaSnippet); + + await editor.typeTextAt(15, 35, constants.NEWLINE); + await editor.typeTextAt(16, 9, constants.FEATURE_SERVLET); await utils.delay(2000); - const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]")); + const flaggedString = await editor.findElement(By.xpath(constants.FOCUS_SERVLET)); await utils.delay(7000); const driverActionList = VSBrowser.instance.driver.actions(); @@ -265,7 +362,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); + const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath(constants.FOCUS_QUICKFIX)); await quickFixPopupLink.click(); const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed')); @@ -277,15 +374,15 @@ describe('LCLS tests for Gradle Project', function () { if (pointerBlockedElement) { await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement); } else { - console.log('pointerBlockElementt not found!'); + console.log('PointerBlockElement is not found!'); } - const quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace feature with servlet-3.1\")]")); + const quickfixOption = await editor.findElement(By.xpath(constants.FOCUS_SERVLET_VALUE)); await quickfixOption.click(); const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix is: ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix is not applied correctly for the invalid value in server.xml server feature.'); + assert(updatedSeverXMLContent.includes(constants.SERVLET_VALUE), 'Quick fix is not applied correctly for the invalid value in server.xml server feature.'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -298,11 +395,10 @@ describe('LCLS tests for Gradle Project', function () { editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; const featureTag = ""; +export const FOCUS_QUICKFIX = "//*[contains(text(), 'Quick Fix')]"; +export const LOGGING_TRUE = "//*[contains(text(), \"Replace with 'true'\")]"; +export const FOCUS_HTTPENDPOINT = "//*[contains(text(), 'httpEndpoint')]"; +export const FOCUS_MPHEALTH = "//*[contains(text(), 'mpHealth')]"; +export const FEATURE_MPHEALTH = 'mpHealth-4.0'; +export const NEWLINE = '\n'; +export const DESCRIPTION_MPHEALTH = "Description: This feature provides support for the MicroProfile Health specification."; +export const DESCRIPTION_HTTPENDPOINT = `Configuration properties for an HTTP endpoint.`; +export const FEATURE_EL = "el-3.0"; +export const LOGGING_TAG = ""; +export const LOGGING = 'logging'; +export const FEATURE_TAG = 'feature'; +export const EL_VALUE = 'el-3.0'; +export const PLATFORM_JAKARTA_VALUE = "jakartaee-11.0"; +export const DESCRIPTION_PLATFORM = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`; +export const FOCUS_JAKARTA = "//*[contains(text(), '\jakarta\')]"; +export const PLATFORM_JAKARTA = "jakarta"; +export const PLATFORM_JAKARTA_ERROR = `ERROR: The platform "jakarta" does not exist.`; +export const FOCUS_JAKARTA_ELEVEN= "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; +export const FEATURE_SERVLET = "servlet"; +export const SERVLET_ERROR = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`; +export const FOCUS_SERVLET ="//*[contains(text(), '\servlet\')]"; +export const SERVLET_VALUE= "servlet-3.1"; +export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with servlet-3.1\")]"; +export const PLATFORM ="platform"; +export const JAKARTA_ELEVEN ='jakartaee-11.0'; +export const PLATFORM_JAKARTA_NINE= "jakartaee-9.1"; \ No newline at end of file diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index 9fab361f..21639750 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -244,6 +244,25 @@ export async function openConfigFile(parentDir: string, configFileName: string) await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); } +/** + * Function to close currently opened config file tab + */ +export async function closeEditor(fileType: string) { + const workbench = new Workbench(); + await workbench.openCommandPrompt(); + await delay(3000); + await workbench.executeCommand(constants.CLOSE_EDITOR); + await delay(3000); + const dialog = new ModalDialog(); + const message = await dialog.getMessage(); + + if (fileType in constants.CONFIRM_MESSAGES) { + expect(message).contains(constants.CONFIRM_MESSAGES[fileType as keyof typeof constants.CONFIRM_MESSAGES]); + } + const buttons = await dialog.getButtons(); + expect(buttons.length).equals(3); + await dialog.pushButton('Don\'t Save'); +} /** * * @param editor From 81cc6a1b01a77f4118bdb693ac514273dfd3f33f Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 14:31:31 +0530 Subject: [PATCH 49/54] time delay updated --- src/test/GradleSingleModLCLSTest.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 54ba936a..8f02f21e 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -239,13 +239,13 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Should show diagnostic for invalid value in server.xml for server platform', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; - await editor.typeTextAt(15, 35, '\n'); + await editor.typeTextAt(15, 35, constants.NEWLINE); await editor.typeTextAt(16, 9, constants.PLATFORM_JAKARTA); await utils.delay(2000); const focusTargetedElement = await editor.findElement(By.xpath(constants.FOCUS_JAKARTA)); @@ -259,7 +259,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverContents = editor.findElement(By.className('hover-contents')); const hoverValue = await hoverContents.getText(); - console.log("Hover text:" + hoverValue); + console.log("Hover text is:" + hoverValue); assert(hoverValue.includes(constants.PLATFORM_JAKARTA_ERROR), 'Did not get expected diagnostic in server.xml server platform'); @@ -267,7 +267,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Should apply quick fix for invalid value in server.xml for server platform', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) @@ -313,7 +313,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Should show diagnostic for invalid value in server.xml for server feature', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) @@ -333,7 +333,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverContents = editor.findElement(By.className('hover-contents')); const hoverValue = await hoverContents.getText(); - console.log("Hover text:" + hoverValue); + console.log("Hover text is:" + hoverValue); assert(hoverValue.includes(constants.SERVLET_ERROR), 'Did not get expected diagnostic in server.xml server feature'); @@ -341,7 +341,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Should apply quick fix for invalid value in server.xml for server feature', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) @@ -388,7 +388,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Should show type ahead support in server.xml Liberty Server platform', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) @@ -418,7 +418,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); it('Valid server feature entry with platform entry in server.xml', async () => { await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) @@ -453,7 +453,7 @@ describe('LCLS tests for Gradle Project', function () { editor.setText(actualServerXMLContent); console.log("Content is restored"); - }).timeout(38000); + }).timeout(45000); after(() => { utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2')); From 17bf406fe883fe61bbedf3b24c9155cbd2f37fb5 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 14:34:55 +0530 Subject: [PATCH 50/54] statements updated in assert --- 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 8f02f21e..20caf030 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -233,7 +233,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(constants.DESCRIPTION_PLATFORM), 'Did not get expected hover text in server.xml server platform'); + assert(hoverValue.includes(constants.DESCRIPTION_PLATFORM), 'Did not get expected hover text in server.xml for server platform'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -261,7 +261,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(constants.PLATFORM_JAKARTA_ERROR), 'Did not get expected diagnostic in server.xml server platform'); + assert(hoverValue.includes(constants.PLATFORM_JAKARTA_ERROR), 'Did not get expected diagnostic in server.xml for server platform'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -307,7 +307,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(constants.PLATFORM_JAKARTA_VALUE), 'Quick fix not applied correctly for the invalid value in server.xml server platform.'); + assert(updatedSeverXMLContent.includes(constants.PLATFORM_JAKARTA_VALUE), 'Quick fix not applied correctly for the invalid value in server.xml for server platform.'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -335,7 +335,7 @@ describe('LCLS tests for Gradle Project', function () { const hoverValue = await hoverContents.getText(); console.log("Hover text is:" + hoverValue); - assert(hoverValue.includes(constants.SERVLET_ERROR), 'Did not get expected diagnostic in server.xml server feature'); + assert(hoverValue.includes(constants.SERVLET_ERROR), 'Did not get expected diagnostic in server.xml for server feature'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -382,7 +382,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedSeverXMLContent = await editor.getText(); await utils.delay(3000); console.log("Content after Quick fix is: ", updatedSeverXMLContent); - assert(updatedSeverXMLContent.includes(constants.SERVLET_VALUE), 'Quick fix is not applied correctly for the invalid value in server.xml server feature.'); + assert(updatedSeverXMLContent.includes(constants.SERVLET_VALUE), 'Quick fix is not applied correctly for the invalid value in server.xml for server feature.'); editor.clearText(); editor.setText(actualServerXMLContent); @@ -412,7 +412,7 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); await utils.delay(3000); console.log("Content after type ahead support is: ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(constants.PLATFORM_JAKARTA_VALUE), 'Type ahead support is not worked as expected in server.xml Liberty Server platform'); + assert(updatedServerxmlContent.includes(constants.PLATFORM_JAKARTA_VALUE), 'Type ahead support is not worked as expected in server.xml for Liberty Server platform'); editor.clearText(); editor.setText(actualServerXMLContent); From 02b596211590abee2f25038a6f579da869f75335 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 16:07:23 +0530 Subject: [PATCH 51/54] method added for close the editor --- src/test/GradleSingleModLCLSTest.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 20caf030..19c32fb9 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -238,6 +238,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -266,6 +267,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -301,7 +303,7 @@ describe('LCLS tests for Gradle Project', function () { } else { console.log('PointerBlockedElement is not found!'); } - const quickfixOption = await editor.findElement(By.xpath(constants.JAKARTA_ELEVEN)); + const quickfixOption = await editor.findElement(By.xpath(constants.FOCUS_JAKARTA_ELEVEN)); await quickfixOption.click(); const updatedSeverXMLContent = await editor.getText(); @@ -312,6 +314,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -340,6 +343,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -387,6 +391,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -417,6 +422,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); @@ -452,6 +458,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); + await utils.closeEditor(constants.SERVER_XML); }).timeout(45000); From d2570d7bed0d689bdd071532f85bf4ff17eeb1a1 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 29 Jan 2025 21:02:07 +0530 Subject: [PATCH 52/54] constant file updated --- src/test/definitions/constants.ts | 33 ++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 812ccae6..08f63190 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -1,5 +1,4 @@ - /** * Copyright (c) 2020, 2022 IBM Corporation. * @@ -75,12 +74,32 @@ export const DESCRIPTION_PLATFORM = `Description: This platform resolves the Lib export const FOCUS_JAKARTA = "//*[contains(text(), '\jakarta\')]"; export const PLATFORM_JAKARTA = "jakarta"; export const PLATFORM_JAKARTA_ERROR = `ERROR: The platform "jakarta" does not exist.`; -export const FOCUS_JAKARTA_ELEVEN= "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; +export const FOCUS_JAKARTA_ELEVEN = "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"; export const FEATURE_SERVLET = "servlet"; export const SERVLET_ERROR = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`; -export const FOCUS_SERVLET ="//*[contains(text(), '\servlet\')]"; -export const SERVLET_VALUE= "servlet-3.1"; +export const FOCUS_SERVLET = "//*[contains(text(), '\servlet\')]"; +export const SERVLET_VALUE = "servlet-3.1"; export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with servlet-3.1\")]"; -export const PLATFORM ="platform"; -export const JAKARTA_ELEVEN ='jakartaee-11.0'; -export const PLATFORM_JAKARTA_NINE= "jakartaee-9.1"; \ No newline at end of file +export const PLATFORM = "platform"; +export const JAKARTA_ELEVEN = 'jakartaee-11.0'; +export const PLATFORM_JAKARTA_NINE = "jakartaee-9.1"; +export const WLP_LOGGING_CONSOLE_FORMAT = 'WLP_LOGGING_CONSOLE_FORMAT'; +export const CONSOLE_FORMAT_TBASIC = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC'; +export const TBASIC = 'TBASIC'; +export const TBA = "=TBA"; +export const WLP_LOGGING_CON = 'WLP_LOGGING_CON'; +export const LOG_LEVEL_INFO_MSG = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.'; +export const FOCUS_LOGLEVEL = "//*[contains(text(), 'CONSOLE_LOGLEVEL')]"; +export const LOGLEVEL_WITH_VALUE = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF'; +export const CONSOLE_FORMAT_DIAGNOSTIC = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.'; +export const FOCUS_NODATA = "//*[contains(text(), 'nodata')]"; +export const VALUE_NODATA = '=sample_value_is_updating_as_nodata'; +export const WS_LOGGING_CON = "com.ibm.ws.logging.con"; +export const VALUE_WRONG = "=wrong"; +export const WS_LOGGING_CONSOLE_FORMAT = "com.ibm.ws.logging.console.format"; +export const WS_LOGGING_CONSOLE_DIAGNOSTIC = "The value `wrong` is not valid for the property `com.ibm.ws.logging.console.format`."; +export const WS_LOGGING_CONSOLE_VALUE = "com.ibm.ws.logging.console.log.level=OFF"; +export const FOCUS_WS_LOGLEVEL = "//*[contains(text(), 'ws.logging.console.log.level')]"; +export const WS_LOGLEVEL_TBASIC = 'com.ibm.ws.logging.trace.format=TBASIC'; +export const WS_LOG_TRACE_FORMAT = 'com.ibm.ws.logging.trace.format'; +export const WS_LOGGING_T = "com.ibm.ws.logging.t"; \ No newline at end of file From 29b4bf156da8e69fe8424110f7b353effdf51f10 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 19:24:31 +0530 Subject: [PATCH 53/54] review comments addressed --- ...ts => GradleSingleModLclsServerXmlTest.ts} | 71 +++++++++---------- src/test/definitions/constants.ts | 2 +- src/test/utils/testUtils.ts | 10 +-- 3 files changed, 41 insertions(+), 42 deletions(-) rename src/test/{GradleSingleModLCLSTest.ts => GradleSingleModLclsServerXmlTest.ts} (89%) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLclsServerXmlTest.ts similarity index 89% rename from src/test/GradleSingleModLCLSTest.ts rename to src/test/GradleSingleModLclsServerXmlTest.ts index 19c32fb9..934074c7 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLclsServerXmlTest.ts @@ -23,17 +23,16 @@ describe('LCLS tests for Gradle Project', function () { }); it('Should copy content of server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; actualServerXMLContent = await editor.getText(); assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.'); - console.log('Sever.xml content is:', actualServerXMLContent); }).timeout(30000); it('Should show diagnostic for server.xml invalid value', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML); await editor.typeTextAt(17, 5, constants.TARGETED_VALUE_LOGGING); const focusTargetedElement = editor.findElement(By.xpath(constants.FOCUS_WRONG)); @@ -54,12 +53,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(38000); it('Should apply quick fix for invalid value in server.xml', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(17, 5, constants.TARGETED_VALUE_LOGGING); @@ -100,12 +99,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should show hover support for server.xml Liberty Server Attribute', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML); const focusTargetedElement = editor.findElement(By.xpath(constants.FOCUS_HTTPENDPOINT)); await utils.delay(3000); @@ -125,12 +124,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should show hover support for server.xml Liberty Server Feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML); await editor.typeTextAt(15, 35, constants.NEWLINE); await utils.delay(1000); @@ -153,12 +152,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); - it('Should show type ahead support in server.xml Liberty Server Feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + it('Should show completion support in server.xml Liberty Server Feature', async () => { + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML); editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; const featureTag = " { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML); + it('Should show completion support in server.xml Liberty Server Configuration Stanza', async () => { + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML); editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; const stanzaSnippet = "log"; @@ -204,17 +203,17 @@ describe('LCLS tests for Gradle Project', function () { const updatedServerxmlContent = await editor.getText(); await utils.delay(3000); console.log("Updated content in Sever.xml : ", updatedServerxmlContent); - assert(updatedServerxmlContent.includes(constants.LOGGING_TAG), 'Type ahead support is not worked as expected in server.xml for Liberty Server Configuration Stanza'); + assert(updatedServerxmlContent.includes(constants.LOGGING_TAG), 'Completion support is not worked as expected in server.xml for Liberty Server Configuration Stanza'); editor.clearText(); editor.setText(actualServerXMLContent); console.log("server.xml content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should show hover text in server.xml for server platform', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(15, 35, constants.NEWLINE); @@ -238,12 +237,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should show diagnostic for invalid value in server.xml for server platform', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(15, 35, constants.NEWLINE); @@ -267,12 +266,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should apply quick fix for invalid value in server.xml for server platform', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(15, 35, constants.NEWLINE); @@ -314,12 +313,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should show diagnostic for invalid value in server.xml for server feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(15, 35, constants.NEWLINE); @@ -343,12 +342,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); it('Should apply quick fix for invalid value in server.xml for server feature', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; @@ -391,12 +390,12 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); - it('Should show type ahead support in server.xml Liberty Server platform', async () => { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + it('Should show completion support in server.xml Liberty Server platform', async () => { + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; const featureTag = " { - await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML) + await utils.openFileByPath(constants.CONFIG_TWO, constants.SERVER_XML) editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor; await editor.typeTextAt(15, 35, constants.NEWLINE); @@ -458,7 +457,7 @@ describe('LCLS tests for Gradle Project', function () { editor.clearText(); editor.setText(actualServerXMLContent); console.log("Content is restored"); - await utils.closeEditor(constants.SERVER_XML); + await utils.closeFileTab(constants.SERVER_XML); }).timeout(45000); diff --git a/src/test/definitions/constants.ts b/src/test/definitions/constants.ts index 08f63190..71a502ca 100755 --- a/src/test/definitions/constants.ts +++ b/src/test/definitions/constants.ts @@ -1,6 +1,6 @@ /** - * Copyright (c) 2020, 2022 IBM Corporation. + * Copyright (c) 2020, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index a6b8e741..103a1be4 100755 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -245,18 +245,18 @@ export async function copyDirectoryByPath(existingDirPath: string, copyDirPath: * * @param parentDir * @param configFileName - * Open specific config file from parent directory + * Open specific file from parent directory */ -export async function openConfigFile(parentDir: string, configFileName: string) { +export async function openFileByPath(parentDir: string, fileName: string) { const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT); section.expand(); - await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, configFileName)); + await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, fileName)); } /** - * Function to close currently opened config file tab + * Function to close currently opened file tab */ -export async function closeEditor(fileType: string) { +export async function closeFileTab(fileType: string) { const workbench = new Workbench(); await workbench.openCommandPrompt(); await delay(3000); From adea404cbf77258a354872dc46f5ff2f710286f4 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 18 Feb 2025 19:34:33 +0530 Subject: [PATCH 54/54] removed server.env file --- .../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