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

Implement bulk export query and abstract bulk methods into own import #2279

Merged
merged 31 commits into from
Aug 14, 2020

Conversation

saberlynx
Copy link
Contributor

@saberlynx saberlynx commented Jun 30, 2020

Checklist:

@saberlynx saberlynx changed the title Bulk export Implement bulk export query and abstract bulk methods into own import Jun 30, 2020
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #2279 into master will increase coverage by 0.15%.
The diff coverage is 94.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2279      +/-   ##
==========================================
+ Coverage   54.73%   54.89%   +0.15%     
==========================================
  Files        1093     1093              
  Lines       26556    26603      +47     
  Branches     7534     7570      +36     
==========================================
+ Hits        14536    14603      +67     
+ Misses      10913    10895      -18     
+ Partials     1107     1105       -2     
Impacted Files Coverage Δ
gsa/src/web/pages/tasks/component.js 35.55% <ø> (ø)
gsa/src/web/pages/tasks/listpage.js 82.71% <82.60%> (+3.70%) ⬆️
gsa/src/web/entities/bulkactions.js 81.30% <100.00%> (ø)
gsa/src/web/graphql/tasks.js 100.00% <100.00%> (ø)
gsa/src/web/entities/actions.js 100.00% <0.00%> (+12.50%) ⬆️
gsa/src/web/components/icon/exporticon.js 100.00% <0.00%> (+18.18%) ⬆️
gsa/src/web/components/icon/tagsicon.js 100.00% <0.00%> (+20.00%) ⬆️
gsa/src/web/components/icon/trashicon.js 100.00% <0.00%> (+20.00%) ⬆️
gsa/src/web/entities/selection.js 84.61% <0.00%> (+76.92%) ⬆️

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 6b783a8...68d6a9b. Read the comment docs.

@saberlynx saberlynx force-pushed the bulk-export branch 2 times, most recently from d9db157 to fec54d4 Compare July 2, 2020 10:47
@saberlynx saberlynx changed the base branch from hyperion to master July 2, 2020 10:53
@saberlynx saberlynx marked this pull request as ready for review July 2, 2020 11:43
@saberlynx saberlynx requested review from a team and bjoernricks July 2, 2020 11:43
Copy link
Contributor

@sarahd93 sarahd93 left a comment

Choose a reason for hiding this comment

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

So we have bulkactions now that contain the BulkTagComponent, useBulkExportEntities and useBulkDeleteEntities, right? There are tests for the BulkTagComponent but I don't see any for useBulkExportEntities and useBulkDeleteEntities. We should test those too if possible.

The task listpage contains a test "should allow to export all displayed tasks". Parts of the test are commented out because the bulk actions were still missing. Shouldn't this work now, since bulk export for tasks is implemented? (Also "should allow to export all displayed tasks" is probably not the best title because bulk delete seems to be tested as well.)

@saberlynx
Copy link
Contributor Author

saberlynx commented Jul 17, 2020

So we have bulkactions now that contain the BulkTagComponent, useBulkExportEntities and useBulkDeleteEntities, right? There are tests for the BulkTagComponent but I don't see any for useBulkExportEntities and useBulkDeleteEntities. We should test those too if possible.

You're right. If we didn't abstract the functionality from just tasks alone then it would be simple. As such I'm not quite sure how to test these functions. I'll have to think about that a little more. I remember several weeks ago I wasn't able to come up with a way.

The task listpage contains a test "should allow to export all displayed tasks". Parts of the test are commented out because the bulk actions were still missing. Shouldn't this work now, since bulk export for tasks is implemented? (Also "should allow to export all displayed tasks" is probably not the best title because bulk delete seems to be tested as well.)

I don't think it should because stuff like that used to be from gmp, so we can check from the listpage if they are called. Now it's a graphql function. I can try to see if I can put the mock into the listpage test and get rid of the old tests.

Copy link
Contributor

@sarahd93 sarahd93 left a comment

Choose a reason for hiding this comment

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

I guess for useBulkExportEntities you would "just" need to test the hook with some simple mock functions for exportByFilterFunc and exportByIdsFunc and test if for each selectionType the correct function is called and returns the correct entities. But I realize that this might be a little more tricky than it looks.

Oh of course the listpage tests need to be adapted to graphQL. I think at least for bulk export this should work. Bulk delete is using refetch, though, and that seems to always break the tests, so we might not be able to test that right now.

Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

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

For me it looks good. I am just not sure about the error cases mentioned in the code comment.

@saberlynx saberlynx force-pushed the bulk-export branch 12 times, most recently from 7dee781 to fc0e187 Compare August 13, 2020 10:45
@saberlynx saberlynx marked this pull request as draft August 13, 2020 11:20
@saberlynx saberlynx force-pushed the bulk-export branch 5 times, most recently from 12eb532 to 7542f95 Compare August 13, 2020 15:55
@saberlynx saberlynx marked this pull request as ready for review August 14, 2020 07:45
Copy link
Contributor

@sarahd93 sarahd93 left a comment

Choose a reason for hiding this comment

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

The tests look really good, I think we have a pretty good coverage now.

@saberlynx saberlynx requested a review from sarahd93 August 14, 2020 11:02
Comment on lines +174 to +175
const [deleteTasksByIds] = useDeleteTasksByIds();
const [deleteTasksByFilter] = useDeleteTasksByFilter();
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation still seems to be wrong here. Maybe a bug in prettier...

@saberlynx saberlynx merged commit a56841e into greenbone:master Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants