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: small error in isOutOfStock
logic
#33
Conversation
I too am not a TS dev by trade! Welcome 😃 ! You're absolutely right. I want to cover my ass and say I didn't write this, but I did merge it and reviewed it 😭 Looks good to me. Just pass the lint and we'll be good to go!
|
Don't worry about it, it wouldn't be software development without random bugs to fix. I'm assuming I can add the other best buy cards in a separate PR? |
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.
nevermind - I see what you meant now. This is good!
Let's pretend our dom text is this: And // at first result is false
const result = false
// first loop is 'out of stock'
result = `blah blah out of stock blah blah`.includes('out of stock');
// sets result to true
// now second loop comes around and does a check against 'not available'
result = `blah blah out of stock blah blah`.includes('not available');
// result now gets set to false and we return false. |
Yup, I thought it was merging in the results. Probably could still do that (not sure what the return of .includes is), but just breaking the function once you find our first in-stock hit makes more sense anyway! |
isOutOfStock
logic
Description
While looking into adding some of the other bestbuy AIBs, I noticed that the loop in
isOutOfStock
will always return the check that coincides with the last value ofStore::oosLabels
. This does not align with the logic in the documentation:Checks if DOM has any out-of-stock related text.
This PR addresses this issue.
There are many different ways to do this, if you have a cleaner idea in mind, feel free to suggest one. I come from a mostly Java background so I'm unsure if node has a cleaner way to do this.