Skip to content

Commit

Permalink
Add test cases that use the main menu
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics

Signed-off-by: Olaf Lessenich <[email protected]>
  • Loading branch information
xai committed Feb 22, 2023
1 parent 50122d7 commit 54798d2
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions examples/playwright/src/tests/theia-electron-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,72 @@ import { TheiaExplorerView } from '../theia-explorer-view';
import { TheiaAboutDialog } from '../theia-about-dialog';
import { ElectronLaunchOptions, TheiaElectronAppLoader } from '../theia-app-loader';
import { TheiaWorkspace } from '../theia-workspace';
import { TheiaApp } from '../theia-app';

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

let ws: TheiaWorkspace;
let app: TheiaApp;

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

test('should load and show main content panel', async () => {
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
const app = await TheiaElectronAppLoader.load(new ElectronLaunchOptions('../electron', '../../plugins'), ws);
expect(await app.isMainContentPanelVisible()).toBe(true);
});

const quickCommand = app.quickCommandPalette;
test('open about dialog using menu', async () => {
// open about dialog using menu
await (await app.menuBar.openMenu('Help')).clickMenuItem('About');
const aboutDialog = new TheiaAboutDialog(app);
expect(await aboutDialog.isVisible()).toBe(true);
await aboutDialog.close();
expect(await aboutDialog.isVisible()).toBe(false);
});

test('toggle explorer view using menu', async () => {
await (await app.menuBar.openMenu('View')).clickMenuItem('Explorer');
const explorerView = new TheiaExplorerView(app);
expect(await explorerView.isDisplayed()).toBe(true);
await (await app.menuBar.openMenu('View')).clickMenuItem('Explorer');
expect(await explorerView.isDisplayed()).toBe(false);
});

test('open quick command palette', async () => {
const quickCommand = app.quickCommandPalette;
expect(await quickCommand.isOpen()).toBe(false);
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
});

test('open about dialog using command', async () => {
const quickCommand = app.quickCommandPalette;
await quickCommand.open();
await quickCommand.type('About');
await quickCommand.trigger('About');
expect(await quickCommand.isOpen()).toBe(false);
const aboutDialog = new TheiaAboutDialog(app);
expect(await quickCommand.isOpen()).toBe(false);
expect(await aboutDialog.isVisible()).toBe(true);
await aboutDialog.close();
expect(await aboutDialog.isVisible()).toBe(false);
});

test('select all using command', async () => {
const quickCommand = app.quickCommandPalette;
await quickCommand.type('Select All');
await quickCommand.trigger('Select All');
expect(await quickCommand.isOpen()).toBe(false);
});

test('toggle explorer view using command', async () => {
const quickCommand = app.quickCommandPalette;
const explorerView = new TheiaExplorerView(app);
await quickCommand.open();
await quickCommand.type('Toggle Explorer');
await quickCommand.trigger('Toggle Explorer View');
expect(await quickCommand.isOpen()).toBe(false);
const explorerView = new TheiaExplorerView(app);
expect(await explorerView.isDisplayed()).toBe(true);
});

});

0 comments on commit 54798d2

Please sign in to comment.