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

Adds a spec on BOM pagination #10383

Merged

Conversation

filipefurtad0
Copy link
Contributor

What? Why?

Adds coverage on pagination, on the BOM page.

What should we test?

  • Green build.

Release notes

Changelog Category: Technical changes

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

Dependencies

Documentation updates

@filipefurtad0 filipefurtad0 force-pushed the add_pagination_BOM_spec branch 2 times, most recently from 0586497 to 673e0c6 Compare February 6, 2023 16:56
@filipefurtad0
Copy link
Contributor Author

I'm missing this section in my tests:
image

Switching it into a draft.

@filipefurtad0 filipefurtad0 marked this pull request as draft February 6, 2023 19:51
@jibees
Copy link
Contributor

jibees commented Feb 7, 2023

@filipefurtad0
As I can see, we do have others issues on this:
Capture d’écran 2023-02-07 à 15 06 07
--> Pagination does not work (on specs...) 🔥

@filipefurtad0
Copy link
Contributor Author

This will need a rebase after merging #10391 and getting the build green again. Keeping it In Dev for now.

@filipefurtad0
Copy link
Contributor Author

As I can see, we do have others issues on this:

@jibees do you still observe this issue? I've tested quickly on Safari 13 and could not observe it, so maybe something with the test environment.

After rebasing build is green (except for the flaky Jest specs), moved to code review

@jibees
Copy link
Contributor

jibees commented Feb 13, 2023

Build is still red. Did you actually rebased? I wanted to rebase you're PR but seems like I don't have the authorization, strange, this happens for the first time.
Nevertheless, I run

bundle exec rspec spec/system/admin/bulk_order_management_spec.rb:62

and spec pass.

This was on my machine as expected ;)

Copy link
Contributor

@jibees jibees left a comment

Choose a reason for hiding this comment

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

Thanks!

One quick comment ;)

@filipefurtad0 filipefurtad0 force-pushed the add_pagination_BOM_spec branch 3 times, most recently from 53cf6c9 to bfa1605 Compare February 13, 2023 11:48
@filipefurtad0
Copy link
Contributor Author

I wanted to rebase you're PR but seems like I don't have the authorization, strange, this happens for the first time.

No idea why that happened on this branch...

and spec pass.
This was on my machine as expected ;)

Great, so the issue is resolved 👍

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.

Great! Happy for you to merge. Just left it in case you wanted to improve the negative matcher.

it "splits results according to line items from orders" do
visit_bulk_order_management

expect(page).to have_select2 "autogen4", selected: "15 per page" # should be default option
Copy link
Member

Choose a reason for hiding this comment

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

Where does "autogen4" come from? Could that change when we edit other parts on the page? Is there a better identifier like a label?

Update: I just checked and our matcher requires an id while our code doesn't provide one. So we have to do with this auto-generated id for now. Fortunately, we are replacing AngularJS and select2 and this doesn't need fixing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - yes, I believe that's the case.

we are replacing AngularJS and select2 and this doesn't need fixing

Ok, so I guess when we do, these tests will need to be updated?

this doesn't need fixing

Agree, let's leave as it is. Sometimes I feel page elements need more consistent and more explicit labeling/identifiers for this type of testing; is also influences Matomo tracking (element clicking, for ex.). I might ping you or @jibees on this matter, soon again.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so I guess when we do, these tests will need to be updated?

Yes, that's the downside of select2 because it needs special Rspec matchers. If it would work with the normal select matchers then we wouldn't need to change it. The new library, tom-select does work with the default matchers. So if we replace it at some point in the future, the specs hopefully don't need changing.

Sometimes I feel page elements need more consistent and more explicit labeling/identifiers for this type of testing; is also influences Matomo tracking (element clicking, for ex.).

I agree that we could have more labels. In this case, we could also use the text next to it as label which says about how many are display per page. Then you would be able to click on that to open the select input.

expect(page).to have_button("« First", disabled: true)
expect(page).to have_button("Previous", disabled: true)
expect(page).to have_button("1", disabled: true)
expect(page).to_not have_button("2", disabled: false)
Copy link
Member

Choose a reason for hiding this comment

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

Negative matchers should be the least specific possible. Otherwise you could have a page with this button disabled which would still be wrong. You want to assert that there is no "2" button, no matter if it's disabled or not.

Suggested change
expect(page).to_not have_button("2", disabled: false)
expect(page).to_not have_button("2")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, great catch for that detail 👍
Committed and squashed.

Adds coverage on bottom section of pagination

Extracts order line item creation to before block

Removes disabled option when asserting on button 2
@mkllnk mkllnk merged commit 255fc64 into openfoodfoundation:master Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants