Skip to content

Commit

Permalink
Fix java server differences (#22)
Browse files Browse the repository at this point in the history
* Fix java server differences
* Make IntegrationVariable type safe
  • Loading branch information
haydar-metin authored Aug 12, 2024
1 parent dac91d5 commit 82d049f
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
env:
THEIA_URL: 'http://localhost:3000'
VSCODE_VSIX_ID: 'eclipse-glsp.workflow-vscode-example'
GLSP_SERVER_TYPE: 'node'
GLSP_SERVER_DEBUG: 'true'
GLSP_SERVER_PORT: '8081'
GLSP_SERVER_PLAYWRIGHT_MANAGED: 'true'
Expand Down Expand Up @@ -87,13 +88,13 @@ jobs:
path: examples/workflow-test/playwright-report/

playwright-java:
if: false
name: Playwright Tests (Java server)
timeout-minutes: 120
runs-on: ubuntu-latest
env:
THEIA_URL: 'http://localhost:3000'
VSCODE_VSIX_ID: 'eclipse-glsp.workflow-vscode-example'
GLSP_SERVER_TYPE: 'java'
GLSP_SERVER_DEBUG: 'true'
GLSP_SERVER_PORT: '8081'
GLSP_SERVER_PLAYWRIGHT_MANAGED: 'true'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
THEIA_URL: 'http://localhost:3000'
VSCODE_VSIX_ID: 'eclipse-glsp.workflow-vscode-example'
GLSP_SERVER_TYPE: 'node'
GLSP_SERVER_DEBUG: 'true'
GLSP_SERVER_PORT: '8081'
GLSP_SERVER_PLAYWRIGHT_MANAGED: 'true'
Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ GLSP_SERVER_DEBUG="true" # For Theia and VSCode instances to connect to an exter
GLSP_SERVER_PORT="8081"
GLSP_SERVER_PLAYWRIGHT_MANAGED="true" # To allow Playwright to manage/start the server
GLSP_WEBSOCKET_PATH="workflow"
GLSP_SERVER_TYPE="node" # To use the node server

# Configurations
STANDALONE_URL="file:///.../repositories/glsp-client/examples/workflow-standalone/app/diagram.html"
Expand Down
18 changes: 18 additions & 0 deletions examples/workflow-test/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/********************************************************************************
* Copyright (c) 2024 EclipseSource 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
********************************************************************************/

export const GLSP_SERVER_TYPE_NODE = 'node';
export const GLSP_SERVER_TYPE_JAVA = 'java';
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { GLSPGlobalCommandPalette, expect, test } from '@eclipse-glsp/glsp-playwright/';
import { GLSPServer } from '@eclipse-glsp/glsp-playwright/src/glsp-server';
import { ServerVariable } from '@eclipse-glsp/glsp-playwright/src/test/dynamic-variable';
import { WorkflowApp } from '../../../src/app/workflow-app';
import { Edge } from '../../../src/graph/elements/edge.po';
import { TaskAutomated } from '../../../src/graph/elements/task-automated.po';
import { TaskManual } from '../../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../../src/graph/workflow.graph';
import { GLSP_SERVER_TYPE_JAVA, GLSP_SERVER_TYPE_NODE } from '../../../src/server';

const element1Label = 'Push';
const element2Label = 'ChkWt';
Expand All @@ -27,14 +30,16 @@ test.describe('The command palette', () => {
let app: WorkflowApp;
let graph: WorkflowGraph;
let globalCommandPalette: GLSPGlobalCommandPalette;
let server: GLSPServer;

test.beforeEach(async ({ integration }) => {
test.beforeEach(async ({ integration, glspServer }) => {
app = new WorkflowApp({
type: 'integration',
integration
});
graph = app.graph;
globalCommandPalette = app.globalCommandPalette;
server = glspServer;
});

test.describe('in the global context', () => {
Expand All @@ -45,23 +50,43 @@ test.describe('The command palette', () => {
expect(await globalCommandPalette.isVisible()).toBeTruthy();

const suggestions = await globalCommandPalette.suggestions();
const expectedSuggestions = [
'Create Manual Task',
'Create Category',
'Create Automated Task',
'Create Merge Node',
'Create Decision Node',
'Delete All',
'Reveal Push',
'Reveal ChkWt',
'Reveal WtOK',
'Reveal RflWt',
'Reveal Brew',
'Reveal ChkTp',
'Reveal KeepTp',
'Reveal PreHeat'
];
expect(suggestions.sort()).toEqual(expectedSuggestions.sort());
const expectedSuggestions = new ServerVariable({
server,
value: {
[GLSP_SERVER_TYPE_NODE]: [
'Create Manual Task',
'Create Category',
'Create Automated Task',
'Create Merge Node',
'Create Decision Node',
'Delete All',
'Reveal Push',
'Reveal ChkWt',
'Reveal WtOK',
'Reveal RflWt',
'Reveal Brew',
'Reveal ChkTp',
'Reveal KeepTp',
'Reveal PreHeat'
],
[GLSP_SERVER_TYPE_JAVA]: [
'Create Manual Task',
'Create Category',
'Create Automated Task',
'Create Merge Node',
'Create Decision Node',
'Reveal Push',
'Reveal ChkWt',
'Reveal WtOK',
'Reveal RflWt',
'Reveal Brew',
'Reveal ChkTp',
'Reveal KeepTp',
'Reveal PreHeat'
]
}
});
expect(suggestions.sort()).toEqual(expectedSuggestions.get().sort());

await globalCommandPalette.search('Create');
const createSuggestions = await globalCommandPalette.suggestions();
Expand Down
73 changes: 50 additions & 23 deletions examples/workflow-test/tests/features/hover/popup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,64 @@ import {
test
} from '@eclipse-glsp/glsp-playwright/';
import { PLabelledElement } from '@eclipse-glsp/glsp-playwright/src/extension';
import { ServerVariable } from '@eclipse-glsp/glsp-playwright/src/test/dynamic-variable';
import { dedent } from 'ts-dedent';
import { WorkflowApp } from '../../../src/app/workflow-app';
import { TaskAutomated } from '../../../src/graph/elements/task-automated.po';
import { TaskManual } from '../../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../../src/graph/workflow.graph';
import { GLSP_SERVER_TYPE_JAVA, GLSP_SERVER_TYPE_NODE } from '../../../src/server';

const manualLabel = 'Push';
const expectedManualPopupText = dedent`Push
Type: manual
Duration: undefined
Reference: undefined
const expectedManualPopupText = new ServerVariable({
value: {
[GLSP_SERVER_TYPE_NODE]: dedent`Push
Type: manual
Duration: undefined
Reference: undefined
`,
[GLSP_SERVER_TYPE_JAVA]: dedent`Push
Type: manual
Duration: 0
Reference: null
`
}
});

`;
const automatedLabel = 'ChkWt';
const expectedAutomatedPopupText = dedent`ChkWt
Type: automated
Duration: undefined
Reference: undefined
`;
const expectedAutomatedPopupText = new ServerVariable({
value: {
[GLSP_SERVER_TYPE_NODE]: dedent`ChkWt
Type: automated
Duration: undefined
Reference: undefined
`,
[GLSP_SERVER_TYPE_JAVA]: dedent`ChkWt
Type: automated
Duration: 0
Reference: null
`
}
});

test.describe('The popup', () => {
let app: WorkflowApp;
let graph: WorkflowGraph;

test.beforeEach(async ({ integration }) => {
test.beforeEach(async ({ integration, glspServer }) => {
app = new WorkflowApp({
type: 'integration',
integration
});
graph = app.graph;
expectedManualPopupText.setServer(glspServer);
expectedAutomatedPopupText.setServer(glspServer);
});

test('should be shown on hovering a task manual', async () => {
Expand All @@ -65,21 +92,21 @@ test.describe('The popup', () => {
await expect(app.popup.locate()).toBeVisible();

const popup = task.popup();
expect(await popup.innerText()).toBe(expectedManualPopupText);
expect(await popup.innerText()).toBe(expectedManualPopupText.get());
});

test('should allow to access the text directly in elements', async () => {
const task = await app.graph.getNodeByLabel(manualLabel, TaskManual);
await expect(app.popup.locate()).toBeHidden();
const text = await task.popupText();
await expect(app.popup.locate()).toBeVisible();
expect(text).toBe(expectedManualPopupText);
expect(text).toBe(expectedManualPopupText.get());
});

test.describe('should be closed on', () => {
test('escape', async () => {
await app.graph.focus();
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());

await app.page.keyboard.press('Escape');
await app.popup.waitForHidden();
Expand All @@ -88,15 +115,15 @@ test.describe('The popup', () => {
});

test('new hover', async () => {
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());

await app.popup.close();

await assertPopup(app, automatedLabel, TaskAutomated, expectedAutomatedPopupText);
await assertPopup(app, automatedLabel, TaskAutomated, expectedAutomatedPopupText.get());
});

test('mouse moved away', async () => {
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());

const bounds = await app.graph.bounds();
await bounds.position('middle_center').move();
Expand All @@ -106,7 +133,7 @@ test.describe('The popup', () => {
});

test('focus lost', async () => {
const task = await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
const task = await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());

await app.graph.locate().click();
await app.popup.waitForHidden();
Expand All @@ -116,7 +143,7 @@ test.describe('The popup', () => {

test('context menu', async ({ integrationOptions }) => {
test.skip(skipNonIntegration(integrationOptions, 'Theia'), 'Only within Theia supported');
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());

await app.contextMenu.open();
await app.popup.waitForHidden();
Expand All @@ -125,7 +152,7 @@ test.describe('The popup', () => {
});

test('center command', async ({ integration }) => {
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());
await graph.focus();
await runInIntegration(
integration,
Expand All @@ -143,7 +170,7 @@ test.describe('The popup', () => {
});

test('fit to screen command', async ({ integration }) => {
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());
await graph.focus();
await runInIntegration(
integration,
Expand All @@ -161,7 +188,7 @@ test.describe('The popup', () => {
});

test('layout command', async ({ integration }) => {
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText);
await assertPopup(app, manualLabel, TaskManual, expectedManualPopupText.get());
await graph.focus();
await runInIntegration(
integration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
MarkerNavigator,
StandaloneMarkerNavigator,
TheiaMarkerNavigator,
createParameterizedIntegrationData,
expect,
test
} from '@eclipse-glsp/glsp-playwright/';
import { MarkerNavigator, StandaloneMarkerNavigator, TheiaMarkerNavigator, expect, test } from '@eclipse-glsp/glsp-playwright/';
import { skipIntegration } from '@eclipse-glsp/glsp-playwright/src/test';
import { IntegrationVariable } from '@eclipse-glsp/glsp-playwright/src/test/dynamic-variable';
import { WorkflowApp } from '../../../src/app/workflow-app';
import { TaskAutomated } from '../../../src/graph/elements/task-automated.po';
import { WorkflowGraph } from '../../../src/graph/workflow.graph';
Expand All @@ -47,24 +41,24 @@ test.describe('The marker navigator', () => {
integration
});
graph = app.graph;
navigator = createParameterizedIntegrationData<() => MarkerNavigator>({
default: () => {
throw new Error('Integration not supported for marker navigator');
const navigatorProvider = new IntegrationVariable<MarkerNavigator>({
value: {
Standalone: new StandaloneMarkerNavigator(app),
Theia: new TheiaMarkerNavigator(app)
},
override: {
Standalone: () => new StandaloneMarkerNavigator(app),
Theia: () => new TheiaMarkerNavigator(app)
}
})[integration.type]();
integration
});

navigator = navigatorProvider.get();

await navigator.trigger();
});

// VSCode has no support for navigation
test.skip(({ integrationOptions }) => skipIntegration(integrationOptions, 'VSCode'));
test.skip(({ integrationOptions }) => skipIntegration(integrationOptions, 'VSCode'), 'Not supported');

test('should navigate to the first element', async ({ integrationOptions }) => {
test.skip(skipIntegration(integrationOptions, 'VSCode'));
test.skip(skipIntegration(integrationOptions, 'VSCode'), 'Not supported');

await navigator.navigateForward();
await app.page.pause();
Expand Down
17 changes: 17 additions & 0 deletions packages/glsp-playwright/src/glsp-server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/********************************************************************************
* Copyright (c) 2024 EclipseSource 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
********************************************************************************/

export * from './server';
Loading

0 comments on commit 82d049f

Please sign in to comment.