Skip to content

Commit

Permalink
First working version
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics.
Change-Id: I7c817b00262229ab096ecbbacca5c465b9fa6302
  • Loading branch information
planger authored and xai committed Jul 28, 2023
1 parent 6607185 commit 2e1e3d3
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 127 deletions.
1 change: 1 addition & 0 deletions examples/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

export * from './theia-about-dialog';
export * from './theia-app';
export * from './theia-app-loader';
export * from './theia-context-menu';
export * from './theia-dialog';
export * from './theia-editor';
Expand Down
25 changes: 0 additions & 25 deletions examples/playwright/src/tests/fixtures/theia-fixture.ts

This file was deleted.

15 changes: 4 additions & 11 deletions examples/playwright/src/tests/theia-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { TheiaApp } from '../theia-app';

import { expect } from '@playwright/test';
import test, { page } from './fixtures/theia-fixture';

let app: TheiaApp;
import { expect, test } from '@playwright/test';
import { TheiaBrowserAppLoader } from '../theia-app-loader';

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

test('should load', async () => {
app = await TheiaApp.load(page);
});

test('should show main content panel', async () => {
test('should load and should show main content panel', async ({ page }) => {
const app = await TheiaBrowserAppLoader.load(page);
expect(await app.isMainContentPanelVisible()).toBe(true);
});

Expand Down
56 changes: 56 additions & 0 deletions examples/playwright/src/tests/theia-electron-app.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// *****************************************************************************
// Copyright (C) 2022 STMicroelectronics and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// *****************************************************************************

import { expect, test } from '@playwright/test';
import { TheiaExplorerView } from '../theia-explorer-view';
import { TheiaAboutDialog } from '../theia-about-dialog';
import { ElectronLaunchOptions, TheiaElectronAppLoader } from '../theia-app-loader';
import { TheiaWorkspace } from '../theia-workspace';

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

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;

await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);

await quickCommand.open();
await quickCommand.type('About');
await quickCommand.trigger('About');
expect(await quickCommand.isOpen()).toBe(false);
const aboutDialog = new TheiaAboutDialog(app);
expect(await aboutDialog.isVisible()).toBe(true);
await aboutDialog.close();
expect(await aboutDialog.isVisible()).toBe(false);

await quickCommand.type('Select All');
await quickCommand.trigger('Select All');
expect(await quickCommand.isOpen()).toBe(false);

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);
});

});
21 changes: 14 additions & 7 deletions examples/playwright/src/tests/theia-explorer-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,31 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaApp } from '../theia-app';
import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
import { TheiaWorkspace } from '../theia-workspace';
import test, { page } from './fixtures/theia-fixture';

let app: TheiaApp;
let explorer: TheiaExplorerView;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Explorer View', () => {

test.beforeAll(async () => {
let app: TheiaApp;
let explorer: TheiaExplorerView;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
app = await TheiaApp.load(page, ws);
app = await TheiaBrowserAppLoader.load(page, ws);
explorer = await app.openView(TheiaExplorerView);
await explorer.waitForVisibleFileNodes();
});

test.afterAll(async () => {
await app.page.close();
});

test('should be visible and active after being opened', async () => {
expect(await explorer.isTabVisible()).toBe(true);
expect(await explorer.isDisplayed()).toBe(true);
Expand Down
22 changes: 15 additions & 7 deletions examples/playwright/src/tests/theia-main-menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { OSUtil } from '../util';
import { expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaMenuBar } from '../theia-main-menu';
import test, { page } from './fixtures/theia-fixture';

let menuBar: TheiaMenuBar;
import { OSUtil } from '../util';

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Main Menu', () => {

test.beforeAll(async () => {
const app = await TheiaApp.load(page);
let app: TheiaApp;
let menuBar: TheiaMenuBar;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page);
menuBar = app.menuBar;
});

test.afterAll(async () => {
await app.page.close();
});

test('should show the main menu bar', async () => {
const menuBarItems = await menuBar.visibleMenuBarItems();
expect(menuBarItems).toContain('File');
Expand Down
19 changes: 13 additions & 6 deletions examples/playwright/src/tests/theia-preference-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { DefaultPreferences, PreferenceIds, TheiaPreferenceView } from '../theia-preference-view';
import test, { page } from './fixtures/theia-fixture';

let app: TheiaApp;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Preference View', () => {

test.beforeAll(async () => {
app = await TheiaApp.load(page);
let app: TheiaApp;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page);
});

test.afterAll(async () => {
await app.page.close();
});

test('should be visible and active after being opened', async () => {
Expand Down
19 changes: 13 additions & 6 deletions examples/playwright/src/tests/theia-problems-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaProblemsView } from '../theia-problem-view';
import test, { page } from './fixtures/theia-fixture';

let app: TheiaApp;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Problems View', () => {

test.beforeAll(async () => {
app = await TheiaApp.load(page);
let app: TheiaApp;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page);
});

test.afterAll(async () => {
await app.page.close();
});

test('should be visible and active after being opened', async () => {
Expand Down
23 changes: 16 additions & 7 deletions examples/playwright/src/tests/theia-quick-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,32 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaAboutDialog } from '../theia-about-dialog';
import { TheiaApp } from '../theia-app';
import { TheiaExplorerView } from '../theia-explorer-view';
import { TheiaNotificationIndicator } from '../theia-notification-indicator';
import { TheiaNotificationOverlay } from '../theia-notification-overlay';
import { TheiaQuickCommandPalette } from '../theia-quick-command-palette';
import test, { page } from './fixtures/theia-fixture';

let app: TheiaApp;
let quickCommand: TheiaQuickCommandPalette;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Quick Command', () => {

test.beforeAll(async () => {
app = await TheiaApp.load(page);
let app: TheiaApp;
let quickCommand: TheiaQuickCommandPalette;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page);
quickCommand = app.quickCommandPalette;
});

test.afterAll(async () => {
await app.page.close();
});

test('should show quick command palette', async () => {
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
Expand All @@ -43,6 +50,7 @@ test.describe('Theia Quick Command', () => {
});

test('should trigger \'About\' command after typing', async () => {
await quickCommand.open();
await quickCommand.type('About');
await quickCommand.trigger('About');
expect(await quickCommand.isOpen()).toBe(false);
Expand All @@ -57,6 +65,7 @@ test.describe('Theia Quick Command', () => {
});

test('should trigger \'Toggle Explorer View\' command after typing', async () => {
await quickCommand.open();
await quickCommand.type('Toggle Explorer');
await quickCommand.trigger('Toggle Explorer View');
expect(await quickCommand.isOpen()).toBe(false);
Expand Down
20 changes: 14 additions & 6 deletions examples/playwright/src/tests/theia-sample-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaToolbar } from '../theia-toolbar';
import test, { page } from './fixtures/theia-fixture';
import { TheiaWorkspace } from '../theia-workspace';

class TheiaSampleApp extends TheiaApp {
protected toolbar = new TheiaToolbar(this);
Expand All @@ -35,12 +36,19 @@ class TheiaSampleApp extends TheiaApp {
}
}

let app: TheiaSampleApp;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Sample Application', () => {

test('should load', async () => {
app = await TheiaApp.loadApp(page, TheiaSampleApp);
let app: TheiaSampleApp;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page, new TheiaWorkspace(), TheiaSampleApp);
});

test.afterAll(async () => {
await app.page.close();
});

test('should start with visible toolbar', async () => {
Expand Down
20 changes: 14 additions & 6 deletions examples/playwright/src/tests/theia-status-bar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaBrowserAppLoader } from '../theia-app-loader';
import { TheiaNotificationIndicator } from '../theia-notification-indicator';
import { TheiaProblemIndicator } from '../theia-problem-indicator';
import { TheiaStatusBar } from '../theia-status-bar';
import { TheiaToggleBottomIndicator } from '../theia-toggle-bottom-indicator';
import test, { page } from './fixtures/theia-fixture';

let statusBar: TheiaStatusBar;

// the tests in this file reuse a page to run faster and thus are executed serially
test.describe.configure({ mode: 'serial' });
test.describe('Theia Status Bar', () => {

test.beforeAll(async () => {
const app = await TheiaApp.load(page);
let app: TheiaApp;
let statusBar: TheiaStatusBar;

test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
app = await TheiaBrowserAppLoader.load(page);
statusBar = app.statusBar;
});

test.afterAll(async () => {
await app.page.close();
});

test('should show status bar', async () => {
expect(await statusBar.isVisible()).toBe(true);
});
Expand Down
Loading

0 comments on commit 2e1e3d3

Please sign in to comment.