mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Fixes under public/app/plugins * Fixes under public/app/plugins/datasource * Fixes under public/app/features * Fixes under public/app/features * Fixes under public/app/features * Fixes under public/app/components * Fix PanelNotSupported test * Fix one more warning * Fix warning in usePanelSave * Fix traceview empty response * Azure monitor fixes * More fixes * Fix tests for azure monitor * Fixes after merging master * Add comment for disabled rules * Fixes after merging master * Fixes after merging master * Adress review comments * Fix azure tests * Address review feedbacks
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { locationService } from '@grafana/runtime';
|
|
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import createMockStore from 'redux-mock-store';
|
|
import { PanelNotSupported, Props } from './PanelNotSupported';
|
|
import { PanelEditorTabId } from './types';
|
|
|
|
const setupTestContext = (options: Partial<Props>) => {
|
|
const defaults: Props = {
|
|
message: '',
|
|
dispatch: jest.fn(),
|
|
};
|
|
const store = createMockStore();
|
|
|
|
const props = { ...defaults, ...options };
|
|
render(
|
|
<Provider store={store()}>
|
|
<PanelNotSupported {...props} />
|
|
</Provider>
|
|
);
|
|
|
|
return { props };
|
|
};
|
|
|
|
describe('PanelNotSupported', () => {
|
|
describe('when component is mounted', () => {
|
|
it('then the supplied message should be shown', () => {
|
|
setupTestContext({ message: 'Expected message' });
|
|
|
|
expect(screen.getByRole('heading', { name: /expected message/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it('then the back to queries button should exist', () => {
|
|
setupTestContext({ message: 'Expected message' });
|
|
expect(screen.getByRole('button', { name: /go back to queries/i })).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe('when the back to queries button is clicked', () => {
|
|
it('then correct action should be dispatched', () => {
|
|
setupTestContext({});
|
|
userEvent.click(screen.getByRole('button', { name: /go back to queries/i }));
|
|
expect(locationService.getSearchObject().tab).toBe(PanelEditorTabId.Query);
|
|
});
|
|
});
|
|
});
|