justinpark commented on code in PR #27422: URL: https://github.com/apache/superset/pull/27422#discussion_r1516655143
########## superset-frontend/src/features/home/ActivityTable.test.tsx: ########## @@ -85,55 +78,61 @@ describe('ActivityTable', () => { isFetchingActivityData: false, }; - let wrapper: ReactWrapper; + const activityViewedTabProps = { + activeChild: TableTab.Viewed, + activityData: mockData, + setActiveChild: jest.fn(), + user: { userId: '1' }, + isFetchingActivityData: false, + }; - beforeAll(async () => { - await act(async () => { - wrapper = mount( - <Provider store={store}> - <ActivityTable {...activityProps} /> - </Provider>, - ); - }); - }); + const emptyActivityProps = { + activeChild: TableTab.Created, + activityData: {}, + setActiveChild: jest.fn(), + user: { userId: '1' }, + isFetchingActivityData: false, + }; - it('the component renders', () => { - expect(wrapper.find(ActivityTable)).toExist(); + const renderOptions = { + useRedux: true, + useRouter: true, + }; + + const renderActivityTable = (props: any) => + render(<ActivityTable {...props} />, renderOptions); + + it('the component renders with ActivityCards', async () => { + renderActivityTable(activityProps); + expect(screen.getByText(/dashboard_test/i)).toBeInTheDocument(); }); - it('renders tabs with three buttons', () => { - expect(wrapper.find('[role="tab"]')).toHaveLength(3); + it('renders tabs with three buttons', async () => { + renderActivityTable(activityProps); + expect(screen.getAllByRole('tab')).toHaveLength(3); }); - it('renders ActivityCards', async () => { - expect(wrapper.find('ListViewCard')).toExist(); + it('renders Viewed tab with ActivityCards', async () => { + renderActivityTable(activityViewedTabProps); + expect(screen.getByText(/chartychart/i)).toBeInTheDocument(); }); it('calls the getEdited batch call when edited tab is clicked', async () => { - act(() => { - const handler = wrapper.find('[role="tab"] a').at(1).prop('onClick'); - if (handler) { - handler({} as any); - } - }); + renderActivityTable(activityProps); + const editedButton = screen.getByText(/edited/i); + expect(editedButton).toBeInTheDocument(); + userEvent.click(editedButton); Review Comment: Could you kindly make use of `import { fireEvent } from spec/helpers/testing-library` as opposed to userEvent for click events? We typically reserve userEvent for certain custom events, such as a file upload event. ```suggestion fireEvent.click(editedButton); ``` -- 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