@theia/playwright 1.34.3 → 1.34.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +54 -54
- package/lib/index.d.ts +25 -25
- package/lib/index.js +52 -52
- package/lib/tests/fixtures/theia-fixture.d.ts +3 -3
- package/lib/tests/fixtures/theia-fixture.js +23 -23
- package/lib/tests/theia-app.test.d.ts +1 -1
- package/lib/tests/theia-app.test.js +29 -29
- package/lib/tests/theia-explorer-view.test.d.ts +1 -1
- package/lib/tests/theia-explorer-view.test.js +109 -109
- package/lib/tests/theia-main-menu.test.d.ts +1 -1
- package/lib/tests/theia-main-menu.test.js +73 -73
- package/lib/tests/theia-preference-view.test.d.ts +1 -1
- package/lib/tests/theia-preference-view.test.js +99 -99
- package/lib/tests/theia-problems-view.test.d.ts +1 -1
- package/lib/tests/theia-problems-view.test.js +52 -52
- package/lib/tests/theia-quick-command.test.d.ts +1 -1
- package/lib/tests/theia-quick-command.test.js +53 -53
- package/lib/tests/theia-sample-app.test.d.ts +1 -1
- package/lib/tests/theia-sample-app.test.js +80 -80
- package/lib/tests/theia-status-bar.test.d.ts +1 -1
- package/lib/tests/theia-status-bar.test.js +41 -41
- package/lib/tests/theia-text-editor.test.d.ts +1 -1
- package/lib/tests/theia-text-editor.test.js +152 -152
- package/lib/tests/theia-workspace.test.d.ts +1 -1
- package/lib/tests/theia-workspace.test.js +47 -47
- package/lib/theia-about-dialog.d.ts +4 -4
- package/lib/theia-about-dialog.js +26 -26
- package/lib/theia-app.d.ts +43 -43
- package/lib/theia-app.js +135 -135
- package/lib/theia-context-menu.d.ts +8 -8
- package/lib/theia-context-menu.js +37 -37
- package/lib/theia-dialog.d.ts +27 -27
- package/lib/theia-dialog.js +98 -98
- package/lib/theia-editor.d.ts +9 -9
- package/lib/theia-editor.js +68 -68
- package/lib/theia-explorer-view.d.ts +38 -38
- package/lib/theia-explorer-view.js +209 -209
- package/lib/theia-main-menu.d.ts +12 -12
- package/lib/theia-main-menu.js +53 -53
- package/lib/theia-menu-item.d.ts +14 -14
- package/lib/theia-menu-item.js +66 -66
- package/lib/theia-menu.d.ts +16 -16
- package/lib/theia-menu.js +86 -86
- package/lib/theia-notification-indicator.d.ts +7 -7
- package/lib/theia-notification-indicator.js +44 -44
- package/lib/theia-notification-overlay.d.ts +22 -22
- package/lib/theia-notification-overlay.js +79 -79
- package/lib/theia-page-object.d.ts +7 -7
- package/lib/theia-page-object.js +27 -27
- package/lib/theia-preference-view.d.ts +76 -76
- package/lib/theia-preference-view.js +201 -201
- package/lib/theia-problem-indicator.d.ts +8 -8
- package/lib/theia-problem-indicator.js +38 -38
- package/lib/theia-problem-view.d.ts +5 -5
- package/lib/theia-problem-view.js +30 -30
- package/lib/theia-quick-command-palette.d.ts +11 -11
- package/lib/theia-quick-command-palette.js +73 -73
- package/lib/theia-rename-dialog.d.ts +5 -5
- package/lib/theia-rename-dialog.js +35 -35
- package/lib/theia-status-bar.d.ts +13 -13
- package/lib/theia-status-bar.js +39 -39
- package/lib/theia-status-indicator.d.ts +10 -10
- package/lib/theia-status-indicator.js +48 -48
- package/lib/theia-text-editor.d.ts +27 -27
- package/lib/theia-text-editor.js +149 -149
- package/lib/theia-toggle-bottom-indicator.d.ts +4 -4
- package/lib/theia-toggle-bottom-indicator.js +26 -26
- package/lib/theia-tree-node.d.ts +16 -16
- package/lib/theia-tree-node.js +53 -53
- package/lib/theia-view.d.ts +32 -32
- package/lib/theia-view.js +151 -151
- package/lib/theia-workspace.d.ts +18 -18
- package/lib/theia-workspace.js +69 -69
- package/lib/util.d.ts +19 -19
- package/lib/util.js +93 -93
- package/package.json +2 -2
- package/src/index.ts +41 -41
- package/src/tests/fixtures/theia-fixture.ts +25 -25
- package/src/tests/resources/sample-files1/sample.txt +4 -4
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-2.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-1.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-2.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-1.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-2.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-1.txt +1 -1
- package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-2.txt +1 -1
- package/src/tests/resources/sample-files2/another-sample.txt +1 -1
- package/src/tests/theia-app.test.ts +34 -34
- package/src/tests/theia-explorer-view.test.ts +124 -124
- package/src/tests/theia-main-menu.test.ts +89 -89
- package/src/tests/theia-preference-view.test.ts +118 -118
- package/src/tests/theia-problems-view.test.ts +60 -60
- package/src/tests/theia-quick-command.test.ts +61 -61
- package/src/tests/theia-sample-app.test.ts +92 -92
- package/src/tests/theia-status-bar.test.ts +47 -47
- package/src/tests/theia-text-editor.test.ts +182 -182
- package/src/tests/theia-workspace.test.ts +51 -51
- package/src/theia-about-dialog.ts +26 -26
- package/src/theia-app.ts +154 -154
- package/src/theia-context-menu.ts +42 -42
- package/src/theia-dialog.ts +113 -113
- package/src/theia-editor.ts +73 -73
- package/src/theia-explorer-view.ts +234 -234
- package/src/theia-main-menu.ts +54 -54
- package/src/theia-menu-item.ts +75 -75
- package/src/theia-menu.ts +96 -96
- package/src/theia-notification-indicator.ts +44 -44
- package/src/theia-notification-overlay.ts +94 -94
- package/src/theia-page-object.ts +29 -29
- package/src/theia-preference-view.ts +232 -232
- package/src/theia-problem-indicator.ts +37 -37
- package/src/theia-problem-view.ts +30 -30
- package/src/theia-quick-command-palette.ts +75 -75
- package/src/theia-rename-dialog.ts +36 -36
- package/src/theia-status-bar.ts +44 -44
- package/src/theia-status-indicator.ts +50 -50
- package/src/theia-text-editor.ts +172 -172
- package/src/theia-toggle-bottom-indicator.ts +21 -21
- package/src/theia-tree-node.ts +60 -60
- package/src/theia-view.ts +178 -178
- package/src/theia-workspace.ts +76 -76
- package/src/util.ts +91 -91
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { TheiaApp } from '../theia-app';
|
|
18
|
-
import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
|
|
19
|
-
import { TheiaWorkspace } from '../theia-workspace';
|
|
20
|
-
import { expect } from '@playwright/test';
|
|
21
|
-
import test, { page } from './fixtures/theia-fixture';
|
|
22
|
-
|
|
23
|
-
test.describe('Theia Workspace', () => {
|
|
24
|
-
|
|
25
|
-
test('should be initialized empty by default', async () => {
|
|
26
|
-
const app = await TheiaApp.load(page);
|
|
27
|
-
const explorer = await app.openView(TheiaExplorerView);
|
|
28
|
-
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
29
|
-
expect(fileStatElements.length).toBe(0);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('should be initialized with the contents of a file location', async () => {
|
|
33
|
-
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
|
|
34
|
-
const app = await TheiaApp.load(page, ws);
|
|
35
|
-
const explorer = await app.openView(TheiaExplorerView);
|
|
36
|
-
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
37
|
-
// resources/sample-files1 contains one folder and one file
|
|
38
|
-
expect(fileStatElements.length).toBe(2);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should be initialized with the contents of multiple file locations', async () => {
|
|
42
|
-
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1', 'src/tests/resources/sample-files2']);
|
|
43
|
-
const app = await TheiaApp.load(page, ws);
|
|
44
|
-
const explorer = await app.openView(TheiaExplorerView);
|
|
45
|
-
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
46
|
-
// resources/sample-files1 contains one folder and one file
|
|
47
|
-
// resources/sample-files2 contains one file
|
|
48
|
-
expect(fileStatElements.length).toBe(3);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { TheiaApp } from '../theia-app';
|
|
18
|
+
import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
|
|
19
|
+
import { TheiaWorkspace } from '../theia-workspace';
|
|
20
|
+
import { expect } from '@playwright/test';
|
|
21
|
+
import test, { page } from './fixtures/theia-fixture';
|
|
22
|
+
|
|
23
|
+
test.describe('Theia Workspace', () => {
|
|
24
|
+
|
|
25
|
+
test('should be initialized empty by default', async () => {
|
|
26
|
+
const app = await TheiaApp.load(page);
|
|
27
|
+
const explorer = await app.openView(TheiaExplorerView);
|
|
28
|
+
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
29
|
+
expect(fileStatElements.length).toBe(0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('should be initialized with the contents of a file location', async () => {
|
|
33
|
+
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
|
|
34
|
+
const app = await TheiaApp.load(page, ws);
|
|
35
|
+
const explorer = await app.openView(TheiaExplorerView);
|
|
36
|
+
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
37
|
+
// resources/sample-files1 contains one folder and one file
|
|
38
|
+
expect(fileStatElements.length).toBe(2);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('should be initialized with the contents of multiple file locations', async () => {
|
|
42
|
+
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1', 'src/tests/resources/sample-files2']);
|
|
43
|
+
const app = await TheiaApp.load(page, ws);
|
|
44
|
+
const explorer = await app.openView(TheiaExplorerView);
|
|
45
|
+
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
46
|
+
// resources/sample-files1 contains one folder and one file
|
|
47
|
+
// resources/sample-files2 contains one file
|
|
48
|
+
expect(fileStatElements.length).toBe(3);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { TheiaDialog } from './theia-dialog';
|
|
18
|
-
|
|
19
|
-
export class TheiaAboutDialog extends TheiaDialog {
|
|
20
|
-
|
|
21
|
-
override async isVisible(): Promise<boolean> {
|
|
22
|
-
const dialog = await this.page.$(`${this.blockSelector} .theia-aboutDialog`);
|
|
23
|
-
return !!dialog && dialog.isVisible();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { TheiaDialog } from './theia-dialog';
|
|
18
|
+
|
|
19
|
+
export class TheiaAboutDialog extends TheiaDialog {
|
|
20
|
+
|
|
21
|
+
override async isVisible(): Promise<boolean> {
|
|
22
|
+
const dialog = await this.page.$(`${this.blockSelector} .theia-aboutDialog`);
|
|
23
|
+
return !!dialog && dialog.isVisible();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
package/src/theia-app.ts
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { Page } from '@playwright/test';
|
|
18
|
-
import { TheiaEditor } from './theia-editor';
|
|
19
|
-
import { DOT_FILES_FILTER, TheiaExplorerView } from './theia-explorer-view';
|
|
20
|
-
import { TheiaMenuBar } from './theia-main-menu';
|
|
21
|
-
import { TheiaPreferenceScope, TheiaPreferenceView } from './theia-preference-view';
|
|
22
|
-
import { TheiaQuickCommandPalette } from './theia-quick-command-palette';
|
|
23
|
-
import { TheiaStatusBar } from './theia-status-bar';
|
|
24
|
-
import { TheiaView } from './theia-view';
|
|
25
|
-
import { TheiaWorkspace } from './theia-workspace';
|
|
26
|
-
|
|
27
|
-
export interface TheiaAppData {
|
|
28
|
-
loadingSelector: string;
|
|
29
|
-
shellSelector: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const DefaultTheiaAppData: TheiaAppData = {
|
|
33
|
-
loadingSelector: '.theia-preload',
|
|
34
|
-
shellSelector: '.theia-ApplicationShell'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export class TheiaApp {
|
|
38
|
-
|
|
39
|
-
readonly statusBar = new TheiaStatusBar(this);
|
|
40
|
-
readonly quickCommandPalette = new TheiaQuickCommandPalette(this);
|
|
41
|
-
readonly menuBar = new TheiaMenuBar(this);
|
|
42
|
-
public workspace: TheiaWorkspace;
|
|
43
|
-
|
|
44
|
-
static async load(page: Page, initialWorkspace?: TheiaWorkspace): Promise<TheiaApp> {
|
|
45
|
-
return this.loadApp(page, TheiaApp, initialWorkspace);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static async loadApp<T extends TheiaApp>(page: Page, appFactory: { new(page: Page, initialWorkspace?: TheiaWorkspace): T }, initialWorkspace?: TheiaWorkspace): Promise<T> {
|
|
49
|
-
const app = new appFactory(page, initialWorkspace);
|
|
50
|
-
await app.load();
|
|
51
|
-
return app;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public constructor(public page: Page, initialWorkspace?: TheiaWorkspace, protected appData = DefaultTheiaAppData) {
|
|
55
|
-
this.workspace = initialWorkspace ? initialWorkspace : new TheiaWorkspace();
|
|
56
|
-
this.workspace.initialize();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected async load(): Promise<void> {
|
|
60
|
-
await this.loadOrReload(this.page, '/#' + this.workspace.urlEncodedPath);
|
|
61
|
-
await this.page.waitForSelector(this.appData.loadingSelector, { state: 'detached' });
|
|
62
|
-
await this.page.waitForSelector(this.appData.shellSelector);
|
|
63
|
-
await this.waitForInitialized();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected async loadOrReload(page: Page, url: string): Promise<void> {
|
|
67
|
-
if (page.url() === url) {
|
|
68
|
-
await page.reload();
|
|
69
|
-
} else {
|
|
70
|
-
const wasLoadedAlready = await page.isVisible(this.appData.shellSelector);
|
|
71
|
-
await page.goto(url);
|
|
72
|
-
if (wasLoadedAlready) {
|
|
73
|
-
// Theia doesn't refresh on URL change only
|
|
74
|
-
// So we need to reload if the app was already loaded before
|
|
75
|
-
await page.reload();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async isMainContentPanelVisible(): Promise<boolean> {
|
|
81
|
-
const contentPanel = await this.page.$('#theia-main-content-panel');
|
|
82
|
-
return !!contentPanel && contentPanel.isVisible();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async openPreferences(viewFactory: { new(app: TheiaApp): TheiaPreferenceView }, preferenceScope = TheiaPreferenceScope.Workspace): Promise<TheiaPreferenceView> {
|
|
86
|
-
const view = new viewFactory(this);
|
|
87
|
-
if (await view.isTabVisible()) {
|
|
88
|
-
await view.activate();
|
|
89
|
-
return view;
|
|
90
|
-
}
|
|
91
|
-
await view.open(preferenceScope);
|
|
92
|
-
return view;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async openView<T extends TheiaView>(viewFactory: { new(app: TheiaApp): T }): Promise<T> {
|
|
96
|
-
const view = new viewFactory(this);
|
|
97
|
-
if (await view.isTabVisible()) {
|
|
98
|
-
await view.activate();
|
|
99
|
-
return view;
|
|
100
|
-
}
|
|
101
|
-
await view.open();
|
|
102
|
-
return view;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async openEditor<T extends TheiaEditor>(filePath: string, editorFactory: { new(filePath: string, app: TheiaApp): T },
|
|
106
|
-
editorName?: string, expectFileNodes = true): Promise<T> {
|
|
107
|
-
const explorer = await this.openView(TheiaExplorerView);
|
|
108
|
-
if (!explorer) {
|
|
109
|
-
throw Error('TheiaExplorerView could not be opened.');
|
|
110
|
-
}
|
|
111
|
-
if (expectFileNodes) {
|
|
112
|
-
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
113
|
-
if (fileStatElements.length < 1) {
|
|
114
|
-
throw Error('TheiaExplorerView is empty.');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const fileNode = await explorer.fileStatNode(filePath);
|
|
118
|
-
if (!fileNode || ! await fileNode?.isFile()) {
|
|
119
|
-
throw Error(`Specified path '${filePath}' could not be found or isn't a file.`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const editor = new editorFactory(filePath, this);
|
|
123
|
-
const contextMenu = await fileNode.openContextMenu();
|
|
124
|
-
const editorToUse = editorName ? editorName : editor.name ? editor.name : undefined;
|
|
125
|
-
if (editorToUse) {
|
|
126
|
-
const menuItem = await contextMenu.menuItemByNamePath('Open With', editorToUse);
|
|
127
|
-
if (!menuItem) {
|
|
128
|
-
throw Error(`Editor named '${editorName}' could not be found in "Open With" menu.`);
|
|
129
|
-
}
|
|
130
|
-
await menuItem.click();
|
|
131
|
-
} else {
|
|
132
|
-
await contextMenu.clickMenuItem('Open');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
await editor.waitForVisible();
|
|
136
|
-
return editor;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async activateExistingEditor<T extends TheiaEditor>(filePath: string, editorFactory: { new(filePath: string, app: TheiaApp): T }): Promise<T> {
|
|
140
|
-
const editor = new editorFactory(filePath, this);
|
|
141
|
-
if (!await editor.isTabVisible()) {
|
|
142
|
-
throw new Error(`Could not find opened editor for file ${filePath}`);
|
|
143
|
-
}
|
|
144
|
-
await editor.activate();
|
|
145
|
-
await editor.waitForVisible();
|
|
146
|
-
return editor;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** Specific Theia apps may add additional conditions to wait for. */
|
|
150
|
-
async waitForInitialized(): Promise<void> {
|
|
151
|
-
// empty by default
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Page } from '@playwright/test';
|
|
18
|
+
import { TheiaEditor } from './theia-editor';
|
|
19
|
+
import { DOT_FILES_FILTER, TheiaExplorerView } from './theia-explorer-view';
|
|
20
|
+
import { TheiaMenuBar } from './theia-main-menu';
|
|
21
|
+
import { TheiaPreferenceScope, TheiaPreferenceView } from './theia-preference-view';
|
|
22
|
+
import { TheiaQuickCommandPalette } from './theia-quick-command-palette';
|
|
23
|
+
import { TheiaStatusBar } from './theia-status-bar';
|
|
24
|
+
import { TheiaView } from './theia-view';
|
|
25
|
+
import { TheiaWorkspace } from './theia-workspace';
|
|
26
|
+
|
|
27
|
+
export interface TheiaAppData {
|
|
28
|
+
loadingSelector: string;
|
|
29
|
+
shellSelector: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const DefaultTheiaAppData: TheiaAppData = {
|
|
33
|
+
loadingSelector: '.theia-preload',
|
|
34
|
+
shellSelector: '.theia-ApplicationShell'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class TheiaApp {
|
|
38
|
+
|
|
39
|
+
readonly statusBar = new TheiaStatusBar(this);
|
|
40
|
+
readonly quickCommandPalette = new TheiaQuickCommandPalette(this);
|
|
41
|
+
readonly menuBar = new TheiaMenuBar(this);
|
|
42
|
+
public workspace: TheiaWorkspace;
|
|
43
|
+
|
|
44
|
+
static async load(page: Page, initialWorkspace?: TheiaWorkspace): Promise<TheiaApp> {
|
|
45
|
+
return this.loadApp(page, TheiaApp, initialWorkspace);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static async loadApp<T extends TheiaApp>(page: Page, appFactory: { new(page: Page, initialWorkspace?: TheiaWorkspace): T }, initialWorkspace?: TheiaWorkspace): Promise<T> {
|
|
49
|
+
const app = new appFactory(page, initialWorkspace);
|
|
50
|
+
await app.load();
|
|
51
|
+
return app;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public constructor(public page: Page, initialWorkspace?: TheiaWorkspace, protected appData = DefaultTheiaAppData) {
|
|
55
|
+
this.workspace = initialWorkspace ? initialWorkspace : new TheiaWorkspace();
|
|
56
|
+
this.workspace.initialize();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected async load(): Promise<void> {
|
|
60
|
+
await this.loadOrReload(this.page, '/#' + this.workspace.urlEncodedPath);
|
|
61
|
+
await this.page.waitForSelector(this.appData.loadingSelector, { state: 'detached' });
|
|
62
|
+
await this.page.waitForSelector(this.appData.shellSelector);
|
|
63
|
+
await this.waitForInitialized();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected async loadOrReload(page: Page, url: string): Promise<void> {
|
|
67
|
+
if (page.url() === url) {
|
|
68
|
+
await page.reload();
|
|
69
|
+
} else {
|
|
70
|
+
const wasLoadedAlready = await page.isVisible(this.appData.shellSelector);
|
|
71
|
+
await page.goto(url);
|
|
72
|
+
if (wasLoadedAlready) {
|
|
73
|
+
// Theia doesn't refresh on URL change only
|
|
74
|
+
// So we need to reload if the app was already loaded before
|
|
75
|
+
await page.reload();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async isMainContentPanelVisible(): Promise<boolean> {
|
|
81
|
+
const contentPanel = await this.page.$('#theia-main-content-panel');
|
|
82
|
+
return !!contentPanel && contentPanel.isVisible();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async openPreferences(viewFactory: { new(app: TheiaApp): TheiaPreferenceView }, preferenceScope = TheiaPreferenceScope.Workspace): Promise<TheiaPreferenceView> {
|
|
86
|
+
const view = new viewFactory(this);
|
|
87
|
+
if (await view.isTabVisible()) {
|
|
88
|
+
await view.activate();
|
|
89
|
+
return view;
|
|
90
|
+
}
|
|
91
|
+
await view.open(preferenceScope);
|
|
92
|
+
return view;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async openView<T extends TheiaView>(viewFactory: { new(app: TheiaApp): T }): Promise<T> {
|
|
96
|
+
const view = new viewFactory(this);
|
|
97
|
+
if (await view.isTabVisible()) {
|
|
98
|
+
await view.activate();
|
|
99
|
+
return view;
|
|
100
|
+
}
|
|
101
|
+
await view.open();
|
|
102
|
+
return view;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async openEditor<T extends TheiaEditor>(filePath: string, editorFactory: { new(filePath: string, app: TheiaApp): T },
|
|
106
|
+
editorName?: string, expectFileNodes = true): Promise<T> {
|
|
107
|
+
const explorer = await this.openView(TheiaExplorerView);
|
|
108
|
+
if (!explorer) {
|
|
109
|
+
throw Error('TheiaExplorerView could not be opened.');
|
|
110
|
+
}
|
|
111
|
+
if (expectFileNodes) {
|
|
112
|
+
const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
|
|
113
|
+
if (fileStatElements.length < 1) {
|
|
114
|
+
throw Error('TheiaExplorerView is empty.');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const fileNode = await explorer.fileStatNode(filePath);
|
|
118
|
+
if (!fileNode || ! await fileNode?.isFile()) {
|
|
119
|
+
throw Error(`Specified path '${filePath}' could not be found or isn't a file.`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const editor = new editorFactory(filePath, this);
|
|
123
|
+
const contextMenu = await fileNode.openContextMenu();
|
|
124
|
+
const editorToUse = editorName ? editorName : editor.name ? editor.name : undefined;
|
|
125
|
+
if (editorToUse) {
|
|
126
|
+
const menuItem = await contextMenu.menuItemByNamePath('Open With', editorToUse);
|
|
127
|
+
if (!menuItem) {
|
|
128
|
+
throw Error(`Editor named '${editorName}' could not be found in "Open With" menu.`);
|
|
129
|
+
}
|
|
130
|
+
await menuItem.click();
|
|
131
|
+
} else {
|
|
132
|
+
await contextMenu.clickMenuItem('Open');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
await editor.waitForVisible();
|
|
136
|
+
return editor;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async activateExistingEditor<T extends TheiaEditor>(filePath: string, editorFactory: { new(filePath: string, app: TheiaApp): T }): Promise<T> {
|
|
140
|
+
const editor = new editorFactory(filePath, this);
|
|
141
|
+
if (!await editor.isTabVisible()) {
|
|
142
|
+
throw new Error(`Could not find opened editor for file ${filePath}`);
|
|
143
|
+
}
|
|
144
|
+
await editor.activate();
|
|
145
|
+
await editor.waitForVisible();
|
|
146
|
+
return editor;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Specific Theia apps may add additional conditions to wait for. */
|
|
150
|
+
async waitForInitialized(): Promise<void> {
|
|
151
|
+
// empty by default
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ElementHandle } from '@playwright/test';
|
|
18
|
-
|
|
19
|
-
import { TheiaApp } from './theia-app';
|
|
20
|
-
import { TheiaMenu } from './theia-menu';
|
|
21
|
-
|
|
22
|
-
export class TheiaContextMenu extends TheiaMenu {
|
|
23
|
-
|
|
24
|
-
public static async openAt(app: TheiaApp, x: number, y: number): Promise<TheiaContextMenu> {
|
|
25
|
-
await app.page.mouse.move(x, y);
|
|
26
|
-
await app.page.mouse.click(x, y, { button: 'right' });
|
|
27
|
-
return TheiaContextMenu.returnWhenVisible(app);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public static async open(app: TheiaApp, element: () => Promise<ElementHandle<SVGElement | HTMLElement>>): Promise<TheiaContextMenu> {
|
|
31
|
-
const elementHandle = await element();
|
|
32
|
-
await elementHandle.click({ button: 'right' });
|
|
33
|
-
return TheiaContextMenu.returnWhenVisible(app);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private static async returnWhenVisible(app: TheiaApp): Promise<TheiaContextMenu> {
|
|
37
|
-
const menu = new TheiaContextMenu(app);
|
|
38
|
-
await menu.waitForVisible();
|
|
39
|
-
return menu;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ElementHandle } from '@playwright/test';
|
|
18
|
+
|
|
19
|
+
import { TheiaApp } from './theia-app';
|
|
20
|
+
import { TheiaMenu } from './theia-menu';
|
|
21
|
+
|
|
22
|
+
export class TheiaContextMenu extends TheiaMenu {
|
|
23
|
+
|
|
24
|
+
public static async openAt(app: TheiaApp, x: number, y: number): Promise<TheiaContextMenu> {
|
|
25
|
+
await app.page.mouse.move(x, y);
|
|
26
|
+
await app.page.mouse.click(x, y, { button: 'right' });
|
|
27
|
+
return TheiaContextMenu.returnWhenVisible(app);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static async open(app: TheiaApp, element: () => Promise<ElementHandle<SVGElement | HTMLElement>>): Promise<TheiaContextMenu> {
|
|
31
|
+
const elementHandle = await element();
|
|
32
|
+
await elementHandle.click({ button: 'right' });
|
|
33
|
+
return TheiaContextMenu.returnWhenVisible(app);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static async returnWhenVisible(app: TheiaApp): Promise<TheiaContextMenu> {
|
|
37
|
+
const menu = new TheiaContextMenu(app);
|
|
38
|
+
await menu.waitForVisible();
|
|
39
|
+
return menu;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|