diff --git a/.betterer.results b/.betterer.results index 943d2b63ecf..41cffdb13c8 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] ], diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx index 8a5b60159d9..78e2dbfe462 100644 --- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx @@ -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( {}} @@ -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( {}} @@ -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(); }); });