import { render, screen } from '@testing-library/react';
import { vi } from 'vitest';
import { ReactNode } from 'react';
import { withTestRouter } from '@/react/test-utils/withRouter';
import { withTestQueryProvider } from '@/react/test-utils/withTestQuery';
import { withUserProvider } from '@/react/test-utils/withUserProvider';
import { UserViewModel } from '@/portainer/models/user';
import { NodeView } from './NodeView';
let mockParams: { endpointId: number; nodeName: string; tab?: string } = {
endpointId: 1,
nodeName: 'test-node',
};
// Mock Link component to avoid ui-router relative state resolution in tests
vi.mock('@@/Link', () => ({
Link: ({
children,
'data-cy': dataCy,
params,
...props
}: {
children: ReactNode;
'data-cy'?: string;
params?: { tab?: string };
}) => (
{
if (params?.tab) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
mockParams = { ...mockParams, tab: params.tab };
}
}}
{...props}
>
{children}
),
}));
vi.mock('@uirouter/react', async (importOriginal: () => Promise