Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
core: fallback to selector, not tagName for nodeLabel #12727
core: fallback to selector, not tagName for nodeLabel #12727
Changes from 3 commits
195605f
f0a9597
676151a
a70e04e
a474e28
ebce04c
81c2c27
8e5c132
b38d83a
08cf6f5
fc9e23a
3cf7e72
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test case to
getNodeDetails
that covers the fallack?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! That's where my mind skipped, thank you, will commit change shortly :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@connorjclark quick question, when I try to use:
its saying I should be using jsdom as
window is not defined
but that is already handled at the beginning of the file. Am I missing some small detail to write this test forgetNodeDetails()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add a
global.window = {}
/global.window = undefined
to make that work–the first few lines ofgetNodeDetails
(which i'm just realizing we have no unit tests for... only smoke tests) expected there to be awindow
variable in the global scope.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that did the trick, I think I expected there to be a
window
variable in the global scope already too and was just stumped because there weren't any other unit tests that testedgetNodeDetails
and neededwindow
.I'm happy to help write a few more unit tests for the other fields in
details
likedevtoolsNodePath
,selector
,boundingRect
etc similar to how were testingnodeLabel
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a simple test to make sure the
selector
value is being used as the fallback fornodeLabel
indetails
. We could pluck each property fromdetails
using destructuring assignment to write a few unit tests for the other properties besidesnodeLabel
, unless each test needed the entiredetails
object.Haven't looked into testing the other properties in
details
but I thought this was a start for potentially writing tests for the others down the line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@connorjclark the above unit test should cover the fallback for
nodeLabel
whengetNodeLabel()
returns null, it could be a little more sturdy but let me know your thoughts.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selector is the fallback now, not the tag name.
If you make a nested element, and give both of them a class and id, that should suffice for testing purposes.
(also, it's simpler to review if you just push your possible changes, as opposed to sharing snippets in comments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my tests didn't fully illustrate that, will update with the suggested improvements.
(ok thanks for the heads up, I will make sure to avoid sharing snippets in comments in the future)