Skip to content

Commit 59fc2af

Browse files
authored
Merge pull request #571 from Geode-solutions/fix/highlight-visibility
fix(componentColor): Add e2e test for specific component style options
2 parents 5f02023 + 5b1b5e7 commit 59fc2af

9 files changed

Lines changed: 66 additions & 37 deletions

File tree

tests/e2e/tests/camera_tools.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
beforeAllTimeout,
1010
changeColor,
1111
dragContextMenu,
12+
expandComponentsType,
1213
focusObjectInTree,
14+
getTreeRowByText,
1315
hideObjectInTree,
1416
hoverViewerCenter,
1517
loadData,
@@ -93,7 +95,13 @@ test("overlapping objects context menu at top", async () => {
9395
});
9496

9597
test("visibility off grid and expand brep focus", async () => {
96-
await hideObjectInTree(window, "RegularGrid3D");
98+
await expandComponentsType(window, "mainObjectTree", "RegularGrid3D");
99+
await getTreeRowByText(window, "mainObjectTree", "test")
100+
.locator(".mdi-eye")
101+
.first()
102+
.click({ force: true });
103+
await window.waitForTimeout(afterActionWait);
104+
97105
await focusObjectInTree(window, "BRep", "test");
98106
await window.mouse.move(0, 0);
99107
await window.waitForTimeout(afterActionWait);

tests/e2e/tests/model.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
beforeAllTimeout,
1010
changeColorWithSlider,
1111
changeColoringStyle,
12+
changeComponentColorToBlue,
1213
changeOpacity,
1314
expandComponentsType,
1415
hideObjectInTree,
@@ -170,3 +171,25 @@ test("object tree hover first surface", async () => {
170171
await hoverModelComponentRow(window, "00000000-");
171172
await expect(window).toHaveScreenshot();
172173
});
174+
175+
test("toggle object tree main", async () => {
176+
await window.getByTestId("toggleObjectsButton").click();
177+
await window.waitForTimeout(afterActionWait);
178+
await expect(window).toHaveScreenshot();
179+
});
180+
181+
test("context menu through non visible surface", async () => {
182+
await window
183+
.getByTestId("modelComponentsObjectTree")
184+
.locator(".tree-row-wrapper", { hasText: "00000000-" })
185+
.nth(4)
186+
.locator(".mdi-eye-off-outline")
187+
.first()
188+
.click();
189+
await window.waitForTimeout(afterActionWait);
190+
const canvas = window.getByTestId("hybridViewer").locator("canvas");
191+
const box = await canvas.boundingBox();
192+
await viewerContextMenu(window, box.width / 2, box.height / 2);
193+
await changeComponentColorToBlue(window, "modelStyleMenu");
194+
await expect(window).toHaveScreenshot();
195+
});
1.56 KB
Loading
Binary file not shown.
-214 Bytes
Loading
215 KB
Loading
-203 Bytes
Loading
104 KB
Loading

tests/e2e/utils/viewer_interaction.js

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,7 @@ async function applyAttribute(
4444
menuTestId,
4545
{ attributeType, attributeName, colorMap = undefined, min = undefined, max = undefined } = {},
4646
) {
47-
const menuButton = window.getByTestId(menuTestId);
48-
if (
49-
!(await menuButton
50-
.locator("button.menu-btn")
51-
.evaluate((node) => node.classList.contains("v-btn--active")))
52-
) {
53-
await menuButton.click();
54-
await window.waitForTimeout(afterActionWait);
55-
}
47+
await ensureMenuOpen(window, menuTestId);
5648

5749
await window.getByTestId("coloringStyleSelector").first().click();
5850
await window.waitForTimeout(afterActionWait);
@@ -74,16 +66,7 @@ async function applyAttribute(
7466
.filter({ visible: true })
7567
.first();
7668

77-
if ((await option.count()) > 0) {
78-
await option.click();
79-
} else {
80-
await window
81-
.locator(".v-overlay-container")
82-
.locator(".v-list-item")
83-
.filter({ visible: true })
84-
.first()
85-
.click();
86-
}
69+
await option.click();
8770
await window.waitForTimeout(afterActionWait);
8871

8972
if (colorMap) {
@@ -165,20 +148,26 @@ async function highlightData(window, category) {
165148
await window.waitForTimeout(afterActionWait);
166149
}
167150

151+
function getTreeRowByText(window, treeTestId, text) {
152+
return window
153+
.getByTestId(treeTestId)
154+
.locator(".tree-row-wrapper")
155+
.filter({ hasText: text })
156+
.first();
157+
}
158+
168159
async function expandComponentsType(window, treeId, categoryName) {
169-
const tree = window.getByTestId(treeId);
170-
const row = tree.locator(".tree-row-wrapper").filter({ hasText: categoryName }).first();
171-
const rightChevron = row.locator(".mdi-menu-right").first();
160+
const rightChevron = getTreeRowByText(window, treeId, categoryName)
161+
.locator(".mdi-menu-right")
162+
.first();
172163
if ((await rightChevron.count()) > 0) {
173164
await rightChevron.dispatchEvent("click");
174165
await window.waitForTimeout(afterActionWait);
175166
}
176167
}
177168

178169
async function hoverModelComponentRow(window, hasText) {
179-
const modelComponentsObjectTree = window.getByTestId("modelComponentsObjectTree");
180-
const row = modelComponentsObjectTree.locator(".tree-row-wrapper").filter({ hasText }).first();
181-
await row.hover();
170+
await getTreeRowByText(window, "modelComponentsObjectTree", hasText).hover();
182171
await window.waitForTimeout(afterActionWait);
183172
}
184173

@@ -258,24 +247,31 @@ async function dragContextMenu(window, { targetX, targetY } = {}) {
258247
}
259248

260249
async function hideObjectInTree(window, objectName, treeTestId = "mainObjectTree") {
261-
const tree = window.getByTestId(treeTestId);
262-
const row = tree.locator(".tree-row-wrapper").filter({ hasText: objectName });
263-
await row.locator(".mdi-eye").first().click();
250+
await getTreeRowByText(window, treeTestId, objectName)
251+
.locator(".mdi-eye")
252+
.first()
253+
.click({ force: true });
254+
await window.waitForTimeout(afterActionWait);
255+
}
256+
257+
async function focusObjectInTree(window, folderName, objectName) {
258+
await expandComponentsType(window, "mainObjectTree", folderName);
259+
await getTreeRowByText(window, "mainObjectTree", objectName)
260+
.locator("button:has(.mdi-target)")
261+
.click();
264262
await window.waitForTimeout(afterActionWait);
265263
}
266264

267265
async function showObjectInTree(window, objectName, treeTestId = "mainObjectTree") {
268-
const tree = window.getByTestId(treeTestId);
269-
const row = tree.locator(".tree-row-wrapper").filter({ hasText: objectName });
270-
await row.locator("button:has(.mdi-eye-off-outline, .mdi-eye-minus-outline)").first().click();
266+
await getTreeRowByText(window, treeTestId, objectName)
267+
.locator(".mdi-eye-off-outline")
268+
.first()
269+
.click({ force: true });
271270
await window.waitForTimeout(afterActionWait);
272271
}
273272

274-
async function focusObjectInTree(window, folderName, objectName) {
275-
await expandComponentsType(window, "mainObjectTree", folderName);
276-
const mainObjectTree = window.getByTestId("mainObjectTree");
277-
const row = mainObjectTree.locator(".tree-row-wrapper").filter({ hasText: objectName }).first();
278-
await row.locator("button:has(.mdi-target)").click();
273+
async function openObjectTreeContextMenu(window, objectName, treeTestId = "mainObjectTree") {
274+
await getTreeRowByText(window, treeTestId, objectName).click({ button: "right" });
279275
await window.waitForTimeout(afterActionWait);
280276
}
281277

@@ -303,6 +299,7 @@ export {
303299
expandComponentsType,
304300
focusObjectInTree,
305301
hideObjectInTree,
302+
openObjectTreeContextMenu,
306303
highlightData,
307304
hoverModelComponentRow,
308305
pointsVisibility,
@@ -313,6 +310,7 @@ export {
313310
hoverViewerCenter,
314311
showObjectInTree,
315312
changeColoringStyle,
313+
getTreeRowByText,
316314
};
317315

318316
export { loadData } from "./load.js";

0 commit comments

Comments
 (0)