Skip to content

Commit a70cf99

Browse files
committed
Add electron playwright test case that opens a file
Contributed on behalf of STMicroelectronics Signed-off-by: Olaf Lessenich <[email protected]>
1 parent 17c3a58 commit a70cf99

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

examples/playwright/src/tests/theia-electron-app.test.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ import { ElectronLaunchOptions, TheiaElectronAppLoader } from '../theia-app-load
2121
import { TheiaWorkspace } from '../theia-workspace';
2222
import { TheiaApp } from '../theia-app';
2323

24+
test.describe.configure({ mode: 'serial' });
2425
test.describe('Theia Electron Application', () => {
2526

26-
let ws: TheiaWorkspace;
2727
let app: TheiaApp;
2828

2929
test.beforeAll(async () => {
30-
ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
30+
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
3131
app = await TheiaElectronAppLoader.load(new ElectronLaunchOptions('../electron', '../../plugins'), ws);
3232
});
3333

34+
test.afterAll(async () => {
35+
await app.page.close();
36+
});
37+
3438
test('should load and show main content panel', async () => {
3539
expect(await app.isMainContentPanelVisible()).toBe(true);
3640
});
@@ -44,6 +48,27 @@ test.describe('Theia Electron Application', () => {
4448
expect(await aboutDialog.isVisible()).toBe(false);
4549
});
4650

51+
test('open file via file menu and cancel', async () => {
52+
await (await app.menuBar.openMenu('File')).clickMenuItem('Open File...');
53+
const fileDialog = await app.page.waitForSelector('div[class="dialogBlock"]');
54+
expect(await fileDialog.isVisible()).toBe(true);
55+
await app.page.getByRole('button', { name: 'Cancel' }).click();
56+
expect(await fileDialog.isVisible()).toBe(false);
57+
});
58+
59+
test('open sample.txt via file menu', async () => {
60+
await (await app.menuBar.openMenu('File')).clickMenuItem('Open File...');
61+
const fileDialog = await app.page.waitForSelector('div[class="dialogBlock"]');
62+
expect(await fileDialog.isVisible()).toBe(true);
63+
64+
const fileEntry = app.page.getByText('sample.txt');
65+
await fileEntry.click();
66+
await app.page.getByRole('button', { name: 'Open' }).click();
67+
68+
const span = await app.page.waitForSelector('span:has-text("content line 2")');
69+
expect(await span.isVisible()).toBe(true);
70+
});
71+
4772
test('toggle explorer view using menu', async () => {
4873
await (await app.menuBar.openMenu('View')).clickMenuItem('Explorer');
4974
const explorerView = new TheiaExplorerView(app);

0 commit comments

Comments
 (0)