rtexelm commented on code in PR #27429: URL: https://github.com/apache/superset/pull/27429#discussion_r1520108285
########## superset-frontend/src/features/home/ChartTable.test.tsx: ########## @@ -68,64 +69,53 @@ describe('ChartTable', () => { showThumbnails: false, }; - let wrapper: ReactWrapper; + const otherTabProps = { + ...mockedProps, + otherTabData: mockCharts, + }; + + const mineTabProps = { + ...mockedProps, + mine: mockCharts, + }; + + const renderOptions = { + useRedux: true, + useRouter: true, + }; - beforeEach(async () => { - act(() => { - wrapper = mount(<ChartTable store={store} {...mockedProps} />); + const renderChartTable = (props: any) => + act(async () => { + render(<ChartTable {...props} />, renderOptions); }); - await waitForComponentToPaint(wrapper); - }); - it('renders', () => { - expect(wrapper.find(ChartTable)).toExist(); + it('renders with EmptyState if no data present', async () => { + await renderChartTable(mockedProps); + expect(screen.getAllByRole('tab')).toHaveLength(3); + expect( + screen.getByText(/other charts will appear here/i), + ).toBeInTheDocument(); }); it('fetches chart favorites and renders chart cards', async () => { - act(() => { - const handler = wrapper.find('[role="tab"] a').at(0).prop('onClick'); - if (handler) { - handler({} as any); - } + await renderChartTable(mockedProps); + fireEvent.click(screen.getByText(/favorite/i)); Review Comment: @justinpark curious what should be the go-to usage, `fireEvent` or `userEvent`, [as you mentioned](https://github.com/apache/superset/pull/27422#discussion_r1516655143) we should save `userEvent` for special cases but this seems to go against the [RTL wiki](https://github.com/apache/superset/wiki/Testing-Guidelines-and-Best-Practices#react-testing-library-rtl) and [docs](https://testing-library.com/docs/user-event/intro#differences-from-fireevent) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org