Skip to content

Commit

Permalink
playwright: Wait for file stat nodes (#12310)
Browse files Browse the repository at this point in the history
The `theia-workspace.test.ts` checks for existence of file nodes in the
explorer view to verify whether the workspace has been prepared
correctly. However, occasionally it may happen that the explorer view
doesn't show them yet, as the files are just being loaded.

This resulted in occasionally flaky test executions (#12063).

To fix this problem, we now use the `existsDirectoryNode` and
`existsFileNode` checks to explicitly wait for them to appear and
only fail if the check times out.

Contributed on behalf of STMicroelectronics.
Fixes #12063

Change-Id: I4226a7d6f657c6a1363160655da4c94cd0984379
  • Loading branch information
planger authored Mar 17, 2023
1 parent 4694363 commit ff944de
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/playwright/src/tests/theia-workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ test.describe('Theia Workspace', () => {
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
const app = await TheiaApp.load(page, ws);
const explorer = await app.openView(TheiaExplorerView);
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
// resources/sample-files1 contains one folder and one file
expect(fileStatElements.length).toBe(2);
expect(await explorer.existsDirectoryNode('sampleFolder')).toBe(true);
expect(await explorer.existsFileNode('sample.txt')).toBe(true);
});

test('should be initialized with the contents of multiple file locations', async () => {
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1', 'src/tests/resources/sample-files2']);
const app = await TheiaApp.load(page, ws);
const explorer = await app.openView(TheiaExplorerView);
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
// resources/sample-files1 contains one folder and one file
expect(await explorer.existsDirectoryNode('sampleFolder')).toBe(true);
expect(await explorer.existsFileNode('sample.txt')).toBe(true);
// resources/sample-files2 contains one file
expect(fileStatElements.length).toBe(3);
expect(await explorer.existsFileNode('another-sample.txt')).toBe(true);
});

});

0 comments on commit ff944de

Please sign in to comment.