Skip to content
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

[BUU] Activate admin_style_v3 for most system specs #11645

Conversation

filipefurtad0
Copy link
Contributor

@filipefurtad0 filipefurtad0 commented Oct 10, 2023

What? Why?

!! Not to be merged just yet, as it activates BUU by default !!

It does not yet fully address feature parity, I've disconnected the issue #11845

  • Enables the BUU toggle on base_spec_helper.rb;
  • Fixes case on text assertions
  • Fixes failing tests due to overlapping elements; a helper was created to deal with this

In what #11845 concerns, this is the current state (this will be updated as progressed):


As an Administrator
  I want to be able to manage products in bulk
  listing products
    displays a list of products - **DONE**
    displays a message when number of products is zero - **DONE**
    displays a select box for suppliers, with the appropriate supplier selected - **PENDING (should be fixed in #11932)**
    displays an on hand count in a span for each product - **DONE**
    displays 'on demand' for any variant that is available on demand - **DONE**
    displays a select box for the unit of measure for the product's variants - **PENDING**
    displays a text field for the item name when unit is set to 'Items' - **PENDING**

What should we test?

  • System tests should display the BUU design on all admin pages
  • Green build

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

This can be done once we have completed all BUU1 features, including:

Documentation updates

@filipefurtad0 filipefurtad0 added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Oct 10, 2023
@filipefurtad0
Copy link
Contributor Author

Ok, some /admin specs are failing, moving to in Dev.

@dacook
Copy link
Member

dacook commented Oct 10, 2023

Thanks Filipe! It looks like probably all of these failures are due to a style change in capitalisation, which results in text no longer matching. Eg:

  expected to find text "DISTRIBUTOR ..." in "Distributor..."

I'm not sure of the most efficient way to solve this, but I've often thought that these expectations shouldn't be case-sensitive (they still convey the same meaning to the user), so I would argue that we change that. I'll raise in #core-devs.

@dacook
Copy link
Member

dacook commented Oct 10, 2023

I discussed with Maikel, and agreed it's worth updating the text in the specs to be more readable and better match what's on the screen.

We also agreed that it's helpful to optionally add a matcher like have_content_i to better handle this in the future.

@filipefurtad0 would you like to try this, or perhaps hand over for a good-first-issue?

@filipefurtad0
Copy link
Contributor Author

Happy to have a go at this 👍
Thanks @dacook

@filipefurtad0 filipefurtad0 self-assigned this Oct 11, 2023
@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch 5 times, most recently from a5e5209 to c50219e Compare October 15, 2023 22:04
dacook

This comment was marked as resolved.

@filipefurtad0
Copy link
Contributor Author

Hum, indeed there are some failing tests now. I've left this one forgotten in In Dev, but now of course the code has changed (after rebasing).

Either way, even after fixing, I guess we'll only be able to merge this PR once we're ready to release the feature, right? So, maybe we should hold this one for a while... And update everything once we're ready to release BUU.

What do you think @dacook ?

@dacook
Copy link
Member

dacook commented Oct 24, 2023

🤔 Hmm.

  • We want to continue supporting the old (current) admin styles, so need to ensure it's being tested
  • We want to also test with the new styles, in case any new problems come up

We could run the specs twice, for both old and new.
But I don't think it's necessary. Apart from the bulk products screen, the only changes are styling (colours, padding, fonts, etc).

So I agree, let's keep this PR in dev, and wait until we get closer to releasing admin_style_v3. We can occasionally refresh this branch when needed until then.

@dacook dacook marked this pull request as draft October 24, 2023 22:50
@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch 2 times, most recently from 50f4af8 to 67c4768 Compare October 25, 2023 12:12
@filipefurtad0
Copy link
Contributor Author

So I agree, let's keep this PR in dev, and wait until we get closer to releasing admin_style_v3. We can occasionally refresh this branch when needed until then.

Ok, great - thanks. I've updated it with a few changes so it's green again.

@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch from 67c4768 to d8313b8 Compare November 21, 2023 18:07
@filipefurtad0
Copy link
Contributor Author

Ok, I've fixed conflicts, rebased, updated a test - it's green again.

It seems to me the challenge now, is to migrate the relevant tests from the legacy products page into the spec for new product page; After that, we can delete the legacy spec file.

Does this sound like a good plan @dacook?

@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch 2 times, most recently from 66d6103 to 1cc7bc4 Compare November 22, 2023 19:38
@dacook
Copy link
Member

dacook commented Nov 22, 2023

Awesome, thanks Filipe! I've created an issue for this:

I think we shouldn't delete the legacy spec until we remove the feature toggle.

@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch 5 times, most recently from 2f2c300 to 93dd4c8 Compare November 28, 2023 17:26
@filipefurtad0 filipefurtad0 force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch 2 times, most recently from e5bdc85 to 4c8f8dc Compare December 13, 2023 11:21
filipefurtad0 and others added 8 commits July 1, 2024 12:24
on the New variant button

This test needs to be improved as, for Capybara, the text seems to be always visible, although it only does become visible by hovering.
This feature does not exist in BUU

Replaces previous add variant button click with correct version
These seem to have been changed since the previous rebase.
I'm not sure why it's not appearing on my computer, but it was an unnecessary duplicate message, so I'm happy to remove it.
@dacook dacook force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch from 3d9ea3f to eccc6f4 Compare July 1, 2024 05:25
@dacook
Copy link
Member

dacook commented Jul 1, 2024

Hi @filipefurtad0 , I went ahead and rebased this to prepare for merge. I condensed some of the past commits, and added some more fixes.
I also added some "TODO" comments where we are still referring to the old Bulk Edit Products screen. I'd like to migrate those over to the new screen soon, but I think it can wait so that we can merge this long-running branch.

It breaks due to a change of the spec environment. There's no point fixing it, it's no longer required.
@dacook dacook force-pushed the activate_buu_toggle_by_default_to_run_the_test_suite branch from eccc6f4 to b1aafbf Compare July 1, 2024 05:31
@dacook dacook self-assigned this Jul 1, 2024
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the latest changes are mine, I'm approving to resolve the "changes requested".

@dacook dacook marked this pull request as ready for review July 1, 2024 05:34
@dacook dacook requested a review from rioug July 1, 2024 06:47
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good !

@dacook dacook changed the title [BUU] Activate admin_style_v3 for all system specs [BUU] Activate admin_style_v3 for most system specs Jul 2, 2024
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge chunk of work. Well done for taming this.

There are many little bits I would have like to see improved in the history but this needs to be merged as soon as possible to avoid more rebase errors.

spec/system/admin/reports_spec.rb Outdated Show resolved Hide resolved
Comment on lines -32 to -37
it "displays a message when number of products is zero" do
visit spree.admin_products_path

expect(page).to have_text "No products yet. Why don't you add some?"
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main commit message doesn't reflect the commit content.

Comment on lines +38 to +39
# Click dismiss on distributor warning
click_button 'Dismiss'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could setup the enterprise properly to avoid the warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #12652 🙏

Comment on lines +534 to +535
# overlapping warning, we need to use 'node.trigger("click")'
page.find(:button, "Save").trigger("click")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we dismiss the warning first? Otherwise this is a UX issue. Users can't "find button and trigger save" with their mouse.

Comment on lines 778 to 783
<<<<<<< HEAD
expect(page).not_to have_content different_shipping_method_for_distributor1.name
=======
expect(page).to_not have_content different_shipping_method_for_distributor1.name
dismiss_warning
>>>>>>> 2ddec2cff4 (Deals with overlapping elements)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another conflict that could have been squashed.

Comment on lines 168 to 171
within(:xpath, '//*[@id="products-form"]/table/tbody[1]/tr[1]/td[5]/div') do
expect(page).to have_content "On demand"
end
within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[1]/td[5]/div') do
expect(page).to have_content "20" # displays the total stock
end
within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[2]/td[5]/div') do
expect(page).to have_content "16" # displays the stock for variant_2
end
within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[3]/td[5]/div') do
expect(page).to have_content "4" # displays the stock for variant_3
end
expect(page).to have_content "On demand"
expect(page).to_not have_content "20" # does not display the total stock
expect(page).to have_content "16" # displays the stock for variant_2
expect(page).to have_content "4" # displays the stock for variant_3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the previous selectors were to avoid false passes of the spec. Imagine this spec running with Enterprise 4. It would show the number 4 even without displaying that stock.

Copy link
Contributor Author

@filipefurtad0 filipefurtad0 Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should revert to the xpath code? Maybe an alternative would be to include the count: 1 attribute/condition, or even make the on_hand numbers a bit more specific, like 111, 222, 333 - I know, in theory, we could still have Enterprise 111, but maybe more unlikely.

What do you think @mkllnk @dacook ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would go back to the xpath. If this was a more common use case then I would create helpers for that. Aren't there some helpers for accessing table rows by a displayed name, for example? That would be better.

Copy link
Member

@dacook dacook Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in fact the inputs have labels associated with them, so something like this should work:

within row_containing_name("variant name") do
  expect(page).to have_field "On demand", checked: true
  expect(page).to_not have_field "On Hand", with: 20
end

(hmm, we need to fix that inconsistent capitalisation..)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was targeting the fields inside the popout.

If we want to check the display, we can target the button (which opens the popout):

within row_containing_name("variant name") do
  expect(page).to have_button "On Hand", with: "On demand"
  expect(page).to_not have_button "On Hand", with: 20
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better might be to say something like this. But as far as I know Capybara doesn't have a convenient way to check all text (including button labels). We could make a helper for that, but it's not worth the bother..

within row_containing_name("variant name") do
  within column("On Hand") do
    expect(page).to have_text "On demand"
    expect(page).to_not have_text "20"
  end
end

@mkllnk mkllnk merged commit a83daae into openfoodfoundation:master Jul 2, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants