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: exploreUtils #13719

Merged
merged 8 commits into from
Apr 7, 2021
Merged

test: exploreUtils #13719

merged 8 commits into from
Apr 7, 2021

Conversation

yardz
Copy link
Contributor

@yardz yardz commented Mar 19, 2021

SUMMARY

Creation of tests for the functions in the file.

Some functions could not be tested correctly, for these cases I created the test that and put the command skip.
Along with that I put a comment explaining why that test is not working.

I put the test of each function in a file to facilitate understanding and prevent the context of the tests from mixing and generating unwanted behaviors.

@codecov
Copy link

codecov bot commented Mar 20, 2021

Codecov Report

Merging #13719 (32d223b) into master (95a017a) will increase coverage by 1.17%.
The diff coverage is 82.58%.

❗ Current head 32d223b differs from pull request most recent head 4c3e29f. Consider uploading reports for the commit 4c3e29f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13719      +/-   ##
==========================================
+ Coverage   77.39%   78.56%   +1.17%     
==========================================
  Files         928      935       +7     
  Lines       47016    47375     +359     
  Branches     5719     5964     +245     
==========================================
+ Hits        36386    37222     +836     
+ Misses      10487    10010     -477     
  Partials      143      143              
Flag Coverage Δ
cypress 56.04% <51.16%> (-0.40%) ⬇️
javascript 67.15% <76.96%> (+4.00%) ⬆️
presto ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rset-frontend/src/SqlLab/components/QueryTable.jsx 66.66% <ø> (ø)
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 56.01% <ø> (ø)
...et-frontend/src/SqlLab/components/TableElement.jsx 88.60% <ø> (+0.23%) ⬆️
superset-frontend/src/chart/chartReducer.ts 66.19% <ø> (+1.81%) ⬆️
...end/src/common/components/DropdownButton/index.tsx 24.00% <0.00%> (ø)
superset-frontend/src/common/components/index.tsx 100.00% <ø> (ø)
...frontend/src/components/Checkbox/CheckboxIcons.tsx 85.71% <ø> (ø)
...perset-frontend/src/components/FormLabel/index.tsx 100.00% <ø> (ø)
superset-frontend/src/components/Icon/index.tsx 100.00% <ø> (ø)
superset-frontend/src/components/Loading/index.tsx 100.00% <ø> (ø)
... and 215 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95a017a...4c3e29f. Read the comment docs.

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

Hey @yardz some feedback from a first look. Also, I believe that the comments that you left through the code are not really necessary. I would remove them

@michael-s-molina
Copy link
Member

@yardz About the comments.. one way to achieve the same objective of communicating the problems that you had, is to mark this PR as a draft and make the comments in the review section. This way we can iterate on each problem and keep the code clean 😉

@yardz
Copy link
Contributor Author

yardz commented Mar 24, 2021

@yardz About the comments.. one way to achieve the same objective of communicating the problems that you had, is to mark this PR as a draft and make the comments in the review section. This way we can iterate on each problem and keep the code clean 😉

I agree, but I think that in this context it is a little more complicated. If we are going to solve all the problems that I mentioned, I believe that PR will be gigantic. This file has several functions with very dangerous behaviors. I created the tests and skipped them just to warn of these behaviors.

The idea here was to approve what can be tested but the tests are there to show some behaviors that can generate a bug.

Changing the functions, adding typescript and improvements is not the goal now ... So I thought it best not to discuss this in this PR.

* For some reason the spy is not working properly and I also did not find a way to mock only the "postForm"
* I believe that if this file is divided the problem will be solved.
*/
test.skip('Should call postForm correctly', () => {
Copy link
Member

Choose a reason for hiding this comment

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

exploreChart is just calling getExploreUrl and postForm. I don't think is necessary to create a test for exploreChart. Just testing getExploreUrl and postForm is enough.

@@ -236,6 +241,9 @@ export const buildV1ChartDataPayload = ({
export const getLegacyEndpointType = ({ resultType, resultFormat }) =>
resultFormat === 'csv' ? resultFormat : resultType;

/**
Copy link
Member

Choose a reason for hiding this comment

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

One way to test postForm is to mock document.createElement returning an object that contains a monitored submit function. Then we can test if all the required fields (action, method, token, data) are correctly configured when submitting. We can also test that the form is added hidden and removed after submit.

@michael-s-molina
Copy link
Member

michael-s-molina commented Mar 24, 2021

@yardz About the comments.. one way to achieve the same objective of communicating the problems that you had, is to mark this PR as a draft and make the comments in the review section. This way we can iterate on each problem and keep the code clean 😉

I agree, but I think that in this context it is a little more complicated. If we are going to solve all the problems that I mentioned, I believe that PR will be gigantic. This file has several functions with very dangerous behaviors. I created the tests and skipped them just to warn of these behaviors.

The idea here was to approve what can be tested but the tests are there to show some behaviors that can generate a bug.

Changing the functions, adding typescript and improvements is not the goal now ... So I thought it best not to discuss this in this PR.

If you think that the PR will be giant I suggest just keeping in this PR the tests that are working and the code without those comments. Then open another PR with the problematic tests in draft mode.

@pull-request-size pull-request-size bot added size/XL and removed size/L labels Apr 2, 2021
Copy link
Member

@pkdotson pkdotson left a comment

Choose a reason for hiding this comment

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

Couple of questions but other than that looks good to go!

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM!

@rusackas rusackas merged commit 1638e6e into apache:master Apr 7, 2021
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
* Tests for exploreUtils

* removing eslint-disable

* applying factory

* Removing skip tests and code comments.

* Improving test name

* remove comments

* Improving "shouldUseLegacyApi" tests

* fixing typo
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* Tests for exploreUtils

* removing eslint-disable

* applying factory

* Removing skip tests and code comments.

* Improving test name

* remove comments

* Improving "shouldUseLegacyApi" tests

* fixing typo
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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/XL test:component 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants