Skip to content

Commit e1b0a11

Browse files
authored
Merge pull request #620 from siddhusaladi/drop-prev-vscode-version
added timeouts + dropped prev vscode version due to build issues + use correct SideBarView reference
2 parents 2e24d2d + 4289483 commit e1b0a11

8 files changed

Lines changed: 51 additions & 31 deletions

.github/workflows/run-regression-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
runtime: [ linux, mac ]
1515
# Removing windows as a standard run flavor runtime: [ linux, mac, windows ]
16-
targetVSCode: [previous, latest ]
16+
targetVSCode: [latest]
1717
buildTool: [maven, gradle]
1818
# As Vscode 1.79 and 1.78 are the only support version for current release, running test with only latest,previous
1919
#Enable it in future for multiple releases as applicable targetVSCode: [ previousMinusOne, previous, latest ]

src/test/Gradle9TestDevModeActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe('Gradle 9-specific devmode action tests', () => {
187187
* Closing the workspace ensures the next test file starts with a clean slate.
188188
*/
189189
after(async function() {
190-
this.timeout(10000);
190+
this.timeout(45000);
191191
await utils.closeWorkspace();
192192
});
193193
});

src/test/GradleTestDevModeActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('Gradle-specific devmode action tests', () => {
183183
* Closing the workspace ensures the next test file starts with a clean slate.
184184
*/
185185
after(async function() {
186-
this.timeout(10000);
186+
this.timeout(45000);
187187
await utils.closeWorkspace();
188188
});
189189
});

src/test/MavenTestDevModeActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe('Maven-specific devmode action tests', () => {
200200
* The following after hook closes the workspace so the next test file starts with a clean slate.
201201
*/
202202
after(async function() {
203-
this.timeout(10000);
203+
this.timeout(45000);
204204
await utils.closeWorkspace();
205205
});
206206
});
File renamed without changes.
File renamed without changes.

src/test/shared/devModeTestSuite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function runDevModeTestSuite(config: DevModeConfig): void {
2424
describe(`Devmode action tests for ${config.buildTool} Project`, () => {
2525

2626
before(async function() {
27-
this.timeout(30000);
27+
this.timeout(60000);
2828

2929
await VSBrowser.instance.openResources(config.getProjectPath());
3030
await VSBrowser.instance.waitForWorkbench();
@@ -33,7 +33,7 @@ export function runDevModeTestSuite(config: DevModeConfig): void {
3333
});
3434

3535
afterEach(async function() {
36-
this.timeout(10000); // Increase timeout for cleanup operations
36+
this.timeout(30000);
3737
// Close any open editors after each test
3838
if (this.currentTest?.state === 'failed') {
3939
await VSBrowser.instance.driver.takeScreenshot();

src/test/utils/testUtils.ts

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright IBM Corp. 2023, 2026
44
*/
55
import path = require('path');
6-
import { Workbench, InputBox, DefaultTreeItem, ModalDialog, VSBrowser, WaitHelper, BottomBarPanel, OutputView, DebugToolbar } from 'vscode-extension-tester';
6+
import { Workbench, InputBox, DefaultTreeItem, ModalDialog, VSBrowser, WaitHelper, BottomBarPanel, OutputView, DebugToolbar, SideBarView } from 'vscode-extension-tester';
77
import * as fs from 'fs';
88
import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants';
99
import { MapContextMenuforMac } from './macUtils';
@@ -86,8 +86,8 @@ export async function waitForLanguageServerInit(
8686
return false;
8787
}
8888
}, {
89-
timeout: timeout * 1000,
90-
pollInterval: 2000,
89+
timeout: seconds(timeout),
90+
pollInterval: seconds(2),
9191
message: `The ${channelName} output channel did not initialize within ${timeout} seconds`
9292
});
9393
}
@@ -177,6 +177,13 @@ export async function waitForSuccess(func: () => Promise<any>, timeout: number =
177177
}, timeout);
178178
}
179179

180+
/**
181+
* Convert seconds to milliseconds for use in timeout parameters.
182+
*/
183+
export function seconds(s: number): number {
184+
return s * 1000;
185+
}
186+
180187
export function getMvnProjectPath(): string {
181188
const mvnProjectPath = path.join(__dirname, "..", "..", "..", "src", "test", "resources", "maven", "liberty-maven-test-wrapper-app");
182189
logger.info("Path is : " + mvnProjectPath);
@@ -198,20 +205,33 @@ export function getGradle9ProjectPath(): string {
198205

199206
export async function getDashboardSection(sidebar: any): Promise<any> {
200207
logger.info("Getting Liberty Tools section");
201-
return await waitForCondition(async () => {
202-
// Get fresh content on each iteration to avoid stale references
203-
const contentPart = sidebar.getContent();
204-
const sections = await contentPart.getSections();
205-
206-
// Find the Liberty Tools section
207-
for (const sec of sections) {
208-
const title = await sec.getTitle();
209-
if (title === 'Liberty Tools') {
210-
return sec;
208+
const wait = getWaitHelper();
209+
return await wait.forCondition(async () => {
210+
try {
211+
// Re-create SideBarView on every iteration — the captured sidebar
212+
// reference goes stale on workspace transitions and getSections()
213+
// throws on every call, bypassing the retry loop.
214+
const freshSidebar = new SideBarView();
215+
const sections = await freshSidebar.getContent().getSections();
216+
for (const sec of sections) {
217+
const title = await sec.getTitle();
218+
if (title === 'Liberty Tools') {
219+
return sec;
220+
}
221+
}
222+
} catch (error: any) {
223+
if (error.name === 'StaleElementReferenceError' ||
224+
error.name === 'ElementNotInteractableError') {
225+
return;
211226
}
227+
throw error;
212228
}
213229
return;
214-
}, 30);
230+
}, {
231+
timeout: seconds(30),
232+
pollInterval: seconds(3),
233+
message: 'Liberty Tools section was not found in sidebar within 30 seconds'
234+
});
215235
}
216236

217237
export async function getDashboardItem(section: any, projectName: string): Promise<DefaultTreeItem> {
@@ -239,7 +259,7 @@ export async function getDashboardItem(section: any, projectName: string): Promi
239259
}
240260
throw error;
241261
}
242-
}, { timeout: 10000, message: 'Dashboard items did not appear after expansion' });
262+
}, { timeout: seconds(10), message: 'Dashboard items did not appear after expansion' });
243263

244264
// Find the item
245265
return await waitForCondition(async () => {
@@ -372,8 +392,8 @@ export async function checkTerminalforServerState(serverStatusCode: string): Pro
372392
return;
373393
}
374394
}, {
375-
timeout: 300000, // 300 seconds (5 minutes) max wait - increased for custom params
376-
pollInterval: 10000, // check every 10 seconds
395+
timeout: seconds(5 * 60),
396+
pollInterval: seconds(10),
377397
message: `Server state '${serverStatusCode}' not found in terminal`
378398
});
379399

@@ -400,8 +420,8 @@ export async function checkTestStatus(testStatus: string): Promise<boolean> {
400420
}
401421
return;
402422
}, {
403-
timeout: 120000, // 120 seconds (2 minutes) max wait for tests to complete
404-
pollInterval: 5000, // check every 5 seconds
423+
timeout: seconds(2 * 60),
424+
pollInterval: seconds(5),
405425
message: `Test status '${testStatus}' not found in terminal`
406426
});
407427

@@ -442,7 +462,7 @@ export async function clearCommandPalette() {
442462
} catch {
443463
return;
444464
}
445-
}, { timeout: 5000, message: 'Clear command history dialog did not appear' });
465+
}, { timeout: seconds(5), message: 'Clear command history dialog did not appear' });
446466

447467
await waitForSuccess(async () => {
448468
const dialog = new ModalDialog();
@@ -489,8 +509,8 @@ export async function waitForDashboardToLoad(section: any): Promise<void> {
489509
}
490510
return;
491511
}, {
492-
timeout: 120000, // 2 minutes max
493-
pollInterval: 5000, // check every 5 seconds
512+
timeout: seconds(3 * 60),
513+
pollInterval: seconds(5),
494514
message: 'Dashboard items did not load'
495515
});
496516
}
@@ -541,8 +561,8 @@ export async function waitForTestReport(reportPath: string, alternatePath?: stri
541561
}
542562
return;
543563
}, {
544-
timeout: 50000, // 50 seconds max (for slow systems)
545-
pollInterval: 1000, // check every 1 second (faster detection)
564+
timeout: seconds(50),
565+
pollInterval: seconds(1),
546566
message: alternatePath
547567
? `Test report not found at either ${reportPath} or ${alternatePath}`
548568
: `Test report not found at ${reportPath}`
@@ -563,7 +583,7 @@ export async function waitForDebuggerAttach(): Promise<boolean> {
563583

564584
try {
565585
// Wait for the debug toolbar to appear, which indicates debugger is attached
566-
const findDebugBarTimeout = 30000;
586+
const findDebugBarTimeout = seconds(30);
567587
await DebugToolbar.create(findDebugBarTimeout);
568588
logger.info('DebugToolbar appeared - debugger attached successfully');
569589
return true;

0 commit comments

Comments
 (0)