import { act , render , screen , within } from '@testing-library/react' ; import userEvent from '@testing-library/user-event' ; import App from './App' ; import MockProvider from './providers/mock/MockProvider' ; import type { Vis } from './vis-packs/core/visualizations' ; export async function renderApp ( ) { return act ( async ( ) => { render ( < MockProvider > < App /> < /MockProvider>); } ) ; } export async function selectExplorerNode ( path ) { for await ( const segment of path . split ( '/' ) ) { userEvent . click ( await screen . findByRole ( 'treeitem' , { name : new RegExp ( `^${ segment }(?: \\(NeXus group\\))?$` , 'u' ) , } ) ) ; } } export function queryVisSelector ( ) { return screen . queryByRole ( 'tablist' , { name : 'Visualization' } ) ; } export async function findVisSelector ( ) { return screen . findByRole ( 'tablist' , { name : 'Visualization' } ) ; } export async function findVisSelectorTabs ( ) { return within ( await findVisSelector ( ) ) . getAllByRole ( 'tab' ) ; } export async function selectVisTab ( name ) { userEvent . click ( await screen . findByRole ( 'tab' , { name } ) ) ; } /**
 * Mock console method in test.
 * Mocks are automatically restored after every test, but to restore
 * the original console method earlier, call `spy.mockRestore()`.
 */ export function mockConsoleMethod ( method ) { const spy = jest . spyOn ( console , method ) ; spy . mockImplementation ( ( ) => { } ) ; return spy ; }