mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 20:43:26 -06:00
Chore: Converts SaveDashboardForm tests to RTL (#49434)
This commit is contained in:
parent
8af587e7ba
commit
51bc1bad1b
@ -149,9 +149,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:1969004590": [
|
||||
[0, 17, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx:948029434": [
|
||||
[0, 17, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:2357087833": [
|
||||
[0, 35, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { mount } from 'enzyme';
|
||||
import { screen, render } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import { DashboardModel } from 'app/features/dashboard/state';
|
||||
|
||||
@ -31,7 +31,7 @@ const prepareDashboardMock = (
|
||||
};
|
||||
};
|
||||
const renderAndSubmitForm = async (dashboard: any, submitSpy: any) => {
|
||||
const container = mount(
|
||||
render(
|
||||
<SaveDashboardForm
|
||||
dashboard={dashboard as DashboardModel}
|
||||
onCancel={() => {}}
|
||||
@ -53,16 +53,13 @@ const renderAndSubmitForm = async (dashboard: any, submitSpy: any) => {
|
||||
/>
|
||||
);
|
||||
|
||||
// @ts-ignore strict null error below
|
||||
await act(async () => {
|
||||
const button = container.find('button[aria-label="Dashboard settings Save Dashboard Modal Save button"]');
|
||||
button.simulate('submit');
|
||||
});
|
||||
const button = screen.getByRole('button', { name: 'Dashboard settings Save Dashboard Modal Save button' });
|
||||
await userEvent.click(button);
|
||||
};
|
||||
describe('SaveDashboardAsForm', () => {
|
||||
describe('time and variables toggle rendering', () => {
|
||||
it('renders switches when variables or timerange', () => {
|
||||
const container = mount(
|
||||
render(
|
||||
<SaveDashboardForm
|
||||
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any}
|
||||
onCancel={() => {}}
|
||||
@ -83,15 +80,15 @@ describe('SaveDashboardAsForm', () => {
|
||||
/>
|
||||
);
|
||||
|
||||
const variablesCheckbox = container.find(
|
||||
'input[aria-label="Dashboard settings Save Dashboard Modal Save variables checkbox"]'
|
||||
);
|
||||
const timeRangeCheckbox = container.find(
|
||||
'input[aria-label="Dashboard settings Save Dashboard Modal Save timerange checkbox"]'
|
||||
);
|
||||
const variablesCheckbox = screen.getByRole('checkbox', {
|
||||
name: 'Dashboard settings Save Dashboard Modal Save variables checkbox',
|
||||
});
|
||||
const timeRangeCheckbox = screen.getByRole('checkbox', {
|
||||
name: 'Dashboard settings Save Dashboard Modal Save timerange checkbox',
|
||||
});
|
||||
|
||||
expect(variablesCheckbox).toHaveLength(1);
|
||||
expect(timeRangeCheckbox).toHaveLength(1);
|
||||
expect(variablesCheckbox).toBeInTheDocument();
|
||||
expect(timeRangeCheckbox).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user