From 08aefcd64a7e9b6385bece3c0449365630a1d722 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Tue, 12 Nov 2024 23:01:34 +0530 Subject: [PATCH 01/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] added code to update the old content --- src/test/GradleSingleModLCLSTest.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index e08f7a97..084d4e3b 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -23,7 +23,7 @@ describe('LCLS Test for Gradle Project', function () { await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); editor = await new EditorView().openEditor('server.xml') as TextEditor; - + const actualContent = await editor.getText(); const stanzaSnippet = ""; const expectedText = ""; await editor.typeTextAt(17, 5, stanzaSnippet); @@ -60,5 +60,9 @@ describe('LCLS Test for Gradle Project', function () { await utils.delay(3000); console.log("Content after Quick fix : ", updatedContent); assert(updatedContent.includes(expectedText), 'quick fix not applied correctly.'); + editor.clearText(); + editor.setText(actualContent); + console.log("Content restored"); + }).timeout(25000); }); From 23d1ce7537c295c295325635ec1b31867fe61908 Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Wed, 20 Nov 2024 22:45:52 +0530 Subject: [PATCH 13/14] hover support for server.xml Liberty Server Attribute --- src/test/GradleSingleModLCLSTest.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index 084d4e3b..d135ea5f 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -65,4 +65,30 @@ describe('LCLS Test for Gradle Project', function () { console.log("Content restored"); }).timeout(25000); + + it('should show hover support for server.xml Liberty Server Attribute', async () => { + + await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config', 'server.xml')); + editor = await new EditorView().openEditor('server.xml') as TextEditor; + + const hoverExpectedOutcome = `Configuration properties for an HTTP endpoint. +Source: ol-24.0.0.11.xsd`; + + console.log(hoverExpectedOutcome); + const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'httpEndpoint')]")); + await utils.delay(3000); + focusTargetLement.click(); + await editor.click(); + + const actions = VSBrowser.instance.driver.actions(); + await actions.move({ origin: focusTargetLement }).perform(); + await utils.delay(5000); + + const hoverContents = editor.findElement(By.className('hover-contents')); + const hoverValue = await hoverContents.getText(); + console.log("Hover text:" + hoverValue); + + assert(hoverValue === (hoverExpectedOutcome), 'Did not get expected hover data.'); + + }).timeout(25000); }); From 6eba89dffb6b73f5bbfc789a1c6df64112494c8b Mon Sep 17 00:00:00 2001 From: SuparnaSuresh Date: Thu, 21 Nov 2024 19:56:26 +0530 Subject: [PATCH 14/14] updated code for quick fix element --- src/test/GradleSingleModLCLSTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/GradleSingleModLCLSTest.ts b/src/test/GradleSingleModLCLSTest.ts index d135ea5f..92047ac7 100755 --- a/src/test/GradleSingleModLCLSTest.ts +++ b/src/test/GradleSingleModLCLSTest.ts @@ -39,7 +39,7 @@ describe('LCLS Test for Gradle Project', function () { const hoverValue = editor.findElement(By.className('hover-row status-bar')); await utils.delay(2000); - const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix... (⌘.)')]")); + const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); await quickFixPopupLink.click(); const hoverBar = editor.findElement(By.className('context-view monaco-component bottom left fixed'));