Skip to content

Commit 4289483

Browse files
author
Siddharth Saladi
committed
added seconds() function for readability
1 parent f38e77a commit 4289483

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

src/test/utils/testUtils.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
@@ -221,8 +228,8 @@ export async function getDashboardSection(sidebar: any): Promise<any> {
221228
}
222229
return;
223230
}, {
224-
timeout: 30000,
225-
pollInterval: 3000,
231+
timeout: seconds(30),
232+
pollInterval: seconds(3),
226233
message: 'Liberty Tools section was not found in sidebar within 30 seconds'
227234
});
228235
}
@@ -252,7 +259,7 @@ export async function getDashboardItem(section: any, projectName: string): Promi
252259
}
253260
throw error;
254261
}
255-
}, { timeout: 10000, message: 'Dashboard items did not appear after expansion' });
262+
}, { timeout: seconds(10), message: 'Dashboard items did not appear after expansion' });
256263

257264
// Find the item
258265
return await waitForCondition(async () => {
@@ -385,8 +392,8 @@ export async function checkTerminalforServerState(serverStatusCode: string): Pro
385392
return;
386393
}
387394
}, {
388-
timeout: 300000, // 300 seconds (5 minutes) max wait - increased for custom params
389-
pollInterval: 10000, // check every 10 seconds
395+
timeout: seconds(5 * 60),
396+
pollInterval: seconds(10),
390397
message: `Server state '${serverStatusCode}' not found in terminal`
391398
});
392399

@@ -413,8 +420,8 @@ export async function checkTestStatus(testStatus: string): Promise<boolean> {
413420
}
414421
return;
415422
}, {
416-
timeout: 120000, // 120 seconds (2 minutes) max wait for tests to complete
417-
pollInterval: 5000, // check every 5 seconds
423+
timeout: seconds(2 * 60),
424+
pollInterval: seconds(5),
418425
message: `Test status '${testStatus}' not found in terminal`
419426
});
420427

@@ -455,7 +462,7 @@ export async function clearCommandPalette() {
455462
} catch {
456463
return;
457464
}
458-
}, { timeout: 5000, message: 'Clear command history dialog did not appear' });
465+
}, { timeout: seconds(5), message: 'Clear command history dialog did not appear' });
459466

460467
await waitForSuccess(async () => {
461468
const dialog = new ModalDialog();
@@ -502,8 +509,8 @@ export async function waitForDashboardToLoad(section: any): Promise<void> {
502509
}
503510
return;
504511
}, {
505-
timeout: 180000, // 3 minutes max
506-
pollInterval: 5000, // check every 5 seconds
512+
timeout: seconds(3 * 60),
513+
pollInterval: seconds(5),
507514
message: 'Dashboard items did not load'
508515
});
509516
}
@@ -554,8 +561,8 @@ export async function waitForTestReport(reportPath: string, alternatePath?: stri
554561
}
555562
return;
556563
}, {
557-
timeout: 50000, // 50 seconds max (for slow systems)
558-
pollInterval: 1000, // check every 1 second (faster detection)
564+
timeout: seconds(50),
565+
pollInterval: seconds(1),
559566
message: alternatePath
560567
? `Test report not found at either ${reportPath} or ${alternatePath}`
561568
: `Test report not found at ${reportPath}`
@@ -576,7 +583,7 @@ export async function waitForDebuggerAttach(): Promise<boolean> {
576583

577584
try {
578585
// Wait for the debug toolbar to appear, which indicates debugger is attached
579-
const findDebugBarTimeout = 30000;
586+
const findDebugBarTimeout = seconds(30);
580587
await DebugToolbar.create(findDebugBarTimeout);
581588
logger.info('DebugToolbar appeared - debugger attached successfully');
582589
return true;

0 commit comments

Comments
 (0)