Skip to content

Commit e1d7afe

Browse files
committed
Add test cases that use the main menu
Contributed on behalf of STMicroelectronics Signed-off-by: Olaf Lessenich <[email protected]>
1 parent 1d622dc commit e1d7afe

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

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

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,72 @@ import { TheiaExplorerView } from '../theia-explorer-view';
1919
import { TheiaAboutDialog } from '../theia-about-dialog';
2020
import { ElectronLaunchOptions, TheiaElectronAppLoader } from '../theia-app-loader';
2121
import { TheiaWorkspace } from '../theia-workspace';
22+
import { TheiaApp } from '../theia-app';
2223

2324
test.describe('Theia Electron Application', () => {
2425

26+
let ws: TheiaWorkspace;
27+
let app: TheiaApp;
28+
29+
test.beforeAll(async () => {
30+
ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
31+
app = await TheiaElectronAppLoader.load(new ElectronLaunchOptions('../electron', '../../plugins'), ws);
32+
});
33+
2534
test('should load and show main content panel', async () => {
26-
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
27-
const app = await TheiaElectronAppLoader.load(new ElectronLaunchOptions('../electron', '../../plugins'), ws);
2835
expect(await app.isMainContentPanelVisible()).toBe(true);
36+
});
2937

30-
const quickCommand = app.quickCommandPalette;
38+
test('open about dialog using menu', async () => {
39+
// open about dialog using menu
40+
await (await app.menuBar.openMenu('Help')).clickMenuItem('About');
41+
const aboutDialog = new TheiaAboutDialog(app);
42+
expect(await aboutDialog.isVisible()).toBe(true);
43+
await aboutDialog.close();
44+
expect(await aboutDialog.isVisible()).toBe(false);
45+
});
3146

47+
test('toggle explorer view using menu', async () => {
48+
await (await app.menuBar.openMenu('View')).clickMenuItem('Explorer');
49+
const explorerView = new TheiaExplorerView(app);
50+
expect(await explorerView.isDisplayed()).toBe(true);
51+
await (await app.menuBar.openMenu('View')).clickMenuItem('Explorer');
52+
expect(await explorerView.isDisplayed()).toBe(false);
53+
});
54+
55+
test('open quick command palette', async () => {
56+
const quickCommand = app.quickCommandPalette;
57+
expect(await quickCommand.isOpen()).toBe(false);
3258
await quickCommand.open();
3359
expect(await quickCommand.isOpen()).toBe(true);
60+
});
3461

62+
test('open about dialog using command', async () => {
63+
const quickCommand = app.quickCommandPalette;
3564
await quickCommand.open();
3665
await quickCommand.type('About');
3766
await quickCommand.trigger('About');
38-
expect(await quickCommand.isOpen()).toBe(false);
3967
const aboutDialog = new TheiaAboutDialog(app);
68+
expect(await quickCommand.isOpen()).toBe(false);
4069
expect(await aboutDialog.isVisible()).toBe(true);
4170
await aboutDialog.close();
42-
expect(await aboutDialog.isVisible()).toBe(false);
71+
});
4372

73+
test('select all using command', async () => {
74+
const quickCommand = app.quickCommandPalette;
4475
await quickCommand.type('Select All');
4576
await quickCommand.trigger('Select All');
4677
expect(await quickCommand.isOpen()).toBe(false);
78+
});
4779

80+
test('toggle explorer view using command', async () => {
81+
const quickCommand = app.quickCommandPalette;
82+
const explorerView = new TheiaExplorerView(app);
4883
await quickCommand.open();
4984
await quickCommand.type('Toggle Explorer');
5085
await quickCommand.trigger('Toggle Explorer View');
5186
expect(await quickCommand.isOpen()).toBe(false);
52-
const explorerView = new TheiaExplorerView(app);
5387
expect(await explorerView.isDisplayed()).toBe(true);
5488
});
55-
5689
});
90+

0 commit comments

Comments
 (0)