openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

Add tests to the search product feature

Open cyrillefr opened this issue 11 months ago • 1 comments

What? Why?

  • Closes #12145

There a products search feature that can be used by customers and we don't know how it works. I have searched how the feature works and added matching tests.

The search is done in app/controller/api/vo/order_cycles_controller.rb in the products method. More precisely, it done by the ransack gem, with a search parameter that looks like this: "name_or_meta_keywords_or_variants_display_as_or_variants_display_name_or_supplier_name_cont"

That implies the search is done against the name or keywords from products; variant_display or variant_display_name from product variants; supplier name of the product. The "_cont" suffix means this not a exact matching search but rather the search term should be not only exactly present in DB but also only a part of it can be matched.

What should we test?

It is an addition of examples in automated specs to illustrate the possibilities of the actual search feature, so there should be no manual testing required here since the back-end code is untouched.

But for the record, the search feature can be found:

  • connect as a customer
  • chose a supplier and begin shopping
  • you should be able to search (and that what the tests show) for:
    • name of a product
    • name of a supplier
    • names of variants attached to a product
    • some keywords that have previously been entered in the back-office

NB The search feature in the back-office is not the same, is not implemented in the same place and therefore do not yield the same results.

Release notes

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

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

Dependencies

Documentation updates

cyrillefr avatar Mar 13 '24 10:03 cyrillefr

Hello @filipefurtad0 , found out a bit too late that I have messed up a bit with titles of my tests. I will change them with the requested changes if any.

cyrillefr avatar Mar 13 '24 10:03 cyrillefr