2022-06-23 07:25:56 +00:00
|
|
|
import { UserContext } from '@/portainer/hooks/useUser';
|
|
|
|
import { UserViewModel } from '@/portainer/models/user';
|
2022-03-14 06:26:30 +00:00
|
|
|
import { render, within } from '@/react-tools/test-utils';
|
|
|
|
|
2022-06-28 07:42:42 +00:00
|
|
|
import { TestSidebarProvider } from '../useSidebarState';
|
|
|
|
|
2022-03-14 06:26:30 +00:00
|
|
|
import { AzureSidebar } from './AzureSidebar';
|
|
|
|
|
|
|
|
test('dashboard items should render correctly', () => {
|
|
|
|
const { getByLabelText } = renderComponent();
|
|
|
|
const dashboardItem = getByLabelText('Dashboard');
|
|
|
|
expect(dashboardItem).toBeVisible();
|
|
|
|
expect(dashboardItem).toHaveTextContent('Dashboard');
|
|
|
|
|
|
|
|
const dashboardItemElements = within(dashboardItem);
|
2022-06-28 07:42:42 +00:00
|
|
|
expect(
|
|
|
|
dashboardItemElements.getByRole('img', { hidden: true })
|
|
|
|
).toBeVisible();
|
2022-03-14 06:26:30 +00:00
|
|
|
|
2022-06-23 07:25:56 +00:00
|
|
|
const containerInstancesItem = getByLabelText(/Container Instances/i);
|
2022-03-14 06:26:30 +00:00
|
|
|
expect(containerInstancesItem).toBeVisible();
|
|
|
|
expect(containerInstancesItem).toHaveTextContent('Container instances');
|
|
|
|
|
|
|
|
const containerInstancesItemElements = within(containerInstancesItem);
|
|
|
|
expect(
|
2022-06-28 07:42:42 +00:00
|
|
|
containerInstancesItemElements.getByRole('img', { hidden: true })
|
2022-03-14 06:26:30 +00:00
|
|
|
).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
function renderComponent() {
|
2022-06-23 07:25:56 +00:00
|
|
|
const user = new UserViewModel({ Username: 'user' });
|
|
|
|
|
|
|
|
return render(
|
|
|
|
<UserContext.Provider value={{ user }}>
|
2022-06-28 07:42:42 +00:00
|
|
|
<TestSidebarProvider>
|
|
|
|
<AzureSidebar environmentId={1} />
|
|
|
|
</TestSidebarProvider>
|
2022-06-23 07:25:56 +00:00
|
|
|
</UserContext.Provider>
|
|
|
|
);
|
2022-03-14 06:26:30 +00:00
|
|
|
}
|