From 768ed973657a14a8f75458e07c196ed95f273533 Mon Sep 17 00:00:00 2001 From: Ross Mabbett <92495987+rtexelm@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:10:35 -0400 Subject: [PATCH] chore(superset-ui-core and NoResultsComponent): Migrate to RTL, add RTL modules to the ui-core (#28187) --- .../packages/superset-ui-core/package.json | 4 +++ .../components/NoResultsComponent.test.tsx | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/package.json b/superset-frontend/packages/superset-ui-core/package.json index 7ccad2a2dff58..1a26e0f49d275 100644 --- a/superset-frontend/packages/superset-ui-core/package.json +++ b/superset-frontend/packages/superset-ui-core/package.json @@ -73,6 +73,10 @@ "@emotion/cache": "^11.4.0", "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", + "@testing-library/dom": "^7.29.4", + "@testing-library/jest-dom": "^5.11.6", + "@testing-library/react": "^11.2.0", + "@testing-library/user-event": "^12.7.0", "@types/react": "*", "@types/react-loadable": "*", "@types/tinycolor2": "*", diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx index 333a0cb8750a6..fa4a3787f4e26 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx @@ -18,18 +18,25 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; -import { configure } from '@superset-ui/core'; +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { ThemeProvider, supersetTheme } from '../../../src/style'; import NoResultsComponent from '../../../src/chart/components/NoResultsComponent'; -configure(); +const renderNoResultsComponent = () => + render( + + + , + ); -describe('NoResultsComponent', () => { - it('renders the no results error', () => { - const wrapper = shallow(); +test('renders the no results error', () => { + renderNoResultsComponent(); - expect(wrapper.text()).toEqual( - 'No ResultsNo results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.', - ); - }); + expect(screen.getByText(/No Results/)).toBeInTheDocument(); + expect( + screen.getByText( + 'No results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.', + ), + ).toBeInTheDocument(); });