forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix #5038: Enhance test case querySelector/querySelectorAll reliability with ensuring element existance #29
Merged
balajis-qb
merged 24 commits into
main
from
issue-5038/refactor/test/ensure-element-existance
Aug 30, 2024
Merged
Fix #5038: Enhance test case querySelector/querySelectorAll reliability with ensuring element existance #29
balajis-qb
merged 24 commits into
main
from
issue-5038/refactor/test/ensure-element-existance
Aug 30, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ctor/querySelectorAll Closes Hacker0x01#5038
…afeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
… safeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…All with safeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…h safeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…l with safeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…afeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…ySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…afeQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…Selector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…feQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…eQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…QuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…feQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…QuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…QuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…feQuerySelector/safeQuerySelectorAll to ensure element existence - This change prevents tests from passing with unexpected null elements, enhancing test reliability and catching potential issues earlier. Closes Hacker0x01#5038
…be null - As the safeQuerySelector automatically throws if the element is not found, additionally checking for null value is not needed
… the safeQuerySelector automatically throws an error if the element is not found
…und element is less than the minExpected param
…ed no of elements and remove the redundant throw error logic
…n to avoid unnecessary temporary variables
… avoid a temporary variable usage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes Hacker0x01#5038
Issue
Currently in our project test cases, in many places we followed a format like
container.querySelector('...') ?? new HTMLElement()
orcontainer.querySelectorAll('...') ?? []
. In most of these cases, we wrote a test case on top of it. But this way of using a fallback null elements won't help us to test the actual cases, as missing elements are replaced by new ones, allowing tests to pass whey they shouldn't.Contribution
To address this, a new utility function has been developed that throws an error if the querySelector result is null or if querySelectorAll returns an empty array. This ensures that missing elements are caught early and improves the reliability of our test cases.
This is just a test case update and it won't affect the source code, but just the way we're currently checking null elements. This PR mainly focus to replace the code like
container.querySelector('...') ?? new HTMLElement()
orcontainer.querySelectorAll('...') ?? []
with safer way to access the elements.Screenshots
Contribution checklist