Skip to content

Commit d8a1b5e

Browse files
committed
update e2e
1 parent 1f3eaaf commit d8a1b5e

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

packages/compass-data-modeling/src/components/drawer/diagram-editor-side-panel.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('DiagramEditorSidePanel', function () {
220220
expect(screen.getByLabelText('Name')).to.have.value('countries');
221221

222222
// Click on add relationship button
223-
userEvent.click(screen.getByRole('button', { name: 'Add relationship' }));
223+
userEvent.click(screen.getByRole('button', { name: 'Add Relationship' }));
224224

225225
// Collection is pre-selected
226226
expect(screen.getByLabelText('Local collection')).to.be.visible;
@@ -329,7 +329,7 @@ describe('DiagramEditorSidePanel', function () {
329329
expect(screen.getByLabelText('Field name')).to.have.value('name');
330330

331331
// Click on add relationship button
332-
userEvent.click(screen.getByRole('button', { name: 'Add relationship' }));
332+
userEvent.click(screen.getByRole('button', { name: 'Add Relationship' }));
333333

334334
// Collection and field are pre-selected
335335
expect(screen.getByLabelText('Local collection')).to.be.visible;

packages/compass-data-modeling/src/components/drawer/relationships-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const RelationshipsSection: React.FunctionComponent<
7373
size="xsmall"
7474
onClick={onCreateNewRelationshipClick}
7575
>
76-
Add relationship
76+
Add Relationship
7777
</Button>
7878
</>
7979
}

packages/compass-e2e-tests/tests/data-modeling-tab.test.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import toNS from 'mongodb-ns';
2222
import path from 'path';
2323
import os from 'os';
2424
import fs from 'fs/promises';
25+
import type { ChainablePromiseElement } from 'webdriverio';
2526

2627
interface Node {
2728
id: string;
@@ -42,6 +43,34 @@ type DiagramInstance = {
4243
getEdges: () => Array<Edge>;
4344
};
4445

46+
/**
47+
* Clicks on a specific element at the given coordinates.
48+
* element.click({ x: number, y: number }) doesn't work as expected,
49+
* so we do this manually using the actions API.
50+
* @param browser The Compass browser instance.
51+
* @param element The WebdriverIO element to click on.
52+
* @param coordinates The coordinates to click at.
53+
*/
54+
async function clickElementAtCoordinates(
55+
browser: CompassBrowser,
56+
element: ChainablePromiseElement,
57+
coordinates: {
58+
x: number;
59+
y: number;
60+
}
61+
) {
62+
await element.waitForClickable();
63+
const location = await element.getLocation();
64+
await browser
65+
.action('pointer')
66+
.move({
67+
x: location.x + coordinates.x,
68+
y: location.y + coordinates.y,
69+
})
70+
.down({ button: 0 }) // Left mouse button
71+
.perform();
72+
}
73+
4574
async function setupDiagram(
4675
browser: CompassBrowser,
4776
options: {
@@ -107,7 +136,12 @@ async function selectCollectionOnTheDiagram(
107136
const collectionNode = browser.$(Selectors.DataModelPreviewCollection(ns));
108137
await collectionNode.waitForClickable();
109138

110-
await collectionNode.click();
139+
await clickElementAtCoordinates(browser, collectionNode, {
140+
// we're aiming for the header (top of the node)
141+
// the default click is in the middle, most likely on a field
142+
x: 100,
143+
y: 15,
144+
});
111145

112146
await drawer.waitForDisplayed();
113147

@@ -178,7 +212,7 @@ async function dragNode(
178212
.action('pointer')
179213
.move({
180214
x: Math.round(startPosition.x + nodeSize.width / 2),
181-
y: Math.round(startPosition.y + nodeSize.height / 2),
215+
y: 15, // we're aiming for the header area (top of the node)
182216
})
183217
.down({ button: 0 }) // Left mouse button
184218
.move({ duration: 1000, origin: 'pointer', ...pointerActionMoveParams })

0 commit comments

Comments
 (0)