@@ -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+
168159async 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
178169async 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
260249async 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
267265async 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
318316export { loadData } from "./load.js" ;
0 commit comments