Skip to content

Commit

Permalink
Introduce core tests (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydar-metin authored Sep 19, 2024
1 parent 82d049f commit 18e0f5c
Show file tree
Hide file tree
Showing 51 changed files with 1,375 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
"The sprotty-protocol default exports are customized and reexported by GLSP. Please use '@eclipse-glsp/client' instead"
}
],
patterns: ['../../../../*', '**/../index']
patterns: ['**/../index']
}
]
}
Expand Down
14 changes: 7 additions & 7 deletions examples/workflow-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ This package contains code examples that demonstrate how to test diagram editors
| Element Hover ||||
| Element Validation ||||
| Element Navigation ||| x |
| Element Type Hints | - | - | - |
| Element Creation and Deletion | - | - | - |
| Node Change Bounds<br>- Move<br>- Resize | <br>-<br>- | <br>-<br>- | <br>-<br>- |
| Element Type Hints | | | |
| Element Creation and Deletion | | | |
| Node Change Bounds<br>- Move<br>- Resize | <br><br> | <br><br> | <br><br> |
| Node Change Container | - | - | - |
| Edge Reconnect | - | - | - |
| Edge Routing Points | - | - | - |
| Edge Reconnect | | | |
| Edge Routing Points | | | |
| Ghost Elements | - | - | - |
| Element Text Editing | - | - | - |
| Element Text Editing | | | |
| Clipboard (Cut, Copy, Paste) | - | - | - |
| Undo / Redo | - | - | - |
| Undo / Redo | | | x |
| Contexts<br>- Context Menu<br>- Command Palette<br>- Tool Palette | <br><br>-<br>- | <br>-<br>-<br>- | <br>-<br>-<br>- |
| Accessibility Features (experimental) <br>- Search<br>- Move <br>- Zoom <br>- Resize | <br>-<br>-<br>-<br>- | | |
| Helper Lines (experimental) | - | - | - |
Expand Down
5 changes: 5 additions & 0 deletions examples/workflow-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"url": "https://me.big.tuwien.ac.at/"
}
],
"main": "lib/index",
"types": "lib/index",
"files": [
"src",
"tests"
Expand All @@ -43,6 +45,9 @@
"test:vscode-setup": "yarn test --project=vscode-setup",
"watch": "tsc -w"
},
"dependencies": {
"@eclipse-glsp/client": "next"
},
"devDependencies": {
"@eclipse-glsp-examples/workflow-server-bundled": "next",
"@eclipse-glsp/glsp-playwright": "2.3.0-next",
Expand Down
2 changes: 1 addition & 1 deletion examples/workflow-test/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const config: PlaywrightTestConfig<GLSPPlaywrightOptions> = {
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 2 : 1,
reporter: process.env.CI ? [['html', { open: 'never' }], ['@estruyf/github-actions-reporter']] : [['html', { open: 'never' }]],
use: {
actionTimeout: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { NodeMetadata, PNode } from '@eclipse-glsp/glsp-playwright';
import { Mix, useClickableFlow } from '@eclipse-glsp/glsp-playwright/src/extension';

export const ActivityNodeDecisionMixin = Mix(PNode).flow(useClickableFlow).build();

@NodeMetadata({
type: 'activityNode:decision'
})
export class ActivityNodeDecision extends ActivityNodeDecisionMixin {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { NodeMetadata, PNode } from '@eclipse-glsp/glsp-playwright';
import { Mix, useClickableFlow } from '@eclipse-glsp/glsp-playwright/src/extension';

export const ActivityNodeForkMixin = Mix(PNode).flow(useClickableFlow).build();

@NodeMetadata({
type: 'activityNode:fork'
})
export class ActivityNodeFork extends PNode {}
export class ActivityNodeFork extends ActivityNodeForkMixin {}
58 changes: 58 additions & 0 deletions examples/workflow-test/src/graph/elements/category.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) 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 {
ChildrenAccessor,
Mix,
NodeMetadata,
PLabelledElement,
PNode,
SVGMetadataUtils,
useClickableFlow,
useCommandPaletteCapability,
useDeletableFlow,
useDraggableFlow,
useRenameableFlow,
useResizeHandleCapability,
useSelectableFlow
} from '@eclipse-glsp/glsp-playwright/';
import { LabelHeading } from './label-heading.po';

export const CategoryMixin = Mix(PNode)
.flow(useClickableFlow)
.flow(useDeletableFlow)
.flow(useDraggableFlow)
.flow(useRenameableFlow)
.flow(useSelectableFlow)
.capability(useResizeHandleCapability)
.capability(useCommandPaletteCapability)
.build();

@NodeMetadata({
type: 'category'
})
export class Category extends CategoryMixin implements PLabelledElement {
override readonly children = new CategoryChildren(this);

get label(): Promise<string> {
return this.children.label().then(label => label.textContent());
}
}

export class CategoryChildren extends ChildrenAccessor {
async label(): Promise<LabelHeading> {
return this.ofType(LabelHeading, { selector: SVGMetadataUtils.typeAttrOf(LabelHeading) });
}
}
3 changes: 2 additions & 1 deletion examples/workflow-test/src/graph/elements/edge.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { EdgeMetadata, Mix, PEdge, useClickableFlow, useRoutingPointCapability } from '@eclipse-glsp/glsp-playwright/';
import { useReconnectCapability } from '@eclipse-glsp/glsp-playwright/src/glsp/features/reconnect';

const EdgeMixin = Mix(PEdge).flow(useClickableFlow).capability(useRoutingPointCapability).build();
const EdgeMixin = Mix(PEdge).flow(useClickableFlow).capability(useRoutingPointCapability).capability(useReconnectCapability).build();

@EdgeMetadata({
type: 'edge'
Expand Down
23 changes: 23 additions & 0 deletions examples/workflow-test/src/graph/elements/weighted-edge.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/********************************************************************************
* Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { EdgeMetadata, Mix, PEdge, useClickableFlow, useRoutingPointCapability } from '@eclipse-glsp/glsp-playwright/';

const EdgeMixin = Mix(PEdge).flow(useClickableFlow).capability(useRoutingPointCapability).build();

@EdgeMetadata({
type: 'edge:weighted'
})
export class WeightedEdge extends EdgeMixin {}
9 changes: 4 additions & 5 deletions examples/workflow-test/tests/core/connectable-element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { ActivityNodeFork } from '../../src/graph/elements/activity-node-fork.po
import { Edge } from '../../src/graph/elements/edge.po';
import { TaskManual } from '../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../src/graph/workflow.graph';

const elementLabel = 'Push';
import { TaskManualNodes } from '../nodes';

test.describe('The edge accessor of a connectable element', () => {
let app: WorkflowApp;
Expand All @@ -35,7 +34,7 @@ test.describe('The edge accessor of a connectable element', () => {
});

test('should allow accessing all edges of a type', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge);

const ids = await Promise.all(edges.map(async e => e.idAttr()));
Expand All @@ -50,7 +49,7 @@ test.describe('The edge accessor of a connectable element', () => {
});

test('should return typed sources on access', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge);
expect(edges.length).toBe(1);

Expand All @@ -60,7 +59,7 @@ test.describe('The edge accessor of a connectable element', () => {
});

test('should allow accessing all edges of a type against a target type', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge, { targetConstructor: ActivityNodeFork });
expect(edges.length).toBe(1);

Expand Down
5 changes: 2 additions & 3 deletions examples/workflow-test/tests/core/edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { ActivityNodeFork } from '../../src/graph/elements/activity-node-fork.po
import { Edge } from '../../src/graph/elements/edge.po';
import { TaskManual } from '../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../src/graph/workflow.graph';

const elementLabel = 'Push';
import { TaskManualNodes } from '../nodes';

test.describe('Edges', () => {
let app: WorkflowApp;
Expand All @@ -35,7 +34,7 @@ test.describe('Edges', () => {
});

test('should have source and target nodes', async () => {
const source = await graph.getNodeByLabel(elementLabel, TaskManual);
const source = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const target = await graph.getNode('[id$="fork_1"]', ActivityNodeFork);
const edge = await graph.getEdgeBetween(Edge, { sourceNode: source, targetNode: target });

Expand Down
11 changes: 5 additions & 6 deletions examples/workflow-test/tests/core/parent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { WorkflowApp } from '../../src/app/workflow-app';
import { LabelHeading } from '../../src/graph/elements/label-heading.po';
import { TaskManual } from '../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../src/graph/workflow.graph';

const elementLabel = 'Push';
import { TaskManualNodes } from '../nodes';

test.describe('The children accessor of a parent element', () => {
let app: WorkflowApp;
Expand All @@ -34,7 +33,7 @@ test.describe('The children accessor of a parent element', () => {
});

test('should allow to access all elements by using a type', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const children = task.children;

const labels = await children.allOfType(LabelHeading);
Expand All @@ -45,23 +44,23 @@ test.describe('The children accessor of a parent element', () => {
});

test('should allow to access the element by using a type', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const children = task.children;

const label = await children.ofType(LabelHeading);
expect(await label.textContent()).toBe('Push');
});

test('should allow to access the element by using a type and a selector', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const children = task.children;

const label = await children.ofType(LabelHeading, { selector: '[id$="task_Push_label"]' });
expect(await label.textContent()).toBe('Push');
});

test('should allow to use typed elements', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const children = task.children;

const label = await children.label();
Expand Down
5 changes: 2 additions & 3 deletions examples/workflow-test/tests/core/shortcuts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { expect, test } from '@eclipse-glsp/glsp-playwright';
import { WorkflowApp } from '../../src/app/workflow-app';
import { TaskManual } from '../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../src/graph/workflow.graph';

const elementLabel = 'Push';
import { TaskManualNodes } from '../nodes';

test.describe('Shortcuts', () => {
let app: WorkflowApp;
Expand All @@ -33,7 +32,7 @@ test.describe('Shortcuts', () => {
});

test('should allow deleting the element in the graph', async ({ integration }) => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
expect(await task.isVisible()).toBeTruthy();

await task.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { PMetadata, ResizeHandle, expect, test } from '@eclipse-glsp/glsp-playwr
import { WorkflowApp } from '../../../src/app/workflow-app';
import { TaskManual } from '../../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../../src/graph/workflow.graph';

const elementLabel = 'Push';
import { TaskManualNodes } from '../../nodes';

test.describe('The resizing handle', () => {
let app: WorkflowApp;
Expand All @@ -33,7 +32,7 @@ test.describe('The resizing handle', () => {
});

test('should allow resizing', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);

const oldBounds = await task.bounds();
const oldTopLeft = oldBounds.position('top_left');
Expand All @@ -52,7 +51,7 @@ test.describe('The resizing handle', () => {
});

test('should show 4 handles', async () => {
const task = await graph.getNodeByLabel(elementLabel, TaskManual);
const task = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);

await graph.waitForCreation(PMetadata.getType(ResizeHandle), async () => {
await task.click();
Expand Down
Loading

0 comments on commit 18e0f5c

Please sign in to comment.