Chore: Converts SaveDashboardAsForm tests to RTL (#49436)

This commit is contained in:
Joao Silva 2022-05-24 10:17:40 +01:00 committed by GitHub
parent 50c2b4682a
commit 71ffa5e5db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 11 deletions

View File

@ -146,9 +146,6 @@ exports[`no enzyme tests`] = {
"public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:1463123173": [
[0, 17, 13, "RegExp match", "2409514259"]
],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:1969004590": [
[0, 17, 13, "RegExp match", "2409514259"]
],
"public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:2357087833": [
[0, 35, 13, "RegExp match", "2409514259"]
],

View File

@ -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';
import * as api from 'app/features/manage-dashboards/state/actions';
@ -35,7 +35,7 @@ const renderAndSubmitForm = async (
submitSpy: jest.Mock,
otherProps: Partial<SaveDashboardAsFormProps> = {}
) => {
const container = mount(
render(
<SaveDashboardAsForm
dashboard={dashboard as DashboardModel}
onCancel={() => {}}
@ -48,11 +48,8 @@ const renderAndSubmitForm = async (
/>
);
// @ts-ignore strict null error below
await act(async () => {
const button = container.find('button[aria-label="Save dashboard button"]');
button.simulate('submit');
});
const button = screen.getByRole('button', { name: 'Save dashboard button' });
await userEvent.click(button);
};
describe('SaveDashboardAsForm', () => {
describe('default values', () => {