-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Prepare product_import_spec.rb for BUU as default #12668
Changes from all commits
bdc42de
91daec4
e1976c6
46696df
24defac
e0d7252
0123d6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class EnableAdminStyleV3ByDefault < ActiveRecord::Migration[7.0] | ||
def up | ||
if Rails.env.development? | ||
Flipper.enable(:admin_style_v3) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -187,6 +187,8 @@ | |||||||||||||
end | ||||||||||||||
|
||||||||||||||
it "records a timestamp on import that can be viewed and filtered under Bulk Edit Products" do | ||||||||||||||
pending "This feature was removed, see: | ||||||||||||||
https://github.com/openfoodfoundation/openfoodnetwork/issues/10694#issuecomment-1578097339" | ||||||||||||||
csv_data = <<~CSV | ||||||||||||||
name, producer, category, on_hand, price, units, unit_type, shipping_category_id | ||||||||||||||
Carrots, User Enterprise, Vegetables, 5, 3.20, 500, g, #{shipping_category_id_str} | ||||||||||||||
|
@@ -209,15 +211,18 @@ | |||||||||||||
potatoes = Spree::Product.find_by(name: 'Potatoes') | ||||||||||||||
expect(potatoes.variants.first.import_date).to be_within(1.minute).of Time.zone.now | ||||||||||||||
|
||||||||||||||
puts "TODO: migrate to v3" | ||||||||||||||
Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page | ||||||||||||||
click_link 'Go To Products Page' | ||||||||||||||
|
||||||||||||||
wait_until { page.find("#p_#{carrots.id}").present? } | ||||||||||||||
# displays product list | ||||||||||||||
expect(page).to have_field("_products_2_name", with: carrots.name.to_s) | ||||||||||||||
expect(page).to have_field("_products_5_name", with: potatoes.name.to_s) | ||||||||||||||
|
||||||||||||||
expect(page).to have_field "product_name", with: carrots.name | ||||||||||||||
expect(page).to have_field "product_name", with: potatoes.name | ||||||||||||||
toggle_columns "Import" | ||||||||||||||
click_button "Save changes" | ||||||||||||||
|
||||||||||||||
ofn_drop_down("Columns").click | ||||||||||||||
within ofn_drop_down("Columns") do | ||||||||||||||
check "Import" | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
within "tr#p_#{carrots.id} td.import_date" do | ||||||||||||||
expect(page).to have_content Time.zone.now.year | ||||||||||||||
|
@@ -675,14 +680,20 @@ | |||||||||||||
expect(page).to have_selector '.created-count', text: '2' | ||||||||||||||
expect(page).not_to have_selector '.updated-count' | ||||||||||||||
|
||||||||||||||
puts "TODO: migrate to v3" | ||||||||||||||
Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page | ||||||||||||||
default_variant_selector = "tr:has(input[aria-label=Name][value='Carrots'])" | ||||||||||||||
|
||||||||||||||
visit spree.admin_products_path | ||||||||||||||
|
||||||||||||||
within "#p_#{Spree::Product.find_by(name: 'Carrots').id}" do | ||||||||||||||
expect(page).to have_input "product_name", with: "Carrots" | ||||||||||||||
expect(page).to have_select "variant_unit_with_scale", selected: "Weight (lb)" | ||||||||||||||
expect(page).to have_content "5" # on_hand | ||||||||||||||
carrots = Spree::Product.find_by(name: 'Carrots') | ||||||||||||||
|
||||||||||||||
within "#product_#{carrots.id}" do | ||||||||||||||
expect(page).to have_input("[products][2][variants_attributes][0][display_name]", | ||||||||||||||
text: "Carrots") | ||||||||||||||
expect(page).to have_input("[products][2][variants_attributes][][0][unit_to_display]", | ||||||||||||||
text: "1 lb") | ||||||||||||||
Comment on lines
+690
to
+693
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here we can use the column labels to refer:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't seem to make that work either... I get:
The element looks like this:
So it fails to find css with Sorry if I'm missing something obvious - this looks simple, but has been quite a challenge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find that the biggest challenge is to write simple code ;) And it's a balance deciding how much time to spend on it! I think that is fine as it is. |
||||||||||||||
within(:xpath, '//*[@id="products-form"]/table/tbody[3]/tr[2]/td[7]') do | ||||||||||||||
expect(page).to have_content("5") | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
|
@@ -716,15 +727,15 @@ | |||||||||||||
expect(page).to have_content "Go To Products Page" | ||||||||||||||
expect(page).to have_content "Upload Another File" | ||||||||||||||
|
||||||||||||||
puts "TODO: migrate to v3" | ||||||||||||||
Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page | ||||||||||||||
visit spree.admin_products_path | ||||||||||||||
|
||||||||||||||
within "#p_#{Spree::Product.find_by(name: 'Cupcake').id}" do | ||||||||||||||
expect(page).to have_input "product_name", with: "Cupcake" | ||||||||||||||
expect(page).to have_select "variant_unit_with_scale", selected: "Items" | ||||||||||||||
expect(page).to have_input "variant_unit_name", with: "Bunch" | ||||||||||||||
expect(page).to have_content "5" # on_hand | ||||||||||||||
expect(page).to have_input("[products][2][variants_attributes][0][display_name]", | ||||||||||||||
text: "Cupcake") | ||||||||||||||
expect(page).to have_select "_products_2_variant_unit_with_scale", selected: "Items" | ||||||||||||||
expect(page).to have_input("[products][2][variant_unit_name]", | ||||||||||||||
text: "Bunch") | ||||||||||||||
within(:xpath, '//*[@id="products-form"]/table/tbody[3]/tr[2]/td[7]') do | ||||||||||||||
expect(page).to have_content("5") | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
|
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.
Instead of asserting backend values, we can use
ProductsHelper#row_containing_name
to find the table row containing a field in column labelled "name" with the text:(You'll need to include
ProductsHelper
at the top of the file)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'm not sure I can make it work with
row_containing_name
, as it finds the first row which contains the name "Carrots" (the product row -TR[1]
):I think we're aiming to look at the second row (i.e., the first variant row -
TR[2]
). The current implementation looks at the whole section, without specifying the row:I've added it to the base_spec_helper so we don't need to include it; do you think it's better to have it loaded only when needed?
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.
Oh well, thanks for trying, sorry to have made more work for you.
Oh I see. As it's for only a specific part of the system, I personally would have only included it on the relevant tests (I guess I forgot that from a prior review). This is fine too :)