From 71ffa5e5db4fe7d73281ee2b8c1e208d104dbdfb Mon Sep 17 00:00:00 2001 From: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> Date: Tue, 24 May 2022 10:17:40 +0100 Subject: [PATCH] Chore: Converts SaveDashboardAsForm tests to RTL (#49436) --- .betterer.results | 3 --- .../forms/SaveDashboardAsForm.test.tsx | 13 +++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.betterer.results b/.betterer.results index 41cffdb13c8..7c54b12b30d 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] ], diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx index 4a36443114c..1dc771bdbc8 100644 --- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.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'; import * as api from 'app/features/manage-dashboards/state/actions'; @@ -35,7 +35,7 @@ const renderAndSubmitForm = async ( submitSpy: jest.Mock, otherProps: Partial = {} ) => { - const container = mount( + render( {}} @@ -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', () => {