diff --git a/examples/playwright/src/tests/theia-explorer-view.test.ts b/examples/playwright/src/tests/theia-explorer-view.test.ts index ba846f4459abb..3dc406f261887 100644 --- a/examples/playwright/src/tests/theia-explorer-view.test.ts +++ b/examples/playwright/src/tests/theia-explorer-view.test.ts @@ -29,6 +29,7 @@ test.describe('Theia Explorer View', () => { const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']); app = await TheiaApp.load(page, ws); explorer = await app.openView(TheiaExplorerView); + await explorer.waitForVisibleFileNodes(); }); test('should be visible and active after being opened', async () => { diff --git a/examples/playwright/src/theia-app.ts b/examples/playwright/src/theia-app.ts index 0680e1faf6a9e..00ccf3bbcc33d 100644 --- a/examples/playwright/src/theia-app.ts +++ b/examples/playwright/src/theia-app.ts @@ -109,6 +109,7 @@ export class TheiaApp { throw Error('TheiaExplorerView could not be opened.'); } if (expectFileNodes) { + await explorer.waitForVisibleFileNodes(); const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER); if (fileStatElements.length < 1) { throw Error('TheiaExplorerView is empty.'); diff --git a/examples/playwright/src/theia-explorer-view.ts b/examples/playwright/src/theia-explorer-view.ts index 6cc1cbba132b1..8664dac70e9aa 100644 --- a/examples/playwright/src/theia-explorer-view.ts +++ b/examples/playwright/src/theia-explorer-view.ts @@ -148,6 +148,10 @@ export class TheiaExplorerView extends TheiaView { await treeNode.focus(); } else { await treeNode.click({ modifiers: ['Control'] }); + // make sure the click has been acted-upon before returning + while (!await this.isTreeNodeSelected(filePath)) { + console.debug('Waiting for clicked tree node to be selected: ' + filePath); + } } } @@ -231,4 +235,18 @@ export class TheiaExplorerView extends TheiaView { await this.refresh(); } + override async waitForVisible(): Promise { + await super.waitForVisible(); + await this.page.waitForSelector(this.tabSelector, { state: 'visible' }); + } + + /** + * Waits until some non-dot file nodes are visible + */ + async waitForVisibleFileNodes(): Promise { + while ((await this.visibleFileStatNodes(DOT_FILES_FILTER)).length === 0) { + console.debug('Awaiting for tree nodes to appear'); + } + } + }