Skip to content

Commit

Permalink
Try to stablize tests that check for deleted elements in the explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed Nov 22, 2024
1 parent ff0cf0f commit 5dd062e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
17 changes: 16 additions & 1 deletion e2e-tests/src/page-objects/cm-explorer-view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/********************************************************************************
* Copyright (c) 2023 CrossBreeze.
********************************************************************************/
import { TheiaApp, TheiaExplorerView } from '@theia/playwright';
import { TheiaApp, TheiaExplorerFileStatNode, TheiaExplorerView } from '@theia/playwright';
import { CMMTabBarToolbar } from './cm-tab-bar-toolbar';

export class CMExplorerView extends TheiaExplorerView {
Expand All @@ -11,4 +11,19 @@ export class CMExplorerView extends TheiaExplorerView {
super(app);
this.tabBarToolbar = new CMMTabBarToolbar(this);
}

/**
* The `existsFileNode` method implementation of the `TheiaExplorerView` PO don't
* behave as expected. If a node does not exist they will throw an errors instead of
* returning `false`.
* This method is a workaround and allows us to quickly check if a file node is visible
*/
async findTreeNode(path: string): Promise<TheiaExplorerFileStatNode | undefined> {
const fullPathSelector = this.treeNodeSelector(path);
const treeNodeElement = await this.page.$(fullPathSelector);
if (treeNodeElement) {
return new TheiaExplorerFileStatNode(treeNodeElement, this);
}
return undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ test.describe.serial('Add/Edit/Delete relationship in a diagram ', () => {
expect(await diagramCodeEditor.numberOfLines()).toBe(11);

const explorer = await app.openExplorerView();
expect(await explorer.existsFileNode(NEW_RELATIONSHIP_PATH)).toBeFalsy();
expect(await explorer.findTreeNode(NEW_RELATIONSHIP_PATH)).toBeUndefined();
});
});
3 changes: 1 addition & 2 deletions e2e-tests/src/tests/form/add-edit-delete-entity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ test.describe('Add/Edit/Delete entity from explorer', () => {
const fileStatElements = await explorer.visibleFileStatNodes();
await explorer.deleteNode(NEW_ENTITY2_PATH);
await explorer.waitForFileNodesToDecrease(fileStatElements.length);
const updatedFileStatElements = await explorer.visibleFileStatNodes();
expect(updatedFileStatElements).toHaveLength(fileStatElements.length - 2);
expect(await explorer.findTreeNode(NEW_ENTITY2_PATH)).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ test.describe('Add/Edit/Delete relationship from explorer', () => {

test('Delete relationship via context menu', async () => {
const explorer = await app.openExplorerView();
await explorer.getFileStatNodeByLabel('ExampleCRM/relationships');
const fileStatElements = await explorer.visibleFileStatNodes();
await explorer.deleteNode(NEW_RELATIONSHIP_PATH);
await explorer.waitForFileNodesToDecrease(fileStatElements.length);
const updatedFileStatElements = await explorer.visibleFileStatNodes();
expect(updatedFileStatElements).toHaveLength(fileStatElements.length - 1);
expect(await explorer.findTreeNode(NEW_RELATIONSHIP_PATH)).toBeUndefined();
});
});

0 comments on commit 5dd062e

Please sign in to comment.