-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Prepare product_import_spec.rb for BUU as default #12668
Conversation
2708202
to
2ae57b8
Compare
As of now, it is not clear whether we wish to re-implement this feature on BUU
Removes TODO, preparing spec for admin_style_3 (2) Uses xpath to point to on hand field
Fixes xpath
e6f5c8d
to
e1976c6
Compare
expect(page).to have_content "5" # on_hand | ||
carrots = Spree::Product.find_by(name: 'Carrots') | ||
|
||
within "#product_#{carrots.id}" do |
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:
within "#product_#{carrots.id}" do | |
within row_containing_name("Carrots") do |
(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]
):
[14] pry(#<RSpec::ExampleGroups::ProductImport::WhenImportingProductsFromUploadedFile>)> page.find(row_containing_name("Carrots"))
=> #<Capybara::Node::Element tag="tr" path="//HTML[1]/BODY[1]/DIV[1]/DIV[4]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/TURBO-FRAME[1]/DIV[3]/DIV[1]/FORM[1]/TABLE[1]/TBODY[3]/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:
[8] pry(#<RSpec::ExampleGroups::ProductImport::WhenImportingProductsFromUploadedFile>)> page.find("#product_#{carrots.id}")
=> #<Capybara::Node::Element tag="tbody" path="//HTML[1]/BODY[1]/DIV[1]/DIV[4]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/TURBO-FRAME[1]/DIV[3]/DIV[1]/FORM[1]/TABLE[1]/TBODY[3]">
(You'll need to include ProductsHelper at the top of the file)
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.
I'm not sure I can make it work with row_containing_name
Oh well, thanks for trying, sorry to have made more work for you.
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?
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 :)
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") |
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.
Also here we can use the column labels to refer:
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") | |
expect(page).to have_input("Name", text: "Carrots") # (This is now already asserted by row_containing_name above) | |
expect(page).to have_input("Unit", text: "1 lb") |
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 can't seem to make that work either... I get:
Failures:
1) Product Import when importing products from uploaded file imports lines with all allowed units
Failure/Error: expect(page).to have_input("Name", text: "Carrots") # (This is now already asserted by row_containing_name above)
expected to find css "[name='Name']" within #<Capybara::Node::Element tag="tbody" path="//HTML[1]/BODY[1]/DIV[1]/DIV[4]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/TURBO-FRAME[1]/DIV[3]/DIV[1]/FORM[1]/TABLE[1]/TBODY[3]"> but there were no matches
The element looks like this:
<input aria-label="Name" placeholder="Carrots" type="text" name="[products][2][variants_attributes][0][display_name]" id="_products_2_variants_attributes_0_display_name">
So it fails to find css with name='Name'
. Hence I could make it work with name="[products][2][variants_attributes][0][display_name]"
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 comment
The 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.
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.
This is looking good! I'm not sure if it's ready, but looks good to me so far.
I think the PR description needs updating; I believe it closes #12627
edit: I just saw your final comment and I think you intended it to be ready, so I'll request a second review and update the description.
expect(page).to have_content "5" # on_hand | ||
carrots = Spree::Product.find_by(name: 'Carrots') | ||
|
||
within "#product_#{carrots.id}" do |
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
Oh well, thanks for trying, sorry to have made more work for you.
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?
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 :)
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") |
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 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.
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.
Looks good 👍
I am not really across the plan for BUU testing, but are removing test for the legacy bulk edit product page ? It seems a bit early as it's still in use.
Oh actually that's a really good point, we don't need to be removing it as part of this PR! I think it should still work. @filipefurtad0 would you agree to restore it? |
Reverts removal from bulk_product_spec.rb
We don't want to enable this in production just yet
This should have an effect on test environment
51a493d
to
0123d6f
Compare
Oh... Of course. I forgot we're still using it in production. Restored the file and squashed it with the commit which was removing it in the first place. Thanks @rioug @dacook. |
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.
Great, I think this is ready to go.
However, as there's currently some blocking bugs on the new product screen, I won't merge right now, because it might cause drama for new developers.
Edit: oh it requires manual testing first anyway :)
What? Why?
./spec/system/admin/product_import_spec.rb
for BUU.admin_style_v3
active by default for new environmentsadmin_style_v3
to be active on all dev environmentsFor reviewing: suggest viewing overall diff.
What should we test?
Feature
admin_style_v3
should be activated by default in the:Staging and production environments:
Test instructions:
admin_style_v3
feature-> Verify that the feature is fully enabled
admin_style_v3
feature exists-> Verify that there are no changes on the
admin_style_v3
feature settings (set on the second step)Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates