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

fix: use ingredient list if lang != lc to parse ingredients #8855

Merged
merged 4 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/api/ref/schemas/product_ingredients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ properties:
type: array
items:
type: string
ingredients_lc:
type: string
description: |
Language that was used to parse the ingredient list. If `ingredients_text` is available
for the product main language (`lang`), `ingredients_lc=lang`, otherwise we look at
`ingredients_text` fields for other languages and set `ingredients_lc` to the first
non-empty `ingredient_text`.
ingredients_text:
type: string
description: |
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/how-to-write-and-run-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If you made change that impact stored expected results, you can use:
* or to generate expected results for a single test
(here for integration test, `test-unit` otherwise)
```bash
make test-int="filename.t --update-expected results"
make test-int test="filename.t --update-expected-results"
```

If you re-generate test results, be sure to look carefully that the changes your commit are expected changes.
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/APITest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ sub execute_api_tests ($file, $tests_ref, $ua = undef) {

my $response_content = $response->decoded_content;

if ($test_ref->{expected_type} eq 'text') {
if ((defined $test_ref->{expected_type}) and ($test_ref->{expected_type} eq 'text')) {
# Check that the text file is the same as expected (useful for checking dynamic robots.txt)
is(
compare_file_to_expected_results(
Expand Down
5 changes: 3 additions & 2 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7838,7 +7838,7 @@ JS
# try to display ingredients in the local language if available

my $ingredients_text = $product_ref->{ingredients_text};
my $ingredients_text_lang = $product_ref->{lc};
my $ingredients_text_lang = $product_ref->{ingredients_lc};

if (defined $product_ref->{ingredients_text_with_allergens}) {
$ingredients_text = $product_ref->{ingredients_text_with_allergens};
Expand Down Expand Up @@ -11049,7 +11049,8 @@ sub data_to_display_ingredients_analysis_details ($product_ref) {

my $result_data_ref = {};

my $ingredients_text = "";
my $ingredients_text_lc = $product_ref->{ingredients_lc};
my $ingredients_text = "$ingredients_text_lc: ";
my $ingredients_list = "";

display_nested_list_of_ingredients($product_ref->{ingredients}, \$ingredients_text, \$ingredients_list);
Expand Down
Loading
Loading