-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Feature/11058 change products order by name #12449
Feature/11058 change products order by name #12449
Conversation
@@ -1,5 +1,5 @@ | |||
%th | |||
%a{ "data-action": "click->search#changeSorting", "data-column": "#{column}", "data-current": sorted.to_s } | |||
%a{ "data-controller": "search", "data-action": "click->search#changeSorting", "data-column": "#{column}", "data-current": (sorted || default).to_s } |
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.
It's better to associate the search
controller here because it doesn't have to depend upon the parent to use it.
|
||
# Sort in descending order | ||
name_header.click | ||
sleep(0.2) |
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.
It requires some delay here otherwise the page
doesn't have the updated content.
I think it's something to do with Turbo, as it doesn't technically load the entire page and changes are updated in the existing page. So there's no way for Capybara to know whether the contents are fully loaded or not and it just moves on without waiting enough. 😅
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.
Actually, I think it's because capybara methods will wait until the specified element exists. Eg expect(page).to have_content /Bananas.*Apples/
would wait.
But this code doesn't know how to wait. We need something like:
expect(page).to have_content(/Bananas.*Apples/, include_input_values: true)
But I'm not sure it's worth trying to create that. How about instead of sleep, we wait for:
sleep(0.2) | |
expect(page).to have_content("Name ▼") # this indicates the re-sorted content has loaded |
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.
Thank you so much, David. It worked ❤️
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 job, it works beautifully. And not a line of javascript added!
I have a suggestion on how we might be able to avoid the sleeps, would you like to try it?
Also if you're interested, to try the rebase for a cleaner history (this makes it easier for the reviewer).
|
||
# Sort in descending order | ||
name_header.click | ||
sleep(0.2) |
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.
Actually, I think it's because capybara methods will wait until the specified element exists. Eg expect(page).to have_content /Bananas.*Apples/
would wait.
But this code doesn't know how to wait. We need something like:
expect(page).to have_content(/Bananas.*Apples/, include_input_values: true)
But I'm not sure it's worth trying to create that. How about instead of sleep, we wait for:
sleep(0.2) | |
expect(page).to have_content("Name ▼") # this indicates the re-sorted content has loaded |
@@ -1,5 +1,5 @@ | |||
%turbo-frame#products-content{ target: "_top", refresh: "morph" } | |||
.spinner-overlay.hidden | |||
.spinner-overlay{ "data-controller": "loading", "data-products-target": "loading", class: "hidden" } |
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.
It would be worth re-basing to revert this on the initial commit. If you're comfortable with interactive rebase, you could try:
git rebase -i master
You can move this commit up two lines, and change to a "fixup" which will combine it into the previous commit
pick 86f88792c2 11058: add sortable products by name
fixup ff97794684 11058: fix specs
pick b104fd8357 11058: add specs
pick 6c65008cf3 11058: add wait for the page to update
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.
Ah, that's nice. Used it for the first time properly. Would use it often now. Thanks :)
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.
A word of caution, only use it when necessary, and only for simple changes if you can.
It can get very difficult very quickly. I find often I need to git rebase --abort
!
ff97794
to
b5fe19c
Compare
8e1218a
to
881da0f
Compare
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.
Nice one 👍
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!
@@ -1,5 +1,5 @@ | |||
%turbo-frame#products-content{ target: "_top", refresh: "morph" } | |||
.spinner-overlay.hidden | |||
.spinner-overlay{ "data-controller": "loading", "data-products-target": "loading", class: "hidden" } |
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.
A word of caution, only use it when necessary, and only for simple changes if you can.
It can get very difficult very quickly. I find often I need to git rebase --abort
!
Staging failed but I don't know why :/ @dacook do you have a clue? |
Looks like the server ran out of memory :(
This is probably why fr_staging is failing intermittently. I haven't checked why, but we may need to increase the memory on that server. |
outch, I don't think FR will be able to cover an increase in memory :/ I'm surprised we run into this as I thought staging FR is an old FR production server. I thought it had a large bandwidth. I think we only have staging AU left then, will try over there as I already tried twice on FR. |
All scenarios passes kudos @chahmedejaz ! I've also tested the scenario of having several pages of products and check if the sorting was applied on all pages. FYI @mariocarabotta I wanted to test with a heavy number of products, so tried to use staging AU super admin, but the profile seems stuck in this position: discarding does not work. This state is prior to staging the PR so has nothing to do with this. I'm merging and will continue testing in production once it's released (not ideal but this is the best to keep things moving forward). |
Awesome! Thanks Rachel, I will look into the modified issue on staging and try to fix that. |
What? Why?
What should we test?
Changelog Category (reviewers may add a label for the release notes):