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