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

[EuiDataGrid] Add remaining unit tests for focus logic #5698

Merged
merged 8 commits into from
Mar 14, 2022

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Mar 7, 2022

Summary

We had a utils/focus.test.ts file, but it only had tests for getParentCellContent. This PR writes unit tests for all the remaining exported utilities in the file.

Before

83.19%

After

99.16%

Note that the missing lines/functions are the empty arrow function initialized as placeholders in DataGridFocusContext:

I couldn't be bothered to write a suite of tests just to initialize focus context and call noop fns 🤷‍♀️

unmount_enzyme.js side effect

8b0baa3#diff-fe768e7e63543f0b9a2ef9d1c41b9248f87d76d04d0d9fa0a6dcd341697d6883 / 7bd108e

We had this conversation mostly in Slack, so I'm mentioning it here in the main GitHub issue for completeness. I wanted to avoid automatically unmounting components (i.e. preserving state) between each it() test, to build upon state between tests. The afterEach->afterAll change allows me to do so with minimal impact on memory leakage.

Checklist

No changelog; should be dev-only changes

cee-chen added 5 commits March 7, 2022 09:01
+ remove unnecessary role=gridcell check - after inspecting our DOM, that role attr is set on the topmost cell wrapper but `data-datagrid-cellcontent` is set on a div below that, so there's no way the parent cell should be inside the cell content

+ swap dataset check for hasAttribute - for some reason Jest/JSDOM was failing to register dataset, but hasAttribute works and should be equivalent
+ change unmount_enzyme helper to run after each file instead of each test, to allow onFocusUpdate tests to retain shared state between each it() block
@cee-chen
Copy link
Contributor Author

cee-chen commented Mar 7, 2022

Opening this in draft mode to kick off CI and see if the afterAll unmount enzyme change that we discussed creates any side effects/issues 🤞

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5698/

@cee-chen cee-chen marked this pull request as ready for review March 10, 2022 23:05
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5698/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

LGTM! 🦑

@cee-chen cee-chen enabled auto-merge (squash) March 14, 2022 19:43
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5698/

@cee-chen cee-chen merged commit fddf0d2 into elastic:main Mar 14, 2022
@cee-chen cee-chen deleted the datagrid/unit-tests/focus branch March 14, 2022 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants