Skip to content

Commit

Permalink
Cleanup system-diagram tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed Oct 31, 2024
1 parent 1f8c79a commit 82fbeed
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 76 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/src/page-objects/crossmodel-composite-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class CrossModelCompositeEditor extends TheiaEditor {
this.app as CrossModelApp,
this.editorTabSelector('System Diagram')
);
await diagramEditor.waitForVisible();
await diagramEditor.diagram.graph.waitForVisible();
return diagramEditor;
}

Expand Down
7 changes: 6 additions & 1 deletion e2e-tests/src/page-objects/system-diagram/system-diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
PNodeConstructor
} from '@eclipse-glsp/glsp-playwright';
import { Locator } from '@playwright/test';
import { SystemToolBox } from './system-tool-box';
import { SystemToolBox, SystemTools } from './system-tool-box';

export class SystemDiagram extends GLSPSemanticApp {
override readonly toolPalette: SystemToolBox;
Expand All @@ -37,6 +37,11 @@ export class SystemDiagram extends GLSPSemanticApp {
protected override createToolPalette(): SystemToolBox {
return new SystemToolBox({ locator: SystemToolBox.locate(this) });
}

async enableTool(tool: SystemTools['default']): Promise<void> {
const paletteItem = await this.toolPalette.content.toolElement('default', tool);
return paletteItem.click();
}
}

export class SystemDiagramGraph extends GLSPSemanticGraph {
Expand Down
5 changes: 3 additions & 2 deletions e2e-tests/src/resources/mapping-example/.theia/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"files.autoSave": "off"
}
"files.autoSave": "off",
"files.enableTrash": false
}
72 changes: 0 additions & 72 deletions e2e-tests/src/tests/diagram/system-diagram-edit-entity.spec.ts

This file was deleted.

86 changes: 86 additions & 0 deletions e2e-tests/src/tests/diagram/system-diagram.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/********************************************************************************
* Copyright (c) 2024 CrossBreeze.
********************************************************************************/
import { expect, test } from '@eclipse-glsp/glsp-playwright';
import { CrossModelApp } from '../../page-objects/crossmodel-app';
import { CrossModelCompositeEditor } from '../../page-objects/crossmodel-composite-editor';
import { Entity } from '../../page-objects/system-diagram/diagram-elements';

test.describe('Cross Model System Diagram ', () => {
let app: CrossModelApp;

test.beforeAll(async ({ browser, playwright }) => {
app = await CrossModelApp.load({ browser, playwright, workspaceUrl: 'src/resources/mapping-example' });
});

test.afterAll(async () => {
await app.page.close();
});

test.describe.serial('Entity Create/Edit/Delete', () => {
test('create new entity via toolbox', async () => {
const diagramEditor = await app
.openEditor('ExampleDWH/diagrams/ExampleDWH.system-diagram.cm', CrossModelCompositeEditor)
.then(ed => ed.switchToSystemDiagram());
const graph = diagramEditor.diagram.graph;

// Create new entity
const entity = await graph.getNodeByLabel('CalcAge', Entity);
await diagramEditor.diagram.enableTool('Create Entity');
const taskBounds = await entity.bounds();
await taskBounds.position('bottom_center').moveRelative(0, 100).click();
// graph.waitForCreationOfType is currently not working, therefore we use a timeout
await app.page.waitForTimeout(1000);

// Verify that the entity was created as expected
const newEntity = await graph.getNodeByLabel('NewEntity', Entity);
expect(newEntity).toBeDefined();

const explorer = await app.openExplorerView();
expect(await explorer.existsFileNode('ExampleDWH/entities/NewEntity.entity.cm')).toBeTruthy();

const entityCodeEditor = await app
.openEditor('ExampleDWH/entities/NewEntity.entity.cm', CrossModelCompositeEditor)
.then(ed => ed.switchToCodeEditor());
expect(await entityCodeEditor.textContentOfLineByLineNumber(1)).toBe('entity:');
expect(await entityCodeEditor.textContentOfLineByLineNumber(2)).toMatch('id: NewEntity');
expect(await entityCodeEditor.textContentOfLineByLineNumber(3)).toMatch('name: "NewEntity');
});

test('Rename new entity via diagram label', async () => {
const diagramEditor = await app
.openEditor('ExampleDWH/diagrams/ExampleDWH.system-diagram.cm', CrossModelCompositeEditor)
.then(ed => ed.switchToSystemDiagram());
const graph = diagramEditor.diagram.graph;
const newEntity = await graph.getNodeByLabel('NewEntity', Entity);
// Rename new entity
await newEntity.rename('NewEntityRenamed');

expect(await newEntity.label).toBe('NewEntityRenamed');
const entityCodeEditor = await app
.openEditor('ExampleDWH/entities/NewEntity.entity.cm', CrossModelCompositeEditor)
.then(ed => ed.switchToCodeEditor());
expect(await entityCodeEditor.textContentOfLineByLineNumber(2)).toMatch('id: NewEntityRenamed');
expect(await entityCodeEditor.textContentOfLineByLineNumber(3)).toMatch('name: "NewEntityRenamed');
});

test('Hide new entity', async () => {
const diagramEditor = await app
.openEditor('ExampleDWH/diagrams/ExampleDWH.system-diagram.cm', CrossModelCompositeEditor)
.then(ed => ed.switchToSystemDiagram());
const graph = diagramEditor.diagram.graph;
// Hide entity
const newEntity = await graph.getNodeByLabel('NewEntityRenamed', Entity);
await diagramEditor.diagram.enableTool('Hide');
await newEntity.click();
expect((await graph.getNodes('NewEntityRenamed', Entity)).length).toBe(0);
// Todo: Check if entity is actually hidden, i.e. can be shown again via toolbox
});

test('Delete new entity', async () => {
const explorer = await app.openExplorerView();
await explorer.deleteNode('ExampleDWH/entities/NewEntity.entity.cm', true);

Check failure on line 82 in e2e-tests/src/tests/diagram/system-diagram.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-test / ubuntu-22.04

diagram/system-diagram.spec.ts:80:11 › Cross Model System Diagram › Entity Create/Edit/Delete › Delete new entity

1) diagram/system-diagram.spec.ts:80:11 › Cross Model System Diagram › Entity Create/Edit/Delete › Delete new entity TimeoutError: page.waitForSelector: Timeout 10000ms exceeded. =========================== logs =========================== waiting for locator('#theia-dialog-shell .dialogBlock') to be visible ============================================================ 80 | test('Delete new entity', async () => { 81 | const explorer = await app.openExplorerView(); > 82 | await explorer.deleteNode('ExampleDWH/entities/NewEntity.entity.cm', true); | ^ 83 | // Todo: Check if entity is actually deleted, i.e. can not be shown again via toolbox 84 | }); 85 | }); at TheiaDialog.waitForVisible (/home/runner/work/crossmodel/crossmodel/node_modules/@theia/playwright/src/theia-dialog.ts:31:25) at CrossModelExplorerView.deleteNode (/home/runner/work/crossmodel/crossmodel/node_modules/@theia/playwright/src/theia-explorer-view.ts:257:29) at /home/runner/work/crossmodel/crossmodel/e2e-tests/src/tests/diagram/system-diagram.spec.ts:82:10

Check failure on line 82 in e2e-tests/src/tests/diagram/system-diagram.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-test / ubuntu-22.04

diagram/system-diagram.spec.ts:80:11 › Cross Model System Diagram › Entity Create/Edit/Delete › Delete new entity

1) diagram/system-diagram.spec.ts:80:11 › Cross Model System Diagram › Entity Create/Edit/Delete › Delete new entity Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: page.waitForSelector: Timeout 10000ms exceeded. =========================== logs =========================== waiting for locator('#theia-dialog-shell .dialogBlock') to be visible ============================================================ 80 | test('Delete new entity', async () => { 81 | const explorer = await app.openExplorerView(); > 82 | await explorer.deleteNode('ExampleDWH/entities/NewEntity.entity.cm', true); | ^ 83 | // Todo: Check if entity is actually deleted, i.e. can not be shown again via toolbox 84 | }); 85 | }); at TheiaDialog.waitForVisible (/home/runner/work/crossmodel/crossmodel/node_modules/@theia/playwright/src/theia-dialog.ts:31:25) at CrossModelExplorerView.deleteNode (/home/runner/work/crossmodel/crossmodel/node_modules/@theia/playwright/src/theia-explorer-view.ts:257:29) at /home/runner/work/crossmodel/crossmodel/e2e-tests/src/tests/diagram/system-diagram.spec.ts:82:10
// Todo: Check if entity is actually deleted, i.e. can not be shown again via toolbox
});
});
});

0 comments on commit 82fbeed

Please sign in to comment.