Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/run-regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
runtime: [ linux, mac ]
# Removing windows as a standard run flavor runtime: [ linux, mac, windows ]
targetVSCode: [previous, latest ]
targetVSCode: [latest]
buildTool: [maven, gradle]
# As Vscode 1.79 and 1.78 are the only support version for current release, running test with only latest,previous
#Enable it in future for multiple releases as applicable targetVSCode: [ previousMinusOne, previous, latest ]
Expand Down
2 changes: 1 addition & 1 deletion src/test/Gradle9TestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('Gradle 9-specific devmode action tests', () => {
* Closing the workspace ensures the next test file starts with a clean slate.
*/
after(async function() {
this.timeout(10000);
this.timeout(45000);
await utils.closeWorkspace();
});
});
2 changes: 1 addition & 1 deletion src/test/GradleTestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Gradle-specific devmode action tests', () => {
* Closing the workspace ensures the next test file starts with a clean slate.
*/
after(async function() {
this.timeout(10000);
this.timeout(45000);
await utils.closeWorkspace();
});
});
2 changes: 1 addition & 1 deletion src/test/MavenTestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ describe('Maven-specific devmode action tests', () => {
* The following after hook closes the workspace so the next test file starts with a clean slate.
*/
after(async function() {
this.timeout(10000);
this.timeout(45000);
await utils.closeWorkspace();
});
});
4 changes: 2 additions & 2 deletions src/test/shared/devModeTestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function runDevModeTestSuite(config: DevModeConfig): void {
describe(`Devmode action tests for ${config.buildTool} Project`, () => {

before(async function() {
this.timeout(30000);
this.timeout(60000);

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

afterEach(async function() {
this.timeout(10000); // Increase timeout for cleanup operations
this.timeout(30000);
// Close any open editors after each test
if (this.currentTest?.state === 'failed') {
await VSBrowser.instance.driver.takeScreenshot();
Expand Down
70 changes: 45 additions & 25 deletions src/test/utils/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright IBM Corp. 2023, 2026
*/
import path = require('path');
import { Workbench, InputBox, DefaultTreeItem, ModalDialog, VSBrowser, WaitHelper, BottomBarPanel, OutputView, DebugToolbar } from 'vscode-extension-tester';
import { Workbench, InputBox, DefaultTreeItem, ModalDialog, VSBrowser, WaitHelper, BottomBarPanel, OutputView, DebugToolbar, SideBarView } from 'vscode-extension-tester';
import * as fs from 'fs';
import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants';
import { MapContextMenuforMac } from './macUtils';
Expand Down Expand Up @@ -86,8 +86,8 @@ export async function waitForLanguageServerInit(
return false;
}
}, {
timeout: timeout * 1000,
pollInterval: 2000,
timeout: seconds(timeout),
pollInterval: seconds(2),
message: `The ${channelName} output channel did not initialize within ${timeout} seconds`
});
}
Expand Down Expand Up @@ -177,6 +177,13 @@ export async function waitForSuccess(func: () => Promise<any>, timeout: number =
}, timeout);
}

/**
* Convert seconds to milliseconds for use in timeout parameters.
*/
export function seconds(s: number): number {
return s * 1000;
}

export function getMvnProjectPath(): string {
const mvnProjectPath = path.join(__dirname, "..", "..", "..", "src", "test", "resources", "maven", "liberty-maven-test-wrapper-app");
logger.info("Path is : " + mvnProjectPath);
Expand All @@ -198,20 +205,33 @@ export function getGradle9ProjectPath(): string {

export async function getDashboardSection(sidebar: any): Promise<any> {
logger.info("Getting Liberty Tools section");
return await waitForCondition(async () => {
// Get fresh content on each iteration to avoid stale references
const contentPart = sidebar.getContent();
const sections = await contentPart.getSections();

// Find the Liberty Tools section
for (const sec of sections) {
const title = await sec.getTitle();
if (title === 'Liberty Tools') {
return sec;
const wait = getWaitHelper();
return await wait.forCondition(async () => {
try {
// Re-create SideBarView on every iteration — the captured sidebar
// reference goes stale on workspace transitions and getSections()
// throws on every call, bypassing the retry loop.
const freshSidebar = new SideBarView();
const sections = await freshSidebar.getContent().getSections();
for (const sec of sections) {
const title = await sec.getTitle();
if (title === 'Liberty Tools') {
return sec;
}
}
} catch (error: any) {
if (error.name === 'StaleElementReferenceError' ||
error.name === 'ElementNotInteractableError') {
return;
}
throw error;
}
return;
}, 30);
}, {
timeout: seconds(30),
pollInterval: seconds(3),
message: 'Liberty Tools section was not found in sidebar within 30 seconds'
});
}

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

// Find the item
return await waitForCondition(async () => {
Expand Down Expand Up @@ -372,8 +392,8 @@ export async function checkTerminalforServerState(serverStatusCode: string): Pro
return;
}
}, {
timeout: 300000, // 300 seconds (5 minutes) max wait - increased for custom params
pollInterval: 10000, // check every 10 seconds
timeout: seconds(5 * 60),
pollInterval: seconds(10),
message: `Server state '${serverStatusCode}' not found in terminal`
});

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

Expand Down Expand Up @@ -442,7 +462,7 @@ export async function clearCommandPalette() {
} catch {
return;
}
}, { timeout: 5000, message: 'Clear command history dialog did not appear' });
}, { timeout: seconds(5), message: 'Clear command history dialog did not appear' });

await waitForSuccess(async () => {
const dialog = new ModalDialog();
Expand Down Expand Up @@ -489,8 +509,8 @@ export async function waitForDashboardToLoad(section: any): Promise<void> {
}
return;
}, {
timeout: 120000, // 2 minutes max
pollInterval: 5000, // check every 5 seconds
timeout: seconds(3 * 60),
pollInterval: seconds(5),
message: 'Dashboard items did not load'
});
}
Expand Down Expand Up @@ -541,8 +561,8 @@ export async function waitForTestReport(reportPath: string, alternatePath?: stri
}
return;
}, {
timeout: 50000, // 50 seconds max (for slow systems)
pollInterval: 1000, // check every 1 second (faster detection)
timeout: seconds(50),
pollInterval: seconds(1),
message: alternatePath
? `Test report not found at either ${reportPath} or ${alternatePath}`
: `Test report not found at ${reportPath}`
Expand All @@ -563,7 +583,7 @@ export async function waitForDebuggerAttach(): Promise<boolean> {

try {
// Wait for the debug toolbar to appear, which indicates debugger is attached
const findDebugBarTimeout = 30000;
const findDebugBarTimeout = seconds(30);
await DebugToolbar.create(findDebugBarTimeout);
logger.info('DebugToolbar appeared - debugger attached successfully');
return true;
Expand Down
Loading