@eclipse-glsp/playwright-theia 2.9.0-next.12
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 +642 -0
- package/README.md +59 -0
- package/docs/theia-integration.md +61 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +33 -0
- package/lib/index.js.map +1 -0
- package/lib/integration/index.d.ts +20 -0
- package/lib/integration/index.d.ts.map +1 -0
- package/lib/integration/index.js +36 -0
- package/lib/integration/index.js.map +1 -0
- package/lib/integration/po/index.d.ts +19 -0
- package/lib/integration/po/index.d.ts.map +1 -0
- package/lib/integration/po/index.js +35 -0
- package/lib/integration/po/index.js.map +1 -0
- package/lib/integration/po/theia-glsp-app.po.d.ts +32 -0
- package/lib/integration/po/theia-glsp-app.po.d.ts.map +1 -0
- package/lib/integration/po/theia-glsp-app.po.js +43 -0
- package/lib/integration/po/theia-glsp-app.po.js.map +1 -0
- package/lib/integration/po/theia-glsp-editor.po.d.ts +25 -0
- package/lib/integration/po/theia-glsp-editor.po.d.ts.map +1 -0
- package/lib/integration/po/theia-glsp-editor.po.js +36 -0
- package/lib/integration/po/theia-glsp-editor.po.js.map +1 -0
- package/lib/integration/po/theia-notifications.po.d.ts +26 -0
- package/lib/integration/po/theia-notifications.po.d.ts.map +1 -0
- package/lib/integration/po/theia-notifications.po.js +38 -0
- package/lib/integration/po/theia-notifications.po.js.map +1 -0
- package/lib/integration/theia-keybindings.d.ts +25 -0
- package/lib/integration/theia-keybindings.d.ts.map +1 -0
- package/lib/integration/theia-keybindings.js +32 -0
- package/lib/integration/theia-keybindings.js.map +1 -0
- package/lib/integration/theia.integration.d.ts +65 -0
- package/lib/integration/theia.integration.d.ts.map +1 -0
- package/lib/integration/theia.integration.js +101 -0
- package/lib/integration/theia.integration.js.map +1 -0
- package/lib/integration/theia.options.d.ts +44 -0
- package/lib/integration/theia.options.d.ts.map +1 -0
- package/lib/integration/theia.options.js +26 -0
- package/lib/integration/theia.options.js.map +1 -0
- package/package.json +72 -0
- package/src/index.ts +16 -0
- package/src/integration/index.ts +19 -0
- package/src/integration/po/index.ts +18 -0
- package/src/integration/po/theia-glsp-app.po.ts +55 -0
- package/src/integration/po/theia-glsp-editor.po.ts +39 -0
- package/src/integration/po/theia-notifications.po.ts +40 -0
- package/src/integration/theia-keybindings.ts +25 -0
- package/src/integration/theia.integration.ts +123 -0
- package/src/integration/theia.options.ts +50 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023-2026 Business Informatics Group (TU Wien) 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 { Locator, Page } from '@playwright/test';
|
|
18
|
+
import { TheiaAppLoader, TheiaWorkspace } from '@theia/playwright';
|
|
19
|
+
import type {
|
|
20
|
+
DiagramShortcutIntegration,
|
|
21
|
+
DiagramShortcuts,
|
|
22
|
+
GLSPSemanticApp,
|
|
23
|
+
IntegrationArgs,
|
|
24
|
+
MarkerNavigator,
|
|
25
|
+
MarkerNavigatorIntegration
|
|
26
|
+
} from '@eclipse-glsp/playwright';
|
|
27
|
+
import { ContextMenuIntegration, hostDiagramShortcuts, Integration, SVGMetadataUtils } from '@eclipse-glsp/playwright';
|
|
28
|
+
import { TheiaMarkerNavigator } from './theia-keybindings';
|
|
29
|
+
import { TheiaGLSPApp } from './po/theia-glsp-app.po';
|
|
30
|
+
import { TheiaGLSPEditor } from './po/theia-glsp-editor.po';
|
|
31
|
+
import { TheiaIntegrationConfig, TheiaIntegrationOptions } from './theia.options';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The {@link TheiaIntegration} provides the glue code for working
|
|
35
|
+
* with the Theia version of the GLSP-Client.
|
|
36
|
+
*/
|
|
37
|
+
export class TheiaIntegration
|
|
38
|
+
extends Integration
|
|
39
|
+
implements ContextMenuIntegration, DiagramShortcutIntegration, MarkerNavigatorIntegration
|
|
40
|
+
{
|
|
41
|
+
protected theiaApp: TheiaGLSPApp;
|
|
42
|
+
|
|
43
|
+
readonly diagramShortcuts: DiagramShortcuts = hostDiagramShortcuts;
|
|
44
|
+
|
|
45
|
+
override get page(): Page {
|
|
46
|
+
return this.theiaApp.page;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get contextMenuLocator(): Locator {
|
|
50
|
+
return this.page.locator('body > .lm-Widget.lm-Menu');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
args: IntegrationArgs,
|
|
55
|
+
protected readonly options: TheiaIntegrationOptions
|
|
56
|
+
) {
|
|
57
|
+
super(args, 'Theia');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Theia rebinds the marker navigation keys, so it contributes its own navigator.
|
|
62
|
+
*/
|
|
63
|
+
createMarkerNavigator(app: GLSPSemanticApp): MarkerNavigator {
|
|
64
|
+
return new TheiaMarkerNavigator(app);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Closes the page {@link TheiaAppLoader} created outside Playwright's test fixtures, which also
|
|
69
|
+
* disposes of its browser context. Only needed before `@theia/playwright` 1.77: since then the
|
|
70
|
+
* loader runs the application on the passed fixture page, which the fixture owns and closes itself.
|
|
71
|
+
*/
|
|
72
|
+
override async close(): Promise<void> {
|
|
73
|
+
if (this.theiaApp && this.theiaApp.page !== this.args.page) {
|
|
74
|
+
await this.theiaApp.page.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected override async launch(): Promise<void> {
|
|
79
|
+
const ws = new TheiaWorkspace(this.options.workspace ? [this.options.workspace] : undefined);
|
|
80
|
+
this.theiaApp = await TheiaAppLoader.load(this.args, ws, TheiaGLSPApp as any);
|
|
81
|
+
this.theiaApp.initialize(this.options);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected override async afterLaunch(): Promise<void> {
|
|
85
|
+
if (this.options.file) {
|
|
86
|
+
await this.theiaApp.openEditor(this.options.file, TheiaGLSPEditor);
|
|
87
|
+
await this.assertMetadataAPI();
|
|
88
|
+
await this.theiaApp.notifications.closeAll();
|
|
89
|
+
|
|
90
|
+
const selector = `${SVGMetadataUtils.typeAttrOf('graph')} svg.sprotty-graph > g`;
|
|
91
|
+
await this.page.waitForSelector(selector);
|
|
92
|
+
// Reset mouse state
|
|
93
|
+
await this.page.click(selector, { force: true });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates {@link TheiaIntegrationOptions} for use as the `integrationOptions` test option.
|
|
100
|
+
*
|
|
101
|
+
* The returned options carry the factory that the `integration` fixture uses to instantiate
|
|
102
|
+
* the {@link TheiaIntegration}, which is how this integration plugs in without the core
|
|
103
|
+
* framework having to import it.
|
|
104
|
+
*
|
|
105
|
+
* **Usage**
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* const integrationOptions = defineTheiaIntegration({
|
|
109
|
+
* url: 'http://localhost:3000',
|
|
110
|
+
* widgetId: 'workflow-diagram'
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @param config Theia specific configuration
|
|
115
|
+
* @returns Options carrying the factory for the {@link TheiaIntegration}
|
|
116
|
+
*/
|
|
117
|
+
export function defineTheiaIntegration(config: TheiaIntegrationConfig): TheiaIntegrationOptions {
|
|
118
|
+
return {
|
|
119
|
+
...config,
|
|
120
|
+
type: 'Theia',
|
|
121
|
+
integrationFactory: (args, options) => new TheiaIntegration(args, options)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023-2026 Business Informatics Group (TU Wien) 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 type { BaseIntegrationOptions, IntegrationFactory, IntegrationOptions } from '@eclipse-glsp/playwright';
|
|
18
|
+
|
|
19
|
+
export interface TheiaIntegrationOptions extends BaseIntegrationOptions {
|
|
20
|
+
type: 'Theia';
|
|
21
|
+
/**
|
|
22
|
+
* Required, so that a hand-written options literal is a compile error.
|
|
23
|
+
* Use {@link defineTheiaIntegration} to create the options.
|
|
24
|
+
*/
|
|
25
|
+
integrationFactory: IntegrationFactory<TheiaIntegrationOptions>;
|
|
26
|
+
url: string;
|
|
27
|
+
widgetId: string;
|
|
28
|
+
workspace?: string;
|
|
29
|
+
file?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The hand-written part of {@link TheiaIntegrationOptions}, i.e. everything except the
|
|
34
|
+
* discriminator and the factory that {@link defineTheiaIntegration} fills in.
|
|
35
|
+
*/
|
|
36
|
+
export type TheiaIntegrationConfig = Omit<TheiaIntegrationOptions, 'type' | 'integrationFactory'>;
|
|
37
|
+
|
|
38
|
+
declare global {
|
|
39
|
+
namespace GLSPPlaywright {
|
|
40
|
+
interface IntegrationOptionsMap {
|
|
41
|
+
Theia: TheiaIntegrationOptions;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export namespace TheiaIntegrationOptions {
|
|
47
|
+
export function is(options?: IntegrationOptions): options is TheiaIntegrationOptions {
|
|
48
|
+
return options?.type === 'Theia';
|
|
49
|
+
}
|
|
50
|
+
}
|