Skip to content

Commit d85946d

Browse files
committed
Update after timeouts, move common hover function and increase timeout
1 parent e9a7f33 commit d85946d

5 files changed

Lines changed: 47 additions & 76 deletions

File tree

src/test/GradleTestDevModeActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('Devmode action tests for Gradle Project', () => {
2525
});
2626

2727
afterEach(async function() {
28+
this.timeout(10000); // Increase timeout for cleanup operations
2829
// Close any open editors after each test
2930
if (this.currentTest?.state === 'failed') {
3031
const driver = VSBrowser.instance.driver;

src/test/GradleTestLSPHover.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('LSP Hover tests for Gradle Project', () => {
5252
});
5353

5454
after(async function() {
55+
this.timeout(10000); // Increase timeout for cleanup operations
5556
// Close editor after all tests complete
5657
try {
5758
await editorView.closeAllEditors();
@@ -106,25 +107,7 @@ describe('LSP Hover tests for Gradle Project', () => {
106107

107108
logger.step(3, 'Verifying hover widget appears with Liberty Language Server content');
108109
const driver = VSBrowser.instance.driver;
109-
const hoverVisible = await wait.forCondition(async () => {
110-
try {
111-
const hoverWidget = await driver.findElement({ css: '.monaco-hover' });
112-
const isDisplayed = await hoverWidget.isDisplayed();
113-
if (isDisplayed) {
114-
const hoverText = await hoverWidget.getText();
115-
logger.info(`Hover content for ${testCase.element}: ${hoverText.length} characters`);
116-
// Verify hover contains content (Liberty LS provides documentation)
117-
return hoverText && hoverText.length > 0;
118-
}
119-
} catch {
120-
return;
121-
}
122-
return;
123-
}, {
124-
timeout: 10000,
125-
pollInterval: 500,
126-
message: `Hover widget did not appear with content for ${testCase.element}`
127-
});
110+
const hoverVisible = await utils.waitForHoverWidget(driver, testCase.element, 15000);
128111

129112
expect(hoverVisible).to.be.true;
130113
logger.stepSuccess(3, `Hover widget displayed with Liberty Language Server content for ${testCase.element}`);
@@ -207,25 +190,7 @@ describe('LSP Hover tests for Gradle Project', () => {
207190

208191
logger.step(3, 'Verifying hover widget appears with LSP4Jakarta content');
209192
const driver = VSBrowser.instance.driver;
210-
const hoverVisible = await wait.forCondition(async () => {
211-
try {
212-
const hoverWidget = await driver.findElement({ css: '.monaco-hover' });
213-
const isDisplayed = await hoverWidget.isDisplayed();
214-
if (isDisplayed) {
215-
const hoverText = await hoverWidget.getText();
216-
logger.info(`Hover content for ${testCase.element}: ${hoverText.length} characters`);
217-
// Verify hover contains content (LSP4Jakarta provides documentation)
218-
return hoverText && hoverText.length > 0;
219-
}
220-
} catch {
221-
return;
222-
}
223-
return;
224-
}, {
225-
timeout: 10000,
226-
pollInterval: 500,
227-
message: `Hover widget did not appear with content for ${testCase.element}`
228-
});
193+
const hoverVisible = await utils.waitForHoverWidget(driver, testCase.element, 15000);
229194

230195
expect(hoverVisible).to.be.true;
231196
logger.stepSuccess(3, `Hover widget displayed with LSP4Jakarta content for ${testCase.element}`);

src/test/MavenTestDevModeActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('Devmode action tests for Maven Project', () => {
2626
});
2727

2828
afterEach(async function() {
29+
this.timeout(10000); // Increase timeout for cleanup operations
2930
// Close any open editors after each test
3031
if (this.currentTest?.state === 'failed') {
3132
const driver = VSBrowser.instance.driver;

src/test/MavenTestLSPHover.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('LSP Hover tests for Maven Project', () => {
5252
});
5353

5454
after(async function() {
55+
this.timeout(10000); // Increase timeout for cleanup operations
5556
// Close editor after all tests complete
5657
try {
5758
await editorView.closeAllEditors();
@@ -106,25 +107,7 @@ describe('LSP Hover tests for Maven Project', () => {
106107

107108
logger.step(3, 'Verifying hover widget appears with Liberty Language Server content');
108109
const driver = VSBrowser.instance.driver;
109-
const hoverVisible = await wait.forCondition(async () => {
110-
try {
111-
const hoverWidget = await driver.findElement({ css: '.monaco-hover' });
112-
const isDisplayed = await hoverWidget.isDisplayed();
113-
if (isDisplayed) {
114-
const hoverText = await hoverWidget.getText();
115-
logger.info(`Hover content for ${testCase.element}: ${hoverText.length} characters`);
116-
// Verify hover contains content (Liberty LS provides documentation)
117-
return hoverText && hoverText.length > 0;
118-
}
119-
} catch {
120-
return;
121-
}
122-
return;
123-
}, {
124-
timeout: 10000,
125-
pollInterval: 500,
126-
message: `Hover widget did not appear with content for ${testCase.element}`
127-
});
110+
const hoverVisible = await utils.waitForHoverWidget(driver, testCase.element, 15000);
128111

129112
expect(hoverVisible).to.be.true;
130113
logger.stepSuccess(3, `Hover widget displayed with Liberty Language Server content for ${testCase.element}`);
@@ -207,25 +190,7 @@ describe('LSP Hover tests for Maven Project', () => {
207190

208191
logger.step(3, 'Verifying hover widget appears with LSP4Jakarta content');
209192
const driver = VSBrowser.instance.driver;
210-
const hoverVisible = await wait.forCondition(async () => {
211-
try {
212-
const hoverWidget = await driver.findElement({ css: '.monaco-hover' });
213-
const isDisplayed = await hoverWidget.isDisplayed();
214-
if (isDisplayed) {
215-
const hoverText = await hoverWidget.getText();
216-
logger.info(`Hover content for ${testCase.element}: ${hoverText.length} characters`);
217-
// Verify hover contains content (LSP4Jakarta provides documentation)
218-
return hoverText && hoverText.length > 0;
219-
}
220-
} catch {
221-
return;
222-
}
223-
return;
224-
}, {
225-
timeout: 10000,
226-
pollInterval: 500,
227-
message: `Hover widget did not appear with content for ${testCase.element}`
228-
});
193+
const hoverVisible = await utils.waitForHoverWidget(driver, testCase.element, 15000);
229194

230195
expect(hoverVisible).to.be.true;
231196
logger.stepSuccess(3, `Hover widget displayed with LSP4Jakarta content for ${testCase.element}`);

src/test/utils/testUtils.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,45 @@ export async function waitForLanguageServerInit(
9292
});
9393
}
9494

95+
/**
96+
* Wait for hover widget to appear with content after triggering hover command.
97+
* This function dynamically waits for the hover widget to render and contain content,
98+
* accounting for language server initialization delays.
99+
* Works for both Liberty Language Server and LSP4Jakarta hover content.
100+
*
101+
* @param driver The WebDriver instance
102+
* @param elementDescription Description of the element being hovered (for logging)
103+
* @param timeout Timeout in milliseconds (default: 15000)
104+
* @returns true if hover widget appeared with content
105+
*/
106+
export async function waitForHoverWidget(
107+
driver: any,
108+
elementDescription: string,
109+
timeout: number = 15000
110+
): Promise<boolean> {
111+
const wait = getWaitHelper();
112+
113+
return await wait.forCondition(async () => {
114+
try {
115+
const hoverWidget = await driver.findElement({ css: '.monaco-hover' });
116+
const isDisplayed = await hoverWidget.isDisplayed();
117+
if (isDisplayed) {
118+
const hoverText = await hoverWidget.getText();
119+
logger.info(`Hover content for ${elementDescription}: ${hoverText.length} characters`);
120+
// Verify hover contains content (language server provides documentation)
121+
return hoverText && hoverText.length > 0;
122+
}
123+
} catch {
124+
return false;
125+
}
126+
return false;
127+
}, {
128+
timeout: timeout,
129+
pollInterval: 500,
130+
message: `Hover widget did not appear with content for ${elementDescription}`
131+
});
132+
}
133+
95134
/**
96135
* @deprecated Use getWaitHelper().sleep() or preferably condition-based waiting instead
97136
*/

0 commit comments

Comments
 (0)