Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSP-1369: Update id locators in tests to align with workflow example #12

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ examples/workflow-test/playwright/.storage/*.json
*.vsix
!*.env.example
*.env


5 changes: 0 additions & 5 deletions examples/workflow-test/.eslintrc.js

This file was deleted.

16 changes: 7 additions & 9 deletions examples/workflow-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-glsp/workflow-test",
"version": "2.0.0",
"version": "2.2.0-next",
"private": true,
"description": "Example project for glsp-playwright",
"homepage": "https://www.eclipse.org/glsp/",
Expand Down Expand Up @@ -31,13 +31,11 @@
],
"scripts": {
"build": "tsc -b",
"check-types": "tsc --noemit",
"clean": "rimraf --glob lib tsconfig.tsbuildinfo server/*.log",
"lint": "eslint --ext .ts,.tsx ./src ./tests",
"lint:all": "yarn check-types && yarn lint",
"lint:ci": "yarn lint -o eslint.xml -f checkstyle",
"prepare": "yarn clean && yarn build && yarn lint && playwright install",
"repo": "npx tsx ./scripts/repositories.ts",
"prepare": "playwright install",
"repo": "ts-node ./scripts/repositories.ts",
"start:server": "node node_modules/@eclipse-glsp-examples/workflow-server-bundled/wf-glsp-server-node.js",
"test": "playwright test",
"test:standalone": "yarn test --project=standalone",
Expand All @@ -47,13 +45,13 @@
"watch": "tsc -w"
},
"devDependencies": {
"@eclipse-glsp-examples/workflow-server-bundled": "~2.1.1",
"@eclipse-glsp/glsp-playwright": "~2.0.0",
"@playwright/test": "^1.40.1",
"@eclipse-glsp-examples/workflow-server-bundled": "next",
"@eclipse-glsp/glsp-playwright": "2.2.0-next",
"@playwright/test": "^1.37.1",
"@theia/playwright": "~1.49.1",
"@types/yargs": "^17.0.32",
"dotenv": "^16.0.3",
"ts-dedent": "^2.2.0",
"tsx": "^3.12.4",
"yargs": "^17.7.2"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions examples/workflow-test/scripts/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function buildClient(options: GlobalOptions): void {
}

function buildTheia(options: GlobalOptions): void {
exec('yarn', [], { cwd: repositoryFolder(options.folder, theiaRepository) });
exec('yarn && yarn browser build', [], { cwd: repositoryFolder(options.folder, theiaRepository) });
tortmayr marked this conversation as resolved.
Show resolved Hide resolved
}

function buildVSCode(options: GlobalOptions): void {
Expand Down Expand Up @@ -274,4 +274,4 @@ function buildCommand(handler: (argv: BuildCommandArgv) => void) {
};
}

main();
main().catch(console.error);
14 changes: 7 additions & 7 deletions examples/workflow-test/tests/core/connectable-element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ test.describe('The edge accessor of a connectable element', () => {
});

test('should allow accessing all edges of a type', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge);

const ids = await Promise.all(edges.map(async e => e.idAttr()));
const expectedIds = ['d34c37e0-e45e-4cfe-a76f-0e9274ed8e60'];
const expectedIds = ['edge_task_Push_fork_1'];

expect(ids.length).toBe(expectedIds.length);
ids.forEach(id => {
Expand All @@ -48,26 +48,26 @@ test.describe('The edge accessor of a connectable element', () => {
});

test('should return typed sources on access', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge);
expect(edges.length).toBe(1);

const source = await edges[0].source();
expect(await source.idAttr()).toContain('task0');
expect(await source.idAttr()).toContain('task_Push');
expect(source instanceof TaskManual).toBeTruthy();
});

test('should allow accessing all edges of a type against a target type', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const edges = await task.edges().outgoingEdgesOfType(Edge, { targetConstructor: ActivityNodeFork });
expect(edges.length).toBe(1);

const source = await edges[0].source();
expect(await source.idAttr()).toContain('task0');
expect(await source.idAttr()).toContain('task_Push');
expect(source instanceof TaskManual).toBeTruthy();

const target = await edges[0].target();
expect(await target.idAttr()).toContain('bb2709f5-0ff0-4438-8853-b7e934b506d7');
expect(await target.idAttr()).toContain('fork_1');
expect(target instanceof ActivityNodeFork).toBeTruthy();
});

Expand Down
16 changes: 8 additions & 8 deletions examples/workflow-test/tests/core/debug.standalone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ import { WorkflowApp } from '../../src/app/workflow-app';
import { TaskManual } from '../../src/graph/elements/task-manual.po';
import { WorkflowGraph } from '../../src/graph/workflow.graph';

const taskSelector = '[id$="task0"]';
const taskSelector = '[id$="task_Push"]';
const expectedElementMetadata = {
id: 'sprotty_task0',
id: 'sprotty_task_Push',
type: 'task:manual',
parent: 'sprotty_sprotty',
children: [
{
id: 'sprotty_task0_icon',
id: 'sprotty_task_Push_icon',
type: 'icon',
parent: 'sprotty_task0',
parent: 'sprotty_task_Push',
children: [],
html: ''
},
{
id: 'sprotty_task0_classname',
id: 'sprotty_task_Push_label',
type: 'label:heading',
parent: 'sprotty_task0',
parent: 'sprotty_task_Push',
children: [],
html: 'Push'
}
Expand All @@ -46,9 +46,9 @@ const expectedElementMetadata = {
const expectedGLSPLocatorData = [
{
locator:
"locator('body').locator('div.sprotty:not(.sprotty-hidden)').locator('[data-svg-metadata-type=\"graph\"]').locator('[id$=\"task0\"]').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('div.sprotty:not(.sprotty-hidden)').locator('[data-svg-metadata-type=\"graph\"]').locator('[data-svg-metadata-type=\"task:manual\"]'))",
children: [
'<g id="sprotty_task0" transform="translate(70, 140)" data-svg-metadata-type="task:manual" data-svg-metadata-parent-id="sprotty_sprotty" class="node task manual">...</g>'
'<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 Down
6 changes: 3 additions & 3 deletions examples/workflow-test/tests/core/edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ test.describe('Edges', () => {
});

test('should have source and target nodes', async () => {
const source = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const target = await graph.getNodeBySelector('[id$="bb2709f5-0ff0-4438-8853-b7e934b506d7"]', ActivityNodeFork);
const edge = await graph.getEdgeBySelector('[id$="d34c37e0-e45e-4cfe-a76f-0e9274ed8e60"]', Edge);
const source = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const target = await graph.getNodeBySelector('[id$="fork_1"]', ActivityNodeFork);
const edge = await graph.getEdgeBySelector('[id$="edge_task_Push_fork_1"]', Edge);

const sourceId = await edge.sourceId();
expect(sourceId).toBe(await source.idAttr());
Expand Down
2 changes: 1 addition & 1 deletion examples/workflow-test/tests/core/flows/deletable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test.describe('Deletable flow', () => {
});

test('should delete element', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);

expect(await task.locate().count()).toBe(1);
await task.delete();
Expand Down
14 changes: 7 additions & 7 deletions examples/workflow-test/tests/core/graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe('The graph', () => {

test.describe('should allow accessing the edge', () => {
test('by using a selector', async () => {
const edge = await graph.getEdgeBySelector('[id$="d34c37e0-e45e-4cfe-a76f-0e9274ed8e60"]', Edge);
const edge = await graph.getEdgeBySelector('[id$="edge_task_Push_fork_1"]', Edge);
const task = await edge.sourceOfType(TaskManual);

expect(await (await task.children.label()).textContent()).toBe('Push');
Expand All @@ -44,7 +44,7 @@ test.describe('The graph', () => {
const edges = await graph.getEdgesOfType(Edge, { sourceConstructor: TaskManual });

const ids = await Promise.all(edges.map(async e => e.idAttr()));
const expectedIds = ['d34c37e0-e45e-4cfe-a76f-0e9274ed8e60', 'a36985a7-3e61-499c-9bdb-5be2b00cb75c'];
const expectedIds = ['edge_task_Push_fork_1', 'edge_task_RflWt_merge_1'];

expect(ids.length).toBe(expectedIds.length);
ids.forEach(id => {
Expand All @@ -55,18 +55,18 @@ test.describe('The graph', () => {
});

test('by using a source selector', async () => {
const edges = await graph.getEdgesOfType(Edge, { sourceSelector: '[id$="task0"]' });
const edges = await graph.getEdgesOfType(Edge, { sourceSelector: '[id$="task_Push"]' });
expect(edges.length).toBe(1);

const source = await edges[0].sourceOfType(TaskManual);
expect(await source.idAttr()).toContain('task0');
expect(await source.idAttr()).toContain('task_Push');
});

test('by using the source type with multiple elements', async () => {
const edges = await graph.getEdgesOfType(Edge, { sourceConstructor: TaskManual });

const ids = await Promise.all(edges.map(async e => e.idAttr()));
const expectedIds = ['d34c37e0-e45e-4cfe-a76f-0e9274ed8e60', 'a36985a7-3e61-499c-9bdb-5be2b00cb75c'];
const expectedIds = ['edge_task_Push_fork_1', 'edge_task_RflWt_merge_1'];

expect(ids.length).toBe(expectedIds.length);
for await (const [index, id] of ids.entries()) {
Expand All @@ -81,7 +81,7 @@ test.describe('The graph', () => {
const edges = await graph.getEdgesOfType(Edge, { targetConstructor: ActivityNodeFork });

const ids = await Promise.all(edges.map(async e => e.idAttr()));
const expectedIds = ['d34c37e0-e45e-4cfe-a76f-0e9274ed8e60'];
const expectedIds = ['edge_task_Push_fork_1'];

expect(ids.length).toBe(expectedIds.length);
for await (const [index, id] of ids.entries()) {
Expand All @@ -99,7 +99,7 @@ test.describe('The graph', () => {
});

const ids = await Promise.all(edges.map(async e => e.idAttr()));
const expectedIds = ['d34c37e0-e45e-4cfe-a76f-0e9274ed8e60'];
const expectedIds = ['edge_task_Push_fork_1'];

expect(ids.length).toBe(expectedIds.length);
for await (const [index, id] of ids.entries()) {
Expand Down
10 changes: 5 additions & 5 deletions examples/workflow-test/tests/core/parent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const children = task.children;

const labels = await children.allOfType(LabelHeading);
Expand All @@ -43,23 +43,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.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', 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.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const children = task.children;

const label = await children.ofType(LabelHeading, { selector: '[id$="task0_classname"]' });
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.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const children = task.children;

const label = await children.label();
Expand Down
2 changes: 1 addition & 1 deletion examples/workflow-test/tests/core/shortcuts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test.describe('Shortcuts', () => {
});

test('should allow deleting the element in the graph', async ({ integration }) => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
expect(await task.isVisible()).toBeTruthy();

await task.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test.describe('The resizing handle', () => {
});

test('should allow resizing', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);

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

test('should show 4 handles', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);

await graph.waitForCreationOfType(PMetadata.getType(ResizeHandle), async () => {
await task.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ test.describe('The command palette', () => {

test.describe('in the element context', () => {
test('should allow to search suggestions', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);

const elementCommandPalette = await task.commandPalette();
await elementCommandPalette.open();
Expand Down Expand Up @@ -179,7 +179,7 @@ test.describe('The command palette', () => {
});

test('should allow creating new elements in the diagram', async () => {
const task = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const task = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);

const nodes = await graph.waitForCreationOfNodeType(TaskManual, async () => {
const command = task.commandPalette();
Expand All @@ -196,8 +196,8 @@ test.describe('The command palette', () => {
});

test('should allow creating edges in the graph', async () => {
const source = await graph.getNodeBySelector('[id$="task0"]', TaskManual);
const target = await graph.getNodeBySelector('[id$="task0_automated"]', TaskAutomated);
const source = await graph.getNodeBySelector('[id$="task_Push"]', TaskManual);
const target = await graph.getNodeBySelector('[id$="task_ChkWt"]', TaskAutomated);

const edges = await graph.waitForCreationOfEdgeType(Edge, async () => {
const command = source.commandPalette();
Expand Down
4 changes: 2 additions & 2 deletions examples/workflow-test/tests/features/hover/popup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ 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';

const manualSelector = '[id$="task0"]';
const manualSelector = '[id$="task_Push"]';
const expectedManualPopupText = dedent`Push
Type: manual
Duration: undefined
Reference: undefined
`;
const automatedSelector = '[id$="task0_automated"]';
const automatedSelector = '[id$="task_ChkWt"]';
const expectedAutomatedPopupText = dedent`ChkWt
Type: automated
Duration: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test.describe('The routing points of an edge', () => {
});

test('should be accessible', async () => {
const edge = await graph.getEdgeBySelector('[id$="d34c37e0-e45e-4cfe-a76f-0e9274ed8e60"]', Edge);
const edge = await graph.getEdgeBySelector('[id$="edge_task_Push_fork_1"]', Edge);

const routingPoints = edge.routingPoints();
expect((await routingPoints.points({ wait: false })).length).toBe(0);
Expand All @@ -46,7 +46,7 @@ test.describe('The routing points of an edge', () => {
});

test('should have the data kind attribute', async () => {
const edge = await graph.getEdgeBySelector('[id$="d34c37e0-e45e-4cfe-a76f-0e9274ed8e60"]', Edge);
const edge = await graph.getEdgeBySelector('[id$="edge_task_Push_fork_1"]', Edge);

const routingPoints = edge.routingPoints();
expect((await routingPoints.volatilePoints({ wait: false })).length).toBe(0);
Expand Down
4 changes: 1 addition & 3 deletions examples/workflow-test/tests/features/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ test.describe('The select feature', () => {
test('should allow to deselect a single element through a keybinding', async () => {
const page = app.page;
const element = await graph.getNodeByLabel('Push', TaskManual);
await element.select();
await element.click();
const before = await graph.getNodesBySelector(`.${Selectable.CSS}`, TaskManual);
expect(before).toHaveLength(1);

// Resize Handle
await page.keyboard.press('Escape');
// Selection
await page.keyboard.press('Escape');

Expand Down
Loading