Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 : 1,
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? [['html', { open: 'never' }], ['@estruyf/github-actions-reporter']] : [['html', { open: 'never' }]],
use: {
actionTimeout: 0,
Expand Down
9 changes: 9 additions & 0 deletions examples/workflow-test/src/app/workflow-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { GLSPSemanticApp } from '@eclipse-glsp/glsp-playwright';
import { expect } from '@eclipse-glsp/glsp-playwright/lib/test';
import { WorkflowToolPalette } from '../features/tool-palette/workflow-tool-palette';
import { WorkflowGraph } from '../graph/workflow.graph';

Expand All @@ -28,4 +29,12 @@ export class WorkflowApp extends GLSPSemanticApp {
protected override createToolPalette(): WorkflowToolPalette {
return new WorkflowToolPalette({ locator: WorkflowToolPalette.locate(this) });
}

/**
* Wait for the application to be ready.
* The server can take some time to send the data.
*/
async waitForReady(): Promise<void> {
await expect(this.locate().getByText('Push')).toBeVisible();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test.describe('The edge accessor of a connectable element', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
3 changes: 2 additions & 1 deletion examples/workflow-test/tests/core/debug.standalone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const expectedElementMetadata = {
const expectedGLSPLocatorData = [
{
locator:
"locator('body').locator('div.sprotty:not(.sprotty-hidden)').locator('[data-svg-metadata-type=\"graph\"]').locator('[id$=\"task_Push\"]').and(locator('body').locator('div.sprotty:not(.sprotty-hidden)').locator('[data-svg-metadata-type=\"graph\"]').locator('[data-svg-metadata-type=\"task:manual\"]'))",
"locator('body').locator('div.sprotty:not(.sprotty-hidden)').locator('[data-svg-metadata-type=\"graph\"]').locator('[id$=\"task_Push\"]').and(locator('body').locator('[data-svg-metadata-type=\"task:manual\"]'))",
children: [
'<g id="sprotty_task_Push" transform="translate(70, 100)" data-svg-metadata-type="task:manual" data-svg-metadata-parent-id="sprotty_sprotty" class="node task manual">...</g>'
]
Expand All @@ -67,6 +67,7 @@ test.describe('The debug functions', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/tests/core/edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test.describe('Edges', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test.describe('The context menu', () => {
type: 'integration',
integration
});
await app.waitForReady();
contextMenu = app.contextMenu;
});

Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/tests/core/graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test.describe('The graph', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/tests/core/parent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test.describe('The children accessor of a parent element', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/tests/core/shortcuts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('Shortcuts', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('The resizing handle', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test.describe('The command palette', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
globalCommandPalette = app.globalCommandPalette;
server = glspServer;
Expand Down
1 change: 1 addition & 0 deletions examples/workflow-test/tests/features/hover/popup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test.describe('The popup', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
expectedManualPopupText.setServer(glspServer);
expectedAutomatedPopupText.setServer(glspServer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('The label edit tool', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand All @@ -45,6 +46,7 @@ test.describe('The label edit tool', () => {
await node.page.keyboard.press('F2');
await node.page.keyboard.type('New Label');
await node.page.keyboard.press('Enter');
await app.labelEditor.waitForHidden();

expect(await node.label).toBe('New Label');
});
Expand All @@ -58,7 +60,7 @@ test.describe('The label edit tool', () => {
await node.page.keyboard.press('Backspace');
await node.page.keyboard.press('Enter');

await expect(await app.labelEditor.getWarning()).toBe('Name must not be empty');
expect(await app.labelEditor.getWarning()).toBe('Name must not be empty');
});

test.afterEach(async ({ integration }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('The routing points of an edge', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
3 changes: 2 additions & 1 deletion examples/workflow-test/tests/features/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('The select feature', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down Expand Up @@ -77,7 +78,7 @@ test.describe('The select feature', () => {
await app.page.keyboard.press('Control+A');
await expect(graph).toHaveSelected({
type: PModelElement,
elements: await graph.getAllModelElements()
elements: () => graph.getAllModelElements()
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test.describe('The tool palette', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
toolPalette = app.toolPalette;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test.describe('The deletion tool', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
toolPalette = app.toolPalette;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test.describe('The edge creation tool', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
toolPalette = app.toolPalette;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { expect, test } from '@eclipse-glsp/glsp-playwright';
import { PMetadata, VolatileRoutingPoint } from '@eclipse-glsp/glsp-playwright/src/glsp';
import { WorkflowApp } from '../../../../src/app/workflow-app';
import { Edge } from '../../../../src/graph/elements/edge.po';
import { TaskAutomated } from '../../../../src/graph/elements/task-automated.po';
Expand All @@ -30,6 +31,7 @@ test.describe('The edge edit tool', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down Expand Up @@ -59,7 +61,9 @@ test.describe('The edge edit tool', () => {
expect(volatilePoints).toHaveLength(1);

const volatilePoint = volatilePoints[0];
await volatilePoint.dragToRelativePosition({ x: 50, y: 50 });
await app.graph.waitForReplacement(PMetadata.getType(VolatileRoutingPoint), async () => {
await volatilePoint.dragToRelativePosition({ x: 50, y: 50 });
});

points = await routingPoints.points();
expect(points).toHaveLength(currentPointsLength + 1);
Expand All @@ -81,7 +85,9 @@ test.describe('The edge edit tool', () => {
expect(volatilePoints).toHaveLength(1);

// Middle one
await volatilePoints[0].dragToRelativePosition({ x: 0, y: 50 });
await app.graph.waitForReplacement(PMetadata.getType(VolatileRoutingPoint), async () => {
await volatilePoints[0].dragToRelativePosition({ x: 0, y: 50 });
});

points = await routingPoints.points();
expect(points).toHaveLength(currentPointsLength + 1);
Expand All @@ -91,8 +97,9 @@ test.describe('The edge edit tool', () => {

// Junction
const junction = points.find(p => p.lastSnapshot?.kind === 'junction')!;
await junction.dragToRelativePosition({ x: 20, y: -40 });
await junction.waitForHidden();
await app.graph.waitForHide(junction.locator, async () => {
await junction.dragToRelativePosition({ x: 20, y: -40 });
});

points = await routingPoints.points();
expect(points).toHaveLength(currentPointsLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test.describe('The node creation tool', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
toolPalette = app.toolPalette;
taskManualCreatedLabel = TaskManualNodes.createdLabel(glspServer);
Expand Down Expand Up @@ -69,6 +70,7 @@ test.describe('The node creation tool', () => {
await paletteItem.click();

await expect(graph).toContainClass(CursorCSS.NODE_CREATION);

const node = await graph.getNodeByLabel(TaskManualNodes.pushLabel, TaskManual);
const bounds = await node.bounds();
await bounds.position('bottom_left').moveRelative(0, 60).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test.describe('The undo redo trigger', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
trigger = provideUndoRedoTriggerVariable(integration, app).get();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test.describe('The marker navigator', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
navigator = provideMarkerNavigatorVariable(integration, app).get();
await navigator.trigger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test.describe('The marker', () => {
type: 'integration',
integration
});
await app.waitForReady();
graph = app.graph;
});

Expand Down
4 changes: 3 additions & 1 deletion packages/glsp-playwright/src/debug/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface DebugNode {
type: string | null;
parent: string | null;
html: string | null;
class: string | null;
children: DebugNode[];
}

Expand Down Expand Up @@ -57,7 +58,8 @@ export async function extractElement(locator: Locator): Promise<DebugNode> {
type: await locator.getAttribute(SVGMetadata.type),
parent: await locator.getAttribute(SVGMetadata.parentId),
children: [],
html: await (await locator.allTextContents()).join(',')
html: (await locator.allTextContents()).join(','),
class: await locator.getAttribute('class')
};
}

Expand Down
4 changes: 4 additions & 0 deletions packages/glsp-playwright/src/glsp/app/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export class GLSPApp {
this.locator = this.rootLocator.child(this.sprottySelector);
}

locate(): Locator {
return this.locator.locate();
}

protected createGraph(_options: GLSPAppOptions): GLSPGraph {
return new GLSPSemanticGraph({ locator: GLSPGraph.locate(this) });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type { Locator } from '@playwright/test';
import type { AutoPrepareOptions, AutoWaitOptions } from '~/extension';
import { Clickable, Mix, useDraggableFlow } from '~/extension';
import { ModelElementMetadata, PEdge, PMetadata, PModelElement, PModelElementData, PModelElementSnapshot, SVGMetadata } from '~/glsp/graph';
import type { GLSPLocator } from '~/remote';
import type { Position } from '~/types';
import { definedAttr, definedGLSPAttr } from '~/utils/ts.utils';

Expand Down Expand Up @@ -55,9 +54,9 @@ export class RoutingPoints {
for await (const childLocator of await this.pointsLocator.all()) {
const id = await definedAttr(childLocator, 'id');

const routingPoint = new RoutingPoint(this.element.locator.child(`id=${id}`), this);
await routingPoint.snapshot();
elements.push(routingPoint);
const point = new RoutingPoint({ locator: this.element.locator.child(`id=${id}`), routingPoints: this });
await point.snapshot();
elements.push(point);
}

return elements;
Expand All @@ -66,14 +65,17 @@ export class RoutingPoints {
async volatilePoints(options?: AutoWaitOptions): Promise<VolatileRoutingPoint[]> {
await this.autoWait(options);

const elements: RoutingPoint[] = [];
const elements: VolatileRoutingPoint[] = [];

for await (const childLocator of await this.volatilePointsLocator.all()) {
const id = await definedAttr(childLocator, 'id');

const routingPoint = new RoutingPoint(this.element.locator.child(`id=${id}`), this);
await routingPoint.snapshot();
elements.push(routingPoint);
const point = new VolatileRoutingPoint({
locator: this.element.locator.child(`id=${id}`),
routingPoints: this
});
await point.snapshot();
elements.push(point);
}

return elements;
Expand All @@ -84,12 +86,16 @@ export interface RoutingPointSnapshot extends PModelElementSnapshot {
kind: RoutingPointKind;
}

export interface BaseRoutingPointData extends PModelElementData {
routingPoints: RoutingPoints;
}

const BaseRoutingPointMixin = Mix(PModelElement).flow(useDraggableFlow).build();
export abstract class BaseRoutingPoint extends BaseRoutingPointMixin {
readonly routingPoints;
override lastSnapshot?: RoutingPointSnapshot | undefined;

constructor(data: PModelElementData & { routingPoints: RoutingPoints }) {
constructor(data: BaseRoutingPointData) {
super(data);

this.routingPoints = data.routingPoints;
Expand Down Expand Up @@ -155,22 +161,16 @@ export abstract class BaseRoutingPoint extends BaseRoutingPointMixin {
type: 'routing-point'
})
export class RoutingPoint extends BaseRoutingPoint {
constructor(locator: GLSPLocator, routingPoints: RoutingPoints) {
super({
routingPoints,
locator
});
constructor(data: BaseRoutingPointData) {
super(data);
}
}

@ModelElementMetadata({
type: 'volatile-routing-point'
})
export class VolatileRoutingPoint extends BaseRoutingPoint {
constructor(locator: GLSPLocator, routingPoints: RoutingPoints) {
super({
routingPoints,
locator
});
constructor(data: BaseRoutingPointData) {
super(data);
}
}
Loading