Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(sqllab): Convert tests to RTL for SqlEditor #22093

Merged

Conversation

corbinrobb
Copy link
Contributor

SUMMARY

Main goal of this PR is to convert SqlEditor's Enzyme tests to React Testing Library with a secondary goal of removing act errors.

Most tests were checking if a component rendered or not. So the changes made were to render with RTL and check if a visual element that the user would only see if the component were or weren't there, instead of checking whether the component itself exists.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

  • cd into superset-frontend
  • npm run test -- src/SqlLab/components/SqlEditor/SqlEditor.test.jsx
  • Check for passing tests and act errors

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Contributor

@EugeneTorap EugeneTorap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @corbinrobb! Thank you for this nice PR!
Can we remove import { mount } from 'enzyme'; on 20 line?

await waitForComponentToPaint(wrapper);
expect(wrapper.find(AntdDropdown)).toExist();
const { findByText } = setup(updatedProps, store);
fireEvent.click(await findByText('LIMIT:'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most projects have a few use cases for fireEvent, but the majority of the time you should probably use @testing-library/user-event.

Should we use user-event here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should! I will switch that over and push up the changes.

@corbinrobb
Copy link
Contributor Author

Hey! @EugeneTorap Thank you and thanks for the review!

I would like to remove the mount import on line 20 and also the buildWrapper function on line 120 but they are still being used inside of the two skipped tests lines 235 - 260. I am not sure what is going one with those two or whether we want to keep them or not.

I notice there is a comment by @eschutho to convert them to RTL. What do you all think? Should I try to convert those two, delete them, or leave them alone?

@EugeneTorap
Copy link
Contributor

Can we try to convert them to RTL?
@michael-s-molina @kgabryje What do you think about it?

@michael-s-molina
Copy link
Member

Can we try to convert them to RTL? @michael-s-molina @kgabryje What do you think about it?

I think we can try to convert them to RTL but I'm not sure if it will be easy because they are testing overflowing behavior. If it becomes too hard, then we can remove them from the file and write those tests using Cypress.

@EugeneTorap
Copy link
Contributor

Hi @corbinrobb!
Can we merge your PR or you're working on rewriting skipped tests?

@corbinrobb
Copy link
Contributor Author

Hey @EugeneTorap! I was planning on working on it this week but i have been pretty busy.

I am okay with merging it if you think that is best! I can open another PR if I am able to figure out how to convert those.

@michael-s-molina michael-s-molina merged commit 83d990d into apache:master Nov 17, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants