File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,7 @@ $('#trigger-field-id').val('');
1212// Notify the user
1313toastr . success ( "Barcode Added to Inventory" ) ;
1414
15- // Locate the row where the barcode was entered from
16- line_item = $ ( '#' + source_field ) . closest ( '.nested-fields' ) ;
17- // Set the values in the form. This is replicating some logic from barcode_items.js.erb
18- $ ( line_item ) . find ( '[data-quantity]' ) . val ( quantity ) ;
19- $ ( line_item ) . find ( '[value="' + item_id + '"]' ) . attr ( "selected" , true ) ;
20- $ ( '#__add_line_item' ) . trigger ( 'click' ) ;
21- $ ( "input.__barcode_item_lookup" ) . last ( ) . focus ( ) ;
15+ // Trigger the capture_entry/barcode_item_lookup functions with a return keypress
16+ // which fills in the item name and quantity, adds new item, and changes focus
17+ return_keypress = $ . Event ( "keypress" , { which : 13 } )
18+ $ ( "input.__barcode_item_lookup" ) . last ( ) . trigger ( return_keypress ) ;
Original file line number Diff line number Diff line change 490490 click_on "Save"
491491 end
492492
493+ # form updates
493494 within "#donation_line_items" do
494495 barcode_field = page . find ( :xpath , "//input[@id='_barcode-lookup-0']" ) . value
495496 expect ( barcode_field ) . to eq ( new_barcode )
498499 item_field = page . find ( :xpath , "//select[@id='donation_line_items_attributes_0_item_id']" ) . value
499500 expect ( item_field ) . to eq ( Item . first . id . to_s )
500501 end
501- # form updates
502+
503+ # new line item was added and has focus
504+ within "#donation_line_items" do
505+ expect ( page ) . to have_xpath ( "//input[@id='_barcode-lookup-1']" )
506+ expect ( page ) . to have_css ( '#_barcode-lookup-1' , focused : true )
507+ end
502508 end
503509
504510 context "When the barcode is a global barcode" do
You can’t perform that action at this time.
0 commit comments