-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
product_picker.js sku lookup actually works #1106
product_picker.js sku lookup actually works #1106
Conversation
This is used in the backend UI for picking products for Spree::Promotion::Rules::Product, might be used other places too. There was code in there that looked like someone was trying to let the query match a product name or sku. But it totally didn't work, didn't do anything, was wrong in two different ways. Took me a couple hours to figure out what was going on, so I figured I'd share the fix. Sorry, don't know how to test this, looks like there aren't any tests for this kind of JS yet?
Nice catch. Looks good to me 👍 For testing this we would normally use a feature test. There is a |
Thanks! Last time I looked the CI was failing although I couldn't figure out why; unrelated? I also wonder if the sku lookup in this area should be exact match only, not partial match -- or they're going to be flooded with imprecise results after sku lookup actually works. I suggest I add that before merging (I've done that in my local fix in my local app). |
I'm also good with this, thanks @jrochkind, looks like that would be pretty terrible to debug 👍 |
How about using |
This solution only looks for |
Okay on sku_start. Ah, true on the master variant only thing, that's a problem. Not sure how to solve that, I'll see if I can figure it out. Keep in mind that at present, sku lookup simply does not work at all, it's not looking up skus. |
Okay, here's my stab at it. Haven't really tested this. It probably needs automated tests, but I'm not sure I'm going to be able to do it. |
You could test it with a feature spec that runs with JS enabled. Create two products, one with variants, and then check for the presence of the right variants in the |
I'm not sure how to start here regarding specs. Can anyone suggest an existing feature spec I can model this off of? Or is there anyone that wants to help by writing a feature spec? Or do any committers want to @jhawthorn that a feature spec may not be required for a merge? (Although I realize things have turned out slightly more complicated since his comment to that effect). I suspect the product_picker.js currently has no specs because it's kind of painful to write. |
Thanks @jrochkind I've created #1171 which adds some feature specs to test the fixed behaviour. |
Add specs for product autocomplete #1106
This is used in the backend UI for picking products for
Spree::Promotion::Rules::Product, might be used other places too.
There was code in there that looked like someone was trying to
let the query match a product name or sku. But it totally didn't work,
didn't do anything, was wrong in like two or three different ways. (useless ransack attribute name for
sku
;m
has to be inside theq
; value ofm
has to be lowercasedor
notOR
).Took me a couple hours to figure out what was going on, so I figured
I'd share the fix. Sorry, don't know how to test this, looks like
there aren't any tests for this kind of JS yet?