Skip to content

Commit d12b396

Browse files
Siddharth SaladiSiddharth Saladi
authored andcommitted
timeouts and re-fetch fresh section
1 parent b33b450 commit d12b396

4 files changed

Lines changed: 17 additions & 21 deletions

File tree

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
});

src/test/utils/testUtils.ts

Lines changed: 14 additions & 18 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';
@@ -246,7 +246,6 @@ export async function getDashboardSection(sidebar: any): Promise<any> {
246246
return await wait.forCondition(async () => {
247247
try {
248248
// Re-create SideBarView on every iteration — on mac Previous the sidebar object goes stale during workspace transitions and getSections() returns dead nodes on every call.
249-
const { SideBarView } = require('vscode-extension-tester');
250249
const freshSidebar = new SideBarView();
251250
const contentPart = freshSidebar.getContent();
252251
const sections = await contentPart.getSections();
@@ -285,7 +284,6 @@ export async function getDashboardItem(section: any, projectName: string): Promi
285284
// stale. Getting a fresh section + fresh sidebar each time breaks that loop.
286285
return (await wait.forCondition(async () => {
287286
try {
288-
const { SideBarView } = require('vscode-extension-tester');
289287
const freshSection = await getDashboardSection(new SideBarView());
290288
await freshSection.expand();
291289
await wait.sleep(1000);
@@ -526,34 +524,33 @@ export async function clearCommandPalette() {
526524
export async function waitForDashboardToLoad(section: any): Promise<void> {
527525
const wait = getWaitHelper();
528526
logger.info('Waiting for Liberty Dashboard to load');
529-
530-
// Expand the section
531-
await waitForSuccess(async () => {
532-
await section.expand();
533-
});
534-
535-
// Wait for section container to become stable after expansion
536-
await wait.sleep(2000);
537-
538-
// Wait for items to appear with retry on ElementNotInteractableError
527+
528+
// Re-fetch a fresh section on every poll iteration. The section reference
529+
// passed in (or obtained just before this call) goes stale on cold runners
530+
// once VS Code rebuilds the sidebar DOM after workspace activation.
531+
// Using a stale reference causes ElementNotInteractableError on every
532+
// getVisibleItems() call, looping forever until timeout.
539533
await wait.forCondition(async () => {
540534
try {
541-
const items = await section.getVisibleItems();
535+
const freshSection = await getDashboardSection(new SideBarView());
536+
await freshSection.expand();
537+
await wait.sleep(500);
538+
const items = await freshSection.getVisibleItems();
542539
if (items && items.length > 0) {
543540
logger.info(`Dashboard loaded with ${items.length} items`);
544541
return true;
545542
}
546543
} catch (error: any) {
547-
// Retry on ElementNotInteractableError
548-
if (error.name === 'ElementNotInteractableError') {
544+
if (error.name === 'ElementNotInteractableError' ||
545+
error.name === 'StaleElementReferenceError') {
549546
logger.info('Container not yet interactable, retrying...');
550547
return;
551548
}
552549
throw error;
553550
}
554551
return;
555552
}, {
556-
timeout: 120000, // 2 minutes max
553+
timeout: 240000, // 4 minutes — matches the 275 s Mocha cap on "Liberty Tools shows items"
557554
pollInterval: 5000, // check every 5 seconds
558555
message: 'Dashboard items did not load'
559556
});
@@ -745,7 +742,6 @@ export async function closeWorkspace(): Promise<void> {
745742
try {
746743
await wait.forCondition(async () => {
747744
try {
748-
const { SideBarView } = require('vscode-extension-tester');
749745
const sidebar = new SideBarView();
750746
const sections = await sidebar.getContent().getSections();
751747
for (const sec of sections) {

0 commit comments

Comments
 (0)