Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests implementation liberty-ls support in server.xml for diagnostic and quickfix #377

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/test/GradleSingleModLCLSTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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 actualContent = await editor.getText();
const stanzaSnippet = "<logging appsWriteJson = \"wrong\" />";
const expectedText = "<logging appsWriteJson = \"true\" />";
await editor.typeTextAt(18, 5, stanzaSnippet);
await utils.delay(2000);
const flaggedString = 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 utils.delay(3000);

const driver = VSBrowser.instance.driver;
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 = await 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.');
await editor.clearText();
await editor.setText(actualContent);
console.log("Content restored");

}).timeout(38000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<server description="Sample Servlet server">
<featureManager>
<feature>jsp-2.3</feature>
<feature>mpHealth-4.0</feature>
</featureManager>

<httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint" />
Expand Down
Loading