From 5a3a5d04f63ccbc8082d723276ad106f9b59ae11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Tue, 15 Oct 2024 17:48:28 +0200 Subject: [PATCH 01/16] feat: ingredients knowledge panels --- lib/ProductOpener/KnowledgePanels.pm | 7 +- .../KnowledgePanelsIngredients.pm | 140 ++++++++++++++++++ po/common/common.pot | 9 ++ po/common/en.po | 9 ++ po/common/fr.po | 8 + .../health/ingredients_panels.tt.json | 3 + 6 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 lib/ProductOpener/KnowledgePanelsIngredients.pm diff --git a/lib/ProductOpener/KnowledgePanels.pm b/lib/ProductOpener/KnowledgePanels.pm index 2febf7f26cbdf..a5250ce609bcd 100644 --- a/lib/ProductOpener/KnowledgePanels.pm +++ b/lib/ProductOpener/KnowledgePanels.pm @@ -47,6 +47,7 @@ BEGIN { &initialize_knowledge_panels_options &create_knowledge_panels &create_panel_from_json_template + &add_taxonomy_properties_in_target_languages_to_object ); # symbols to export on request %EXPORT_TAGS = (all => [@EXPORT_OK]); @@ -66,6 +67,7 @@ use ProductOpener::Lang qw/f_lang f_lang_in_lc lang lang_in_other_lc/; use ProductOpener::Display qw/:all/; use ProductOpener::Ecoscore qw/is_ecoscore_extended_data_more_precise_than_agribalyse/; use ProductOpener::PackagerCodes qw/%packager_codes/; +use ProductOpener::KnowledgePanelsIngredients qw/create_ingredients_list_panel/; use ProductOpener::KnowledgePanelsContribution qw/create_contribution_card_panel/; use ProductOpener::KnowledgePanelsReportProblem qw/create_report_problem_card_panel/; use ProductOpener::ProductsFeatures qw/feature_enabled/; @@ -982,7 +984,10 @@ sub create_health_card_panel ($product_ref, $target_lc, $target_cc, $options_ref $log->debug("create health card panel", {code => $product_ref->{code}}) if $log->is_debug(); # All food, pet food and beauty products have ingredients - create_ingredients_panel($product_ref, $target_lc, $target_cc, $options_ref); + if (feature_enabled("ingredients")) { + create_ingredients_panel($product_ref, $target_lc, $target_cc, $options_ref); + create_ingredients_list_panel($product_ref, $target_lc, $target_cc, $options_ref); + } # Show additives only for food and pet food if (feature_enabled("additives")) { diff --git a/lib/ProductOpener/KnowledgePanelsIngredients.pm b/lib/ProductOpener/KnowledgePanelsIngredients.pm new file mode 100644 index 0000000000000..c24cd0c9e6d1f --- /dev/null +++ b/lib/ProductOpener/KnowledgePanelsIngredients.pm @@ -0,0 +1,140 @@ +# This file is part of Product Opener. +# +# Product Opener +# Copyright (C) 2011-2023 Association Open Food Facts +# Contact: contact@openfoodfacts.org +# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France +# +# Product Opener is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +=head1 NAME + +ProductOpener::KnowledgePanelsIngredients - Generate knowledge panels to report a problem with the data or the product + +=head1 SYNOPSIS + +Knowledge panels to indicate how to report a problem with the product data, +or with the product (e.g. link to report to authorities like SignalConso in France) + +=cut + +package ProductOpener::KnowledgePanelsIngredients; + +use ProductOpener::PerlStandards; +use Exporter qw< import >; + +use Log::Any qw($log); + +BEGIN { + use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); + @EXPORT_OK = qw( + &create_ingredients_list_panel + &create_data_quality_panel + ); # symbols to export on request + %EXPORT_TAGS = (all => [@EXPORT_OK]); +} + +use vars @EXPORT_OK; + +use ProductOpener::KnowledgePanels qw(create_panel_from_json_template add_taxonomy_properties_in_target_languages_to_object); +use ProductOpener::Tags qw(:all); + +use Encode; +use Data::DeepAccess qw(deep_get); + + +=head2 create_ingredients_list_panel ( $product_ref, $target_lc, $target_cc, $options_ref ) + +Creates a panel with a list of ingredients as individual panels. + +=head3 Arguments + +=head4 product reference $product_ref + +=head4 language code $target_lc + +=head4 country code $target_cc + +=cut + +sub create_ingredients_list_panel ($product_ref, $target_lc, $target_cc, $options_ref) { + + $log->debug("create ingredients list panel", {code => $product_ref->{code}}) if $log->is_debug(); + + # Create a panel only if the product has ingredients + + if ((defined $product_ref->{ingredients_tags}) and (scalar @{$product_ref->{ingredients_tags}} > 0)) { + + my $ingredient_i = 0; # sequence number for ingredients + my @ingredients_panels_ids = create_ingredients_panels_recursive($product_ref, \$ingredient_i, 0, $product_ref->{ingredients}, $target_lc, $target_cc, $options_ref); + my $ingredients_list_panel_data_ref = {ingredients_panels_ids => \@ingredients_panels_ids}; + + create_panel_from_json_template("ingredients_list", "api/knowledge-panels/health/ingredients/ingredients_list.tt.json", + $ingredients_list_panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref); + + } + return; +} + +sub create_ingredients_panels_recursive ($product_ref, $ingredient_i_ref, $level, $ingredients_ref, $target_lc, $target_cc, $options_ref) { + + my @ingredients_panels_ids = (); + + foreach my $ingredient_ref (@$ingredients_ref) { + + push @ingredients_panels_ids, create_ingredient_panel($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, $options_ref); + if (defined $ingredient_ref->{ingredients}) { + push @ingredients_panels_ids, create_ingredients_panels_recursive($product_ref, $ingredient_i_ref, $level + 1, $ingredient_ref->{ingredients}, $target_lc, $target_cc, $options_ref); + } + + } + + return @ingredients_panels_ids; +} + +sub create_ingredient_panel ($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, $options_ref) { + + $$ingredient_i_ref++; + my $ingredient_panel_id = "ingredient_" . $$ingredient_i_ref; + + my $ingredient_panel_data_ref = {ingredient_id => $ingredient_ref->{id}, level => $level, ingredient => $ingredient_ref}; + + # Wikipedia abstracts, in target language or English + + my $target_lcs_ref = [$target_lc]; + if ($target_lc ne "en") { + push @$target_lcs_ref, "en"; + } + + add_taxonomy_properties_in_target_languages_to_object($ingredient_panel_data_ref, "ingredients", $ingredient_ref->{id}, + ["wikipedia_url", "wikipedia_title", "wikipedia_abstract"], + $target_lcs_ref); + + # We check if the knowledge content for this ingredient (and language/country) is available. + # If it is it will be displayed instead of the wikipedia extract + my $ingredient_description = get_knowledge_content("ingredients", $ingredient_ref->{id}, $target_lc, $target_cc); + + if (defined $ingredient_description) { + $ingredient_panel_data_ref->{ingredient_description} = $ingredient_description; + } + + create_panel_from_json_template($ingredient_panel_id, + "api/knowledge-panels/health/ingredients/ingredient.tt.json", + $ingredient_panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref); + + return $ingredient_panel_id; +} + + +1; diff --git a/po/common/common.pot b/po/common/common.pot index 369a495a69423..7dc3c8664f161 100644 --- a/po/common/common.pot +++ b/po/common/common.pot @@ -7203,3 +7203,12 @@ msgstr "Poor repairability" msgctxt "attribute_repairability_index_france_bad_description_short" msgid "Bad repairability" msgstr "Bad repairability" + +msgctxt "estimate" +msgid "estimate" +msgstr "estimate" + +# information on several ingredients, in plural in languages like French +msgctxt "ingredient_information" +msgid "Ingredient information" +msgstr "Ingredient information" \ No newline at end of file diff --git a/po/common/en.po b/po/common/en.po index 170b7486e5ab2..2e03d32896458 100644 --- a/po/common/en.po +++ b/po/common/en.po @@ -7196,3 +7196,12 @@ msgstr "Bad repairability" msgctxt "concerned_categories" msgid "Bad repairability" msgstr "Bad repairability" + +msgctxt "estimate" +msgid "estimate" +msgstr "estimate" + +# information on several ingredients, in plural in languages like French +msgctxt "ingredient_information" +msgid "Ingredient information" +msgstr "Ingredient information" \ No newline at end of file diff --git a/po/common/fr.po b/po/common/fr.po index 3121f8de72bf8..66855e1c44658 100644 --- a/po/common/fr.po +++ b/po/common/fr.po @@ -7051,3 +7051,11 @@ msgctxt "attribute_repairability_index_france_bad_description_short" msgid "Bad repairability" msgstr "Très mauvaise réparabilité" +msgctxt "estimate" +msgid "estimate" +msgstr "estimation" + +# information on several ingredients, in plural in languages like French +msgctxt "ingredient_information" +msgid "Ingredient information" +msgstr "Information sur les ingrédients" \ No newline at end of file diff --git a/templates/api/knowledge-panels/health/ingredients_panels.tt.json b/templates/api/knowledge-panels/health/ingredients_panels.tt.json index 9b0aa4304e31a..2a01ae6cac8c1 100644 --- a/templates/api/knowledge-panels/health/ingredients_panels.tt.json +++ b/templates/api/knowledge-panels/health/ingredients_panels.tt.json @@ -10,6 +10,9 @@ [% IF panels.ingredients_rare_crops.defined %] "ingredients_rare_crops", [% END %] + [% IF panels.ingredients_list.defined %] + "ingredients_list", + [% END %] ], [% IF panel.ingredients_image.defined %] "image": [% encode_json(panel.ingredients_image) %], From dbb333029e98c34b0ea68855ee5da78ba955d6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Tue, 15 Oct 2024 18:17:39 +0200 Subject: [PATCH 02/16] ingredients templates --- .../health/ingredients/ingredient.tt.json | 46 +++++++++++++++++++ .../ingredients/ingredients_list.tt.json | 21 +++++++++ 2 files changed, 67 insertions(+) create mode 100644 templates/api/knowledge-panels/health/ingredients/ingredient.tt.json create mode 100644 templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json new file mode 100644 index 0000000000000..5066f3da27de7 --- /dev/null +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -0,0 +1,46 @@ +{ + "level": "info", + "topics": [ + "health" + ], + "size": "small", + [% IF panel.ingredient_description OR panel.wikipedia_abstract %] + "expanded": false, + [% ELSE %] + "expanded": false, + [% END %] + "title_element": { + "title": ` + [% dash = "-" %] + [% dash.repeat(panel.level) %] + + [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %] + [% IF panel.ingredient.percent.defined %] + ([% round(panel.ingredient.percent) %]%) + [% ELSIF panel.ingredient.percent_estimate.defined %] + ([% round(panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) + [% END %] + `, + }, + "elements": [ + [% IF panel.ingredient_description -%] + { + "element_type": "text", + "text_element": { + "html": `[% panel.ingredient_description %]` + } + } + [% ELSIF panel.wikipedia_abstract -%] + { + "element_type": "text", + "text_element": { + "html": `[% edq(panel.wikipedia_title) %][% sep %]: [% edq(panel.wikipedia_abstract) %]`, + "source_text": `Wikipedia`, + "source_url": `[% panel.wikipedia_url %]`, + "source_lc": "[% panel.wikipedia_url_lc %]", + "source_language": "[% panel.wikipedia_url_language %]" + } + } + [% END %] + ] +} diff --git a/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json new file mode 100644 index 0000000000000..702554d510bf7 --- /dev/null +++ b/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json @@ -0,0 +1,21 @@ +{ + "level": "info", + "topics": [ + "health" + ], + "type": "inline", + "expanded": true, + "title_element": { + "title":"[% lang("ingredient_information") %]", + }, + "elements": [ + [% FOREACH ingredient_panel_id IN panel.ingredients_panels_ids %] + { + "element_type": "panel", + "panel_element": { + "panel_id": "[% ingredient_panel_id %]", + } + }, + [% END %] + ] +} From c81a1524c594b1a26d0c634ea699a7bc57b1b4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Tue, 15 Oct 2024 18:58:01 +0200 Subject: [PATCH 03/16] fixes for mobile app --- .../KnowledgePanelsIngredients.pm | 52 ++++++++++++------- .../health/ingredients/ingredient.tt.json | 13 +---- .../health/ingredients/ingredients.tt.json | 11 +++- .../ingredients/ingredients_list.tt.json | 1 - .../health/ingredients_panels.tt.json | 3 -- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/lib/ProductOpener/KnowledgePanelsIngredients.pm b/lib/ProductOpener/KnowledgePanelsIngredients.pm index c24cd0c9e6d1f..79c1daa623efb 100644 --- a/lib/ProductOpener/KnowledgePanelsIngredients.pm +++ b/lib/ProductOpener/KnowledgePanelsIngredients.pm @@ -47,13 +47,13 @@ BEGIN { use vars @EXPORT_OK; -use ProductOpener::KnowledgePanels qw(create_panel_from_json_template add_taxonomy_properties_in_target_languages_to_object); +use ProductOpener::KnowledgePanels + qw(create_panel_from_json_template add_taxonomy_properties_in_target_languages_to_object); use ProductOpener::Tags qw(:all); use Encode; use Data::DeepAccess qw(deep_get); - =head2 create_ingredients_list_panel ( $product_ref, $target_lc, $target_cc, $options_ref ) Creates a panel with a list of ingredients as individual panels. @@ -76,39 +76,55 @@ sub create_ingredients_list_panel ($product_ref, $target_lc, $target_cc, $option if ((defined $product_ref->{ingredients_tags}) and (scalar @{$product_ref->{ingredients_tags}} > 0)) { - my $ingredient_i = 0; # sequence number for ingredients - my @ingredients_panels_ids = create_ingredients_panels_recursive($product_ref, \$ingredient_i, 0, $product_ref->{ingredients}, $target_lc, $target_cc, $options_ref); + my $ingredient_i = 0; # sequence number for ingredients + my @ingredients_panels_ids + = create_ingredients_panels_recursive($product_ref, \$ingredient_i, 0, $product_ref->{ingredients}, + $target_lc, $target_cc, $options_ref); my $ingredients_list_panel_data_ref = {ingredients_panels_ids => \@ingredients_panels_ids}; - create_panel_from_json_template("ingredients_list", "api/knowledge-panels/health/ingredients/ingredients_list.tt.json", - $ingredients_list_panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref); + create_panel_from_json_template( + "ingredients_list", + "api/knowledge-panels/health/ingredients/ingredients_list.tt.json", + $ingredients_list_panel_data_ref, + $product_ref, $target_lc, $target_cc, $options_ref + ); } return; } -sub create_ingredients_panels_recursive ($product_ref, $ingredient_i_ref, $level, $ingredients_ref, $target_lc, $target_cc, $options_ref) { +sub create_ingredients_panels_recursive ($product_ref, $ingredient_i_ref, $level, $ingredients_ref, $target_lc, + $target_cc, $options_ref) +{ my @ingredients_panels_ids = (); foreach my $ingredient_ref (@$ingredients_ref) { - push @ingredients_panels_ids, create_ingredient_panel($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, $options_ref); - if (defined $ingredient_ref->{ingredients}) { - push @ingredients_panels_ids, create_ingredients_panels_recursive($product_ref, $ingredient_i_ref, $level + 1, $ingredient_ref->{ingredients}, $target_lc, $target_cc, $options_ref); - } - + push @ingredients_panels_ids, + create_ingredient_panel($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, + $options_ref); + if (defined $ingredient_ref->{ingredients}) { + push @ingredients_panels_ids, + create_ingredients_panels_recursive($product_ref, $ingredient_i_ref, $level + 1, + $ingredient_ref->{ingredients}, + $target_lc, $target_cc, $options_ref); + } + } return @ingredients_panels_ids; } -sub create_ingredient_panel ($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, $options_ref) { +sub create_ingredient_panel ($product_ref, $ingredient_i_ref, $level, $ingredient_ref, $target_lc, $target_cc, + $options_ref) +{ $$ingredient_i_ref++; my $ingredient_panel_id = "ingredient_" . $$ingredient_i_ref; - my $ingredient_panel_data_ref = {ingredient_id => $ingredient_ref->{id}, level => $level, ingredient => $ingredient_ref}; + my $ingredient_panel_data_ref + = {ingredient_id => $ingredient_ref->{id}, level => $level, ingredient => $ingredient_ref}; # Wikipedia abstracts, in target language or English @@ -117,8 +133,8 @@ sub create_ingredient_panel ($product_ref, $ingredient_i_ref, $level, $ingredien push @$target_lcs_ref, "en"; } - add_taxonomy_properties_in_target_languages_to_object($ingredient_panel_data_ref, "ingredients", $ingredient_ref->{id}, - ["wikipedia_url", "wikipedia_title", "wikipedia_abstract"], + add_taxonomy_properties_in_target_languages_to_object($ingredient_panel_data_ref, "ingredients", + $ingredient_ref->{id}, ["wikipedia_url", "wikipedia_title", "wikipedia_abstract"], $target_lcs_ref); # We check if the knowledge content for this ingredient (and language/country) is available. @@ -129,12 +145,10 @@ sub create_ingredient_panel ($product_ref, $ingredient_i_ref, $level, $ingredien $ingredient_panel_data_ref->{ingredient_description} = $ingredient_description; } - create_panel_from_json_template($ingredient_panel_id, - "api/knowledge-panels/health/ingredients/ingredient.tt.json", + create_panel_from_json_template($ingredient_panel_id, "api/knowledge-panels/health/ingredients/ingredient.tt.json", $ingredient_panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref); return $ingredient_panel_id; } - 1; diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index 5066f3da27de7..ef7f1502e215b 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -10,17 +10,8 @@ "expanded": false, [% END %] "title_element": { - "title": ` - [% dash = "-" %] - [% dash.repeat(panel.level) %] - - [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %] - [% IF panel.ingredient.percent.defined %] - ([% round(panel.ingredient.percent) %]%) - [% ELSIF panel.ingredient.percent_estimate.defined %] - ([% round(panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) - [% END %] - `, + // Note: the app displays line feeds as line feeds... + "title": ` [% dash = "-" %] [% dash.repeat(panel.level) %] [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %] [% IF panel.ingredient.percent.defined %] ([% round(panel.ingredient.percent) %]%) [% ELSIF panel.ingredient.percent_estimate.defined %] ([% round(panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) [% END %] `, }, "elements": [ [% IF panel.ingredient_description -%] diff --git a/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json index 3bb2a2dc7cdf7..50cd77b9ca80b 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json @@ -55,6 +55,15 @@ `, }, }, - [% END %] + [% END %] + [% IF 1 %] + { + "element_type": "panel", + "panel_element": { + "panel_id": + "ingredients_list", + }, + }, + [% END %] ] } diff --git a/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json index 702554d510bf7..dae4f9ddd4118 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredients_list.tt.json @@ -3,7 +3,6 @@ "topics": [ "health" ], - "type": "inline", "expanded": true, "title_element": { "title":"[% lang("ingredient_information") %]", diff --git a/templates/api/knowledge-panels/health/ingredients_panels.tt.json b/templates/api/knowledge-panels/health/ingredients_panels.tt.json index 2a01ae6cac8c1..9b0aa4304e31a 100644 --- a/templates/api/knowledge-panels/health/ingredients_panels.tt.json +++ b/templates/api/knowledge-panels/health/ingredients_panels.tt.json @@ -10,9 +10,6 @@ [% IF panels.ingredients_rare_crops.defined %] "ingredients_rare_crops", [% END %] - [% IF panels.ingredients_list.defined %] - "ingredients_list", - [% END %] ], [% IF panel.ingredients_image.defined %] "image": [% encode_json(panel.ingredients_image) %], From 2eccff5e9288a3b873a32e002fc041867771bb48 Mon Sep 17 00:00:00 2001 From: Open Food Facts Bot Date: Wed, 16 Oct 2024 08:26:16 +0000 Subject: [PATCH 04/16] test: Update tests results --- .../get-fields-all-knowledge-panels.json | 90 +++ ...attribute-groups-all-knowledge-panels.json | 90 +++ ...edge-panels_excluded-environment_card.json | 90 +++ ...included-health_card-environment_card.json | 90 +++ .../get-knowledge-panels-fr.json | 90 +++ .../get-knowledge-panels.json | 90 +++ .../get-fields-all-knowledge-panels.json | 90 +++ ...attribute-groups-all-knowledge-panels.json | 90 +++ ...edge-panels_excluded-environment_card.json | 90 +++ ...included-health_card-environment_card.json | 90 +++ .../get-knowledge-panels-fr.json | 90 +++ .../get-knowledge-panels.json | 90 +++ ...ted-attribute-groups-knowledge-panels.json | 6 + .../data-quality.json | 54 ++ .../no-data-quality.json | 54 ++ .../crawler-access-product-page.html | 121 ++++ .../normal-user-access-product-page.html | 121 ++++ .../product_read/get-existing-product.html | 203 +++++++ .../web_html/fr-product-2.html | 531 ++++++++++++++++++ .../web_html/fr-product.html | 490 ++++++++++++++++ .../web_html/world-product.html | 490 ++++++++++++++++ .../ingredients/fr-marmelade.json | 4 +- 22 files changed, 3152 insertions(+), 2 deletions(-) diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json index 9134226de65f1..14c043f40c672 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json @@ -1359,6 +1359,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -1377,6 +1425,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -1529,6 +1583,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json index 03a19d9617b5b..131317e693ce9 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -2015,6 +2015,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -2033,6 +2081,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -2185,6 +2239,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json index 63c2ffeb8ad03..904153e24a424 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json @@ -96,6 +96,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -114,6 +162,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -266,6 +320,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index 35752e10e9821..5b960eb300c38 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -629,6 +629,54 @@ ], "type" : "card" }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -647,6 +695,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -799,6 +853,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json index 91a48114dc672..aef0d8ffa86e5 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Pomme (62% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Lait (19% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Œuf (9% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Huile de palme (9% estimation) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergènes : \n en:Apple, Œufs, Lait\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Information sur les ingrédients" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json index 631730c89fe5c..8d2bfabc6817d 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json index 80763d7fd81c5..5e068f72831d0 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json @@ -1352,6 +1352,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -1370,6 +1418,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -1522,6 +1576,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json index 70c2a0fe05045..55df8089f7465 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -2000,6 +2000,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -2018,6 +2066,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -2170,6 +2224,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json index f5acfb17c36f9..441512852e45d 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json @@ -96,6 +96,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -114,6 +162,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -266,6 +320,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index fb09d2de473cb..6f7af82159d2c 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -629,6 +629,54 @@ ], "type" : "card" }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -647,6 +695,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -799,6 +853,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json index bc91ed1cbd7cc..2a37ff4b61bff 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Pomme (62% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Lait (19% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Œuf (9% estimation) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Huile de palme (9% estimation) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergènes : \n en:Apple, Œufs, Lait\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Information sur les ingrédients" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json index eacd14f068bc4..61e735ac26280 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Apple (62% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Milk (19% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Egg (9% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Palm oil (9% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json index d2c61ef7076f0..b377198328d17 100644 --- a/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json @@ -484,6 +484,12 @@ "html" : "Could you add the ingredients list?" }, "element_type" : "action" + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", diff --git a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json index 22414cbb8217f..0a73cae241a26 100644 --- a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json +++ b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json @@ -328,6 +328,30 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Water (75% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Test-ingredient (25% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -340,6 +364,12 @@ "language" : "English", "lc" : "en" } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -540,6 +570,30 @@ ], "type" : "inline" }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json b/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json index e532ef647655d..76393f794005f 100644 --- a/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json +++ b/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json @@ -290,6 +290,30 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Water (75% estimate) " + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : " Test-ingredient (25% estimate) " + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -302,6 +326,12 @@ "language" : "English", "lc" : "en" } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -502,6 +532,30 @@ ], "type" : "inline" }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html b/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html index dbd9864e0edf2..5a4b7f6f75ef1 100644 --- a/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html +++ b/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html @@ -1315,6 +1315,127 @@

Ingredient + + + + + + + diff --git a/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html b/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html index dbd9864e0edf2..5a4b7f6f75ef1 100644 --- a/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html +++ b/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html @@ -1315,6 +1315,127 @@

Ingredient + + + + + + + diff --git a/tests/integration/expected_test_results/product_read/get-existing-product.html b/tests/integration/expected_test_results/product_read/get-existing-product.html index 899b09ac5f4a2..6e6258c2cc1cd 100644 --- a/tests/integration/expected_test_results/product_read/get-existing-product.html +++ b/tests/integration/expected_test_results/product_read/get-existing-product.html @@ -1995,6 +1995,209 @@

Ingredient + + + + + + + diff --git a/tests/integration/expected_test_results/web_html/fr-product-2.html b/tests/integration/expected_test_results/web_html/fr-product-2.html index 9c09a61618105..f9ebd69d773a8 100644 --- a/tests/integration/expected_test_results/web_html/fr-product-2.html +++ b/tests/integration/expected_test_results/web_html/fr-product-2.html @@ -1368,6 +1368,537 @@

Ingrédien + + + + + + + diff --git a/tests/integration/expected_test_results/web_html/fr-product.html b/tests/integration/expected_test_results/web_html/fr-product.html index 525b4e2a92696..2019e6673cbde 100644 --- a/tests/integration/expected_test_results/web_html/fr-product.html +++ b/tests/integration/expected_test_results/web_html/fr-product.html @@ -1383,6 +1383,496 @@

Ingrédien + + + + + + + diff --git a/tests/integration/expected_test_results/web_html/world-product.html b/tests/integration/expected_test_results/web_html/world-product.html index ce5a4d2c774fa..e338022494285 100644 --- a/tests/integration/expected_test_results/web_html/world-product.html +++ b/tests/integration/expected_test_results/web_html/world-product.html @@ -1941,6 +1941,496 @@

Ingredient + + + + + + + diff --git a/tests/unit/expected_test_results/ingredients/fr-marmelade.json b/tests/unit/expected_test_results/ingredients/fr-marmelade.json index 11e3f28a5bb10..ac84363c58fa3 100644 --- a/tests/unit/expected_test_results/ingredients/fr-marmelade.json +++ b/tests/unit/expected_test_results/ingredients/fr-marmelade.json @@ -138,8 +138,8 @@ "percent" : 41, "percent_estimate" : 41, "text" : "Marmelade d'oranges", - "vegan": "maybe", - "vegetarian": "maybe" + "vegan" : "maybe", + "vegetarian" : "maybe" }, { "id" : "en:chocolate", From bfc451359106055e4e7ed786a401a49e6b506f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 10:33:08 +0200 Subject: [PATCH 05/16] double backticks --- lib/ProductOpener/KnowledgePanels.pm | 30 +++++++++++++++++++ .../health/ingredients/ingredient.tt.json | 18 ++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/ProductOpener/KnowledgePanels.pm b/lib/ProductOpener/KnowledgePanels.pm index a5250ce609bcd..c52dbe4de93b9 100644 --- a/lib/ProductOpener/KnowledgePanels.pm +++ b/lib/ProductOpener/KnowledgePanels.pm @@ -273,6 +273,8 @@ sub create_knowledge_panels ($product_ref, $target_lc, $target_cc, $options_ref, Helper function to allow to enter multiline strings in JSON templates. The function converts the multiline string into a single line string. +New lines are converted to \n, and quotes " and \ are escaped if not escaped already. + =cut sub convert_multiline_string_to_singleline ($line) { @@ -287,6 +289,30 @@ sub convert_multiline_string_to_singleline ($line) { return '"' . $line . '"'; } +=head2 convert_multiline_string_to_singleline_without_line_breaks_and_extra_spaces($line) + +Helper function to allow to enter multiline strings in JSON templates. +The function converts the multiline string into a single line string. + +Line breaks are converted to spaces, and multiple spaces are converted to a single space. + +This function is useful in templates where we use IF statements etc. to generate a single value like a title. + +=cut + +sub convert_multiline_string_to_singleline_without_line_breaks_and_extra_spaces ($line) { + + # Escape " and \ unless they have been escaped already + # negative look behind to not convert \n to \\n or \" to \\" or \\ to \\\\ + $line =~ s/(? Date: Wed, 16 Oct 2024 10:33:14 +0200 Subject: [PATCH 06/16] update tests --- .../get-fields-all-knowledge-panels.json | 90 +++ ...attribute-groups-all-knowledge-panels.json | 90 +++ ...edge-panels_excluded-environment_card.json | 90 +++ ...included-health_card-environment_card.json | 90 +++ .../get-knowledge-panels-fr.json | 90 +++ .../get-knowledge-panels.json | 90 +++ .../get-fields-all-knowledge-panels.json | 90 +++ ...attribute-groups-all-knowledge-panels.json | 90 +++ ...edge-panels_excluded-environment_card.json | 90 +++ ...included-health_card-environment_card.json | 90 +++ .../get-knowledge-panels-fr.json | 90 +++ .../get-knowledge-panels.json | 90 +++ ...ted-attribute-groups-knowledge-panels.json | 6 + .../create_pro_user/mails.json | 25 +- .../data-quality.json | 54 ++ .../no-data-quality.json | 54 ++ .../crawler-access-product-page.html | 121 ++++ .../normal-user-access-product-page.html | 121 ++++ .../normal-user-get-non-official-cc-lc.html | 26 +- .../product_read/get-existing-product.html | 203 +++++++ .../web_html/fr-index.html | 26 +- .../web_html/fr-product-2.html | 545 +++++++++++++++++- .../web_html/fr-product.html | 504 +++++++++++++++- .../web_html/world-index-signedin.html | 7 +- .../web_html/world-index.html | 7 +- .../web_html/world-product.html | 535 ++++++++++++++++- .../ingredients/fr-marmelade.json | 4 +- 27 files changed, 3244 insertions(+), 74 deletions(-) diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json index 9134226de65f1..cd37ef19587b0 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json @@ -1359,6 +1359,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -1377,6 +1425,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -1529,6 +1583,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json index 03a19d9617b5b..e6664ee594e2a 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -2015,6 +2015,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -2033,6 +2081,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -2185,6 +2239,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json index 63c2ffeb8ad03..619d9391615e4 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json @@ -96,6 +96,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -114,6 +162,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -266,6 +320,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index 35752e10e9821..5bdbf05ee3b85 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -629,6 +629,54 @@ ], "type" : "card" }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -647,6 +695,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -799,6 +853,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json index 91a48114dc672..c87df1bf7cc2a 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Pomme (62% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Lait (19% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Œuf (9% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Huile de palme (9% estimation)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergènes : \n en:Apple, Œufs, Lait\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Information sur les ingrédients" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json index 631730c89fe5c..3512cac9b8be1 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json index 80763d7fd81c5..d13e7436a2444 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json @@ -1352,6 +1352,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -1370,6 +1418,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -1522,6 +1576,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json index 70c2a0fe05045..be5628418aea7 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -2000,6 +2000,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -2018,6 +2066,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -2170,6 +2224,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json index f5acfb17c36f9..c19bc571f5105 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json @@ -96,6 +96,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -114,6 +162,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -266,6 +320,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index fb09d2de473cb..f72174ec5cfc1 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -629,6 +629,54 @@ ], "type" : "card" }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -647,6 +695,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -799,6 +853,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json index bc91ed1cbd7cc..47b7f6880ccad 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Pomme (62% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Lait (19% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Œuf (9% estimation)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Huile de palme (9% estimation)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergènes : \n en:Apple, Œufs, Lait\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Information sur les ingrédients" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json index eacd14f068bc4..3fbfe1f12288a 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json @@ -659,6 +659,54 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Apple (62% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Milk (19% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_3" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Egg (9% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_4" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Palm oil (9% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -677,6 +725,12 @@ "text_element" : { "html" : "Allergens: \n Apple, Eggs, Milk\n " } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -829,6 +883,42 @@ "health" ] }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_3" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_4" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json index d2c61ef7076f0..b377198328d17 100644 --- a/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_write/patch-request-fields-updated-attribute-groups-knowledge-panels.json @@ -484,6 +484,12 @@ "html" : "Could you add the ingredients list?" }, "element_type" : "action" + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", diff --git a/tests/integration/expected_test_results/create_pro_user/mails.json b/tests/integration/expected_test_results/create_pro_user/mails.json index 750337c82f108..2965e0a60ffd9 100644 --- a/tests/integration/expected_test_results/create_pro_user/mails.json +++ b/tests/integration/expected_test_results/create_pro_user/mails.json @@ -152,7 +152,30 @@ "To: Test ", "Subject: Thanks for joining Open Food Facts", "", - "

Welcome Test, your user ID: tests

" + "

Hi Test and welcome to Open Food Facts! =F0=9F=94=8E=F0=9F=8D=8A

Thank you for joining our international community of people eager to see more transparency in the food industry by contributing to the world=E2=80=99s largest open food database!

Here is your user name: tests

Sign in on the website to add and edit products.

=F0=9F=93=B2 We also have a free, ad-free and private mobile scanning app you may like.

Open Food Facts is a collaborative project to which you can bring much more than new products: your energy, enthusiasm and ideas!

=F0=9F=8C=8E To discuss projects and connect as a community, join us on our Slack or our Forum.

=F0=9F=99=8B=F0=9F=99=8B=E2=80=8D=E2=99=80=EF=B8=8FTo become a volunteer for the project, sign up to the Contributor Skill Pool (4 min form)!

=F0=9F=92=AB To follow our latest news:

Please also get familiar with our community=E2=80=99s Code of Conduct.

Thank you for joining the food revolution and we look forward to your contribution! =F0=9F=A4=B3=F0=9F=A5=AB

#YesWeScan

Stay tuned,

The Open Food Facts team

https://openfoodfacts.org

Still have a minute to read? =F0=9F=98=89

Some further resources

Are you:

  • a producer? Discover our dedicated Pro platform to help you in your transparency journey
  • into cosmetics ? Discover the growing Open Beauty Facts database
  • a developer? Join us on Github to help improve the interfaces
  • a translator? Help make Open Food Facts available in your language via Crowdin

=F0=9F=8C=B1 How can informed food choices make a difference?

What we eat matters when food accounts for 28% of C02 emissions, 70% of drinking water consumption and the majority of packaging waste globally. Each meal is an opportunity to have a positive impact on our health and that of our planet.

=F0=9F=A7=A1 Open Food Facts is a non-profit organization and exists in part thanks to donations. If you like the project, please consider supporting it with a donation.

" ], [ "Date: ***", diff --git a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json index 22414cbb8217f..0639304b7daf1 100644 --- a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json +++ b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json @@ -328,6 +328,30 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Water (75% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Test-ingredient (25% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -340,6 +364,12 @@ "language" : "English", "lc" : "en" } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -540,6 +570,30 @@ ], "type" : "inline" }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json b/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json index e532ef647655d..7a8b8a2090dd5 100644 --- a/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json +++ b/tests/integration/expected_test_results/data_quality_knowledge_panel/no-data-quality.json @@ -290,6 +290,30 @@ "problem" ] }, + "ingredient_1" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Water (75% estimate)" + }, + "topics" : [ + "health" + ] + }, + "ingredient_2" : { + "elements" : [], + "expanded" : false, + "level" : "info", + "size" : "small", + "title_element" : { + "title" : "Test-ingredient (25% estimate)" + }, + "topics" : [ + "health" + ] + }, "ingredients" : { "elements" : [ { @@ -302,6 +326,12 @@ "language" : "English", "lc" : "en" } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_list" + } } ], "evaluation" : "unknown", @@ -502,6 +532,30 @@ ], "type" : "inline" }, + "ingredients_list" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_1" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredient_2" + } + } + ], + "expanded" : true, + "level" : "info", + "title_element" : { + "title" : "Ingredient information" + }, + "topics" : [ + "health" + ] + }, "nova" : { "elements" : [ { diff --git a/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html b/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html index dbd9864e0edf2..d3409202c9646 100644 --- a/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html +++ b/tests/integration/expected_test_results/page_crawler/crawler-access-product-page.html @@ -1315,6 +1315,127 @@

Ingredient + + + + + + + diff --git a/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html b/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html index dbd9864e0edf2..d3409202c9646 100644 --- a/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html +++ b/tests/integration/expected_test_results/page_crawler/normal-user-access-product-page.html @@ -1315,6 +1315,127 @@

Ingredient + + + + + + + diff --git a/tests/integration/expected_test_results/page_crawler/normal-user-get-non-official-cc-lc.html b/tests/integration/expected_test_results/page_crawler/normal-user-get-non-official-cc-lc.html index 86fe6b98bd7e9..8bc5498bb265c 100644 --- a/tests/integration/expected_test_results/page_crawler/normal-user-get-non-official-cc-lc.html +++ b/tests/integration/expected_test_results/page_crawler/normal-user-get-non-official-cc-lc.html @@ -4,7 +4,7 @@ - Open Food Facts - Suiza + @@ -346,38 +346,36 @@
-

Open Food Facts - Suiza

+

- -
+
-

Discover

-

Open Food Facts is a food products database made by everyone, for everyone. You can use it to make better food choices, and as it is open data, anyone can re-use it for any purpose.

+

Descubrir

+

Open Food Facts es una base de datos de productos alimenticios elaborada por todos, para todos. Puedes utilizarla para escoger mejor los alimentos que consumes y, como es de dominio público, cualquier persona puede utilizar los datos para cualquier propósito.

- auto_storiesLearn more about Open Food Facts + auto_storiesDescubre más sobre Open Food Facts
- Discover Open Food Facts. + Descubre Open Food Facts.
-

Contribute

+

Contribuir

- Open Food Facts is a non-profit project developed by thousands of volunteers from around the world. - You can start contributing by adding a product from your kitchen with our app for iPhone or Android, and we have lots of - exciting projects you can contribute to in many different ways. + Open Food Facts es un proyecto sin fines de lucro desarrollado por miles de voluntarios de todo el mundo. + Puedes contribuir añadiendo un producto de tu cocina desde la aplicación para Android o iPhone. Además, tenemos muchos proyectos emocionantes en los que puedes colaborar de muchas maneras diferentes.

- add_taskLearn more about how you can join us + add_taskDescubre cómo puedes unirte a nosotros
- Contribute to Open Food Facts. + Colabora con Open Food Facts.
diff --git a/tests/integration/expected_test_results/product_read/get-existing-product.html b/tests/integration/expected_test_results/product_read/get-existing-product.html index 899b09ac5f4a2..af0aa67027456 100644 --- a/tests/integration/expected_test_results/product_read/get-existing-product.html +++ b/tests/integration/expected_test_results/product_read/get-existing-product.html @@ -1995,6 +1995,209 @@

Ingredient

+ + + + + + +
diff --git a/tests/integration/expected_test_results/web_html/fr-index.html b/tests/integration/expected_test_results/web_html/fr-index.html index cfadb70efb8b4..90fc747fff462 100644 --- a/tests/integration/expected_test_results/web_html/fr-index.html +++ b/tests/integration/expected_test_results/web_html/fr-index.html @@ -4,7 +4,7 @@ - Open Food Facts - France + @@ -347,38 +347,36 @@
-

Open Food Facts - France

+

- -
+
-

Discover

-

Open Food Facts is a food products database made by everyone, for everyone. You can use it to make better food choices, and as it is open data, anyone can re-use it for any purpose.

+

Découvrir

+

Open Food Facts est une base de données de produits alimentaires créée par tous et pour tous. Vous pouvez l'utiliser pour faire de meilleurs choix alimentaires, et comme les données sont ouvertes, tout le monde peut les réutiliser pour tout usage.

- auto_storiesLearn more about Open Food Facts + En savoir plus sur Open Food Facts
- Discover Open Food Facts. + Open Food Facts
-

Contribute

+

Contribuer

- Open Food Facts is a non-profit project developed by thousands of volunteers from around the world. - You can start contributing by adding a product from your kitchen with our app for iPhone or Android, and we have lots of - exciting projects you can contribute to in many different ways. + Open Food Facts est un projet à but non-lucratif qui a été mis sur pied par des milliers de bénévoles à travers le monde. + Vous pouvez commencer à contribuer en ajoutant un produit de votre cuisine avec notre application pour iPhone ou Android, et nous avons beaucoup de projets excitants auxquels vous pouvez contribuez, de beaucoup de façons différentes.

- add_taskLearn more about how you can join us + add_taskApprenez comment nous rejoindre
- Contribute to Open Food Facts. + Open Food Facts est une base de données de produits alimentaires créée par tous et pour tous.
diff --git a/tests/integration/expected_test_results/web_html/fr-product-2.html b/tests/integration/expected_test_results/web_html/fr-product-2.html index 9c09a61618105..d706ee7a7f7c6 100644 --- a/tests/integration/expected_test_results/web_html/fr-product-2.html +++ b/tests/integration/expected_test_results/web_html/fr-product-2.html @@ -1368,6 +1368,537 @@

Ingrédien

+ + + + + + +
@@ -1575,17 +2106,17 @@

Additifs

- Acide citrique : L'acide citrique est un acide tricarboxylique α-hydroxylé présent en abondance dans le citron, d'où son nom. Il s'agit d'un acide faible qui joue un rôle important en biochimie comme métabolite du cycle de Krebs, une voie métabolique majeure chez tous les organismes aérobies. Plus d'un million de tonnes d'acide citrique sont produites industriellement chaque année. Il est largement utilisé comme exhausteur de goût, comme régulateur alimentaire de pH et comme chélateur. +

L'acide citrique est un acide organique naturel présent dans les +agrumes tels que les citrons et les oranges.

+

Il est largement utilisé dans l'industrie alimentaire en tant +qu'exhausteur de goût, acidifiant et conservateur en raison de son +goût acidulé et rafraîchissant.

+

L'acide citrique est considéré comme un additif alimentaire sûr par +les organismes de réglementation du monde entier.

- Source : - Wikipedia - - - - diff --git a/tests/integration/expected_test_results/web_html/fr-product.html b/tests/integration/expected_test_results/web_html/fr-product.html index 525b4e2a92696..05afe0ca0fe5d 100644 --- a/tests/integration/expected_test_results/web_html/fr-product.html +++ b/tests/integration/expected_test_results/web_html/fr-product.html @@ -1383,6 +1383,496 @@

Ingrédien + + + + + + + @@ -1590,17 +2080,17 @@

Additifs

- Acide citrique : L'acide citrique est un acide tricarboxylique α-hydroxylé présent en abondance dans le citron, d'où son nom. Il s'agit d'un acide faible qui joue un rôle important en biochimie comme métabolite du cycle de Krebs, une voie métabolique majeure chez tous les organismes aérobies. Plus d'un million de tonnes d'acide citrique sont produites industriellement chaque année. Il est largement utilisé comme exhausteur de goût, comme régulateur alimentaire de pH et comme chélateur. +

L'acide citrique est un acide organique naturel présent dans les +agrumes tels que les citrons et les oranges.

+

Il est largement utilisé dans l'industrie alimentaire en tant +qu'exhausteur de goût, acidifiant et conservateur en raison de son +goût acidulé et rafraîchissant.

+

L'acide citrique est considéré comme un additif alimentaire sûr par +les organismes de réglementation du monde entier.

- Source : - Wikipedia - - - - diff --git a/tests/integration/expected_test_results/web_html/world-index-signedin.html b/tests/integration/expected_test_results/web_html/world-index-signedin.html index 48640c2f84ae6..dd9c49151500d 100644 --- a/tests/integration/expected_test_results/web_html/world-index-signedin.html +++ b/tests/integration/expected_test_results/web_html/world-index-signedin.html @@ -4,7 +4,7 @@ - Open Food Facts - World + @@ -370,11 +370,10 @@
-

Open Food Facts - World

+

- -
+
diff --git a/tests/integration/expected_test_results/web_html/world-index.html b/tests/integration/expected_test_results/web_html/world-index.html index 17bb935f1dca0..dc4d312309180 100644 --- a/tests/integration/expected_test_results/web_html/world-index.html +++ b/tests/integration/expected_test_results/web_html/world-index.html @@ -4,7 +4,7 @@ - Open Food Facts - World + @@ -347,11 +347,10 @@
-

Open Food Facts - World

+

- -
+
diff --git a/tests/integration/expected_test_results/web_html/world-product.html b/tests/integration/expected_test_results/web_html/world-product.html index ce5a4d2c774fa..926efd7903a8c 100644 --- a/tests/integration/expected_test_results/web_html/world-product.html +++ b/tests/integration/expected_test_results/web_html/world-product.html @@ -1941,6 +1941,496 @@

Ingredient

+ + + + + + +
@@ -2148,17 +2638,17 @@

Additives

- Citric acid: Citric acid is a weak organic acid that has the chemical formula C6H8O7. It occurs naturally in citrus fruits. In biochemistry, it is an intermediate in the citric acid cycle, which occurs in the metabolism of all aerobic organisms. More than a million tons of citric acid are manufactured every year. It is used widely as an acidifier, as a flavoring and chelating agent.A citrate is a derivative of citric acid; that is, the salts, esters, and the polyatomic anion found in solution. An example of the former, a salt is trisodium citrate; an ester is triethyl citrate. When part of a salt, the formula of the citrate ion is written as C6H5O3−7 or C3H5O-COO-3−3. +

Citric acid is a natural organic acid found in citrus fruits such as +lemons, oranges, and limes.

+

It is widely used in the food industry as a flavor enhancer, acidulant, +and preservative due to its tart and refreshing taste.

+

Citric acid is safe for consumption when used in moderation and is +considered a generally recognized as safe (GRAS) food additive by +regulatory agencies worldwide.

- Source: - Wikipedia - - - -
@@ -2212,17 +2702,19 @@

Additives

- Sodium carbonate: Sodium carbonate, Na2CO3, -also known as washing soda, soda ash and soda crystals, and in the monohydrate form as crystal carbonate- is the water-soluble sodium salt of carbonic acid. It most commonly occurs as a crystalline decahydrate, which readily effloresces to form a white powder, the monohydrate. Pure sodium carbonate is a white, odorless powder that is hygroscopic -absorbs moisture from the air-. It has a strongly alkaline taste, and forms a moderately basic solution in water. Sodium carbonate is well known domestically for its everyday use as a water softener. Historically it was extracted from the ashes of plants growing in sodium-rich soils, such as vegetation from the Middle East, kelp from Scotland and seaweed from Spain. Because the ashes of these sodium-rich plants were noticeably different from ashes of timber -used to create potash-, they became known as "soda ash". It is synthetically produced in large quantities from salt -sodium chloride- and limestone by a method known as the Solvay process. The manufacture of glass is one of the most important uses of sodium carbonate. Sodium carbonate acts as a flux for silica, lowering the melting point of the mixture to something achievable without special materials. This "soda glass" is mildly water-soluble, so some calcium carbonate is added to the melt mixture to make the glass produced insoluble. This type of glass is known as soda lime glass: "soda" for the sodium carbonate and "lime" for the calcium carbonate. Soda lime glass has been the most common form of glass for centuries. Sodium carbonate is also used as a relatively strong base in various settings. For example, it is used as a pH regulator to maintain stable alkaline conditions necessary for the action of the majority of photographic film developing agents. It acts as an alkali because when dissolved in water, it dissociates into the weak acid: carbonic acid and the strong alkali: sodium hydroxide. This gives sodium carbonate in solution the ability to attack metals such as aluminium with the release of hydrogen gas.It is a common additive in swimming pools used to raise the pH which can be lowered by chlorine tablets and other additives which contain acids. In cooking, it is sometimes used in place of sodium hydroxide for lyeing, especially with German pretzels and lye rolls. These dishes are treated with a solution of an alkaline substance to change the pH of the surface of the food and improve browning. In taxidermy, sodium carbonate added to boiling water will remove flesh from the bones of animal carcasses for trophy mounting or educational display. In chemistry, it is often used as an electrolyte. Electrolytes are usually salt-based, and sodium carbonate acts as a very good conductor in the process of electrolysis. In addition, unlike chloride ions, which form chlorine gas, carbonate ions are not corrosive to the anodes. It is also used as a primary standard for acid-base titrations because it is solid and air-stable, making it easy to weigh accurately. +

Sodium carbonates (E500) are compounds commonly used in food preparation +as leavening agents, helping baked goods rise by releasing carbon dioxide +when they interact with acids.

+

Often found in baking soda, they regulate the pH of food, preventing it +from becoming too acidic or too alkaline. In the culinary world, sodium +carbonates can also enhance the texture and structure of foods, such as +noodles, by modifying the gluten network.

+

Generally recognized as safe, sodium carbonates are non-toxic when +consumed in typical amounts found in food.

- Source: - Wikipedia - - - -
@@ -2276,17 +2768,18 @@

Additives

- Sodium carbonate: Sodium carbonate, Na2CO3, -also known as washing soda, soda ash and soda crystals, and in the monohydrate form as crystal carbonate- is the water-soluble sodium salt of carbonic acid. It most commonly occurs as a crystalline decahydrate, which readily effloresces to form a white powder, the monohydrate. Pure sodium carbonate is a white, odorless powder that is hygroscopic -absorbs moisture from the air-. It has a strongly alkaline taste, and forms a moderately basic solution in water. Sodium carbonate is well known domestically for its everyday use as a water softener. Historically it was extracted from the ashes of plants growing in sodium-rich soils, such as vegetation from the Middle East, kelp from Scotland and seaweed from Spain. Because the ashes of these sodium-rich plants were noticeably different from ashes of timber -used to create potash-, they became known as "soda ash". It is synthetically produced in large quantities from salt -sodium chloride- and limestone by a method known as the Solvay process. The manufacture of glass is one of the most important uses of sodium carbonate. Sodium carbonate acts as a flux for silica, lowering the melting point of the mixture to something achievable without special materials. This "soda glass" is mildly water-soluble, so some calcium carbonate is added to the melt mixture to make the glass produced insoluble. This type of glass is known as soda lime glass: "soda" for the sodium carbonate and "lime" for the calcium carbonate. Soda lime glass has been the most common form of glass for centuries. Sodium carbonate is also used as a relatively strong base in various settings. For example, it is used as a pH regulator to maintain stable alkaline conditions necessary for the action of the majority of photographic film developing agents. It acts as an alkali because when dissolved in water, it dissociates into the weak acid: carbonic acid and the strong alkali: sodium hydroxide. This gives sodium carbonate in solution the ability to attack metals such as aluminium with the release of hydrogen gas.It is a common additive in swimming pools used to raise the pH which can be lowered by chlorine tablets and other additives which contain acids. In cooking, it is sometimes used in place of sodium hydroxide for lyeing, especially with German pretzels and lye rolls. These dishes are treated with a solution of an alkaline substance to change the pH of the surface of the food and improve browning. In taxidermy, sodium carbonate added to boiling water will remove flesh from the bones of animal carcasses for trophy mounting or educational display. In chemistry, it is often used as an electrolyte. Electrolytes are usually salt-based, and sodium carbonate acts as a very good conductor in the process of electrolysis. In addition, unlike chloride ions, which form chlorine gas, carbonate ions are not corrosive to the anodes. It is also used as a primary standard for acid-base titrations because it is solid and air-stable, making it easy to weigh accurately. +

Sodium hydrogen carbonate, also known as E500ii, is a food additive +commonly used as a leavening agent.

+

When added to recipes, it releases carbon dioxide gas upon exposure to +heat or acids, causing dough to rise and resulting in a light, fluffy +texture in baked goods.

+

It is generally recognized as safe (GRAS) by regulatory authorities when +used in appropriate quantities and poses no significant health risks when +consumed in typical food applications.

- Source: - Wikipedia - - - -
diff --git a/tests/unit/expected_test_results/ingredients/fr-marmelade.json b/tests/unit/expected_test_results/ingredients/fr-marmelade.json index 11e3f28a5bb10..ac84363c58fa3 100644 --- a/tests/unit/expected_test_results/ingredients/fr-marmelade.json +++ b/tests/unit/expected_test_results/ingredients/fr-marmelade.json @@ -138,8 +138,8 @@ "percent" : 41, "percent_estimate" : 41, "text" : "Marmelade d'oranges", - "vegan": "maybe", - "vegetarian": "maybe" + "vegan" : "maybe", + "vegetarian" : "maybe" }, { "id" : "en:chocolate", From fc470177f1f4146657354eb84452c92ed8a3226b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 11:36:18 +0200 Subject: [PATCH 07/16] panels without content cannot be expanded --- scss/_product-page.scss | 4 ++++ .../knowledge-panels/health/ingredients/ingredient.tt.json | 2 +- templates/web/panels/panel.tt.html | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scss/_product-page.scss b/scss/_product-page.scss index 1c46e1f0b9825..5f7793b0b7fe4 100644 --- a/scss/_product-page.scss +++ b/scss/_product-page.scss @@ -118,6 +118,10 @@ $decalTop:48px; } } +li.accordion-navigation.accordion-navigation-inactive:after { + display: none; +} + // align dropdown only on manages images accordion #manage_images_accordion .accordion-navigation { &:after { diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index 629e36f8762a9..fdaea70a8ff11 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -7,7 +7,7 @@ [% IF panel.ingredient_description OR panel.wikipedia_abstract %] "expanded": false, [% ELSE %] - "expanded": false, + "not_expandable": true, [% END %] "title_element": { // double backticks: convert to a single line without newlines and extra spaces diff --git a/templates/web/panels/panel.tt.html b/templates/web/panels/panel.tt.html index cc006a0644c4e..046f420b370ab 100644 --- a/templates/web/panels/panel.tt.html +++ b/templates/web/panels/panel.tt.html @@ -21,6 +21,7 @@ panel = panels.$panel_id; is_card_or_inline = (panel.type == "card") OR (panel.type == "inline"); + has_elements = panel.elements.defined AND panel.elements.size > 0; wrapper_name = is_card_or_inline ? "wrapper_for_card_or_inline" : "wrapper_for_other_types"; %] @@ -92,10 +93,10 @@

[% panel.title_element.title %]

style="margin-top:0.5rem;margin-bottom:1.5rem;" [% END %] > -
  • +
  • [% IF panel.title_element.defined %] - [% panel.title_element.title %]
  • [% panel.title_element.subtitle %] [% END %]
    -
    + [% END %] [% content %] From 47dc2894d1c7e5958fd44da487eb0f775288a0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 11:40:55 +0200 Subject: [PATCH 08/16] panels without content cannot be expanded --- .../knowledge-panels/health/ingredients/ingredient.tt.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index fdaea70a8ff11..fca8b13f94189 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -4,11 +4,6 @@ "health" ], "size": "small", - [% IF panel.ingredient_description OR panel.wikipedia_abstract %] - "expanded": false, - [% ELSE %] - "not_expandable": true, - [% END %] "title_element": { // double backticks: convert to a single line without newlines and extra spaces "title": `` From e6c7ad6c1705d2b19bb27293e45f65a91e4c9a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 11:47:35 +0200 Subject: [PATCH 09/16] Update lib/ProductOpener/KnowledgePanelsIngredients.pm Co-authored-by: Alex Garel --- lib/ProductOpener/KnowledgePanelsIngredients.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ProductOpener/KnowledgePanelsIngredients.pm b/lib/ProductOpener/KnowledgePanelsIngredients.pm index 79c1daa623efb..003420222a3db 100644 --- a/lib/ProductOpener/KnowledgePanelsIngredients.pm +++ b/lib/ProductOpener/KnowledgePanelsIngredients.pm @@ -77,6 +77,7 @@ sub create_ingredients_list_panel ($product_ref, $target_lc, $target_cc, $option if ((defined $product_ref->{ingredients_tags}) and (scalar @{$product_ref->{ingredients_tags}} > 0)) { my $ingredient_i = 0; # sequence number for ingredients + # creates each individual panels for each ingredient my @ingredients_panels_ids = create_ingredients_panels_recursive($product_ref, \$ingredient_i, 0, $product_ref->{ingredients}, $target_lc, $target_cc, $options_ref); From 98b62b446fe8e8eac1bbb13c972531e998d01279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 11:47:42 +0200 Subject: [PATCH 10/16] Update lib/ProductOpener/KnowledgePanelsIngredients.pm Co-authored-by: Alex Garel --- lib/ProductOpener/KnowledgePanelsIngredients.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ProductOpener/KnowledgePanelsIngredients.pm b/lib/ProductOpener/KnowledgePanelsIngredients.pm index 003420222a3db..25d707e7be76d 100644 --- a/lib/ProductOpener/KnowledgePanelsIngredients.pm +++ b/lib/ProductOpener/KnowledgePanelsIngredients.pm @@ -83,6 +83,7 @@ sub create_ingredients_list_panel ($product_ref, $target_lc, $target_cc, $option $target_lc, $target_cc, $options_ref); my $ingredients_list_panel_data_ref = {ingredients_panels_ids => \@ingredients_panels_ids}; + # create the panel that reference ingredients panels create_panel_from_json_template( "ingredients_list", "api/knowledge-panels/health/ingredients/ingredients_list.tt.json", From 8c1881608ef0eae8f0c8b3cba09db3c88d7bd828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 11:54:14 +0200 Subject: [PATCH 11/16] fix template --- .../api/knowledge-panels/health/ingredients/ingredients.tt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json index 50cd77b9ca80b..fb066bc7c82e1 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredients.tt.json @@ -56,7 +56,7 @@ }, }, [% END %] - [% IF 1 %] + [% IF product.ingredients_n.defined && product.ingredients_n > 0 %] { "element_type": "panel", "panel_element": { From 972b015b56d83a9a32e63a1d8ffc2fa231dc0e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 16:53:39 +0200 Subject: [PATCH 12/16] < 2% --- .../health/ingredients/ingredient.tt.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index fca8b13f94189..4c88bbd965e83 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -7,14 +7,18 @@ "title_element": { // double backticks: convert to a single line without newlines and extra spaces "title": `` - [% dash = "-" %] + [% dash = "—" %] [% dash.repeat(panel.level) %] [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %] [% IF panel.ingredient.percent.defined %] - ([% round(panel.ingredient.percent) %]%) + ([% sprintf("%.1f", panel.ingredient.percent) %]%) [% ELSIF panel.ingredient.percent_estimate.defined %] - ([% round(panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) + [% IF panel.ingredient.percent_estimate < 2 %] + (< 2% [% lang("estimate") %]) + [% ELSE %] + ([% sprintf("%.1f", panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) + [% END %] [% END %] ``, }, From c5046143312ae2c40c3ba34a53a283b9329ad819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 16:55:26 +0200 Subject: [PATCH 13/16] < 2% --- .../knowledge-panels/health/ingredients/ingredient.tt.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index 4c88bbd965e83..1491beb02bf89 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -15,9 +15,9 @@ ([% sprintf("%.1f", panel.ingredient.percent) %]%) [% ELSIF panel.ingredient.percent_estimate.defined %] [% IF panel.ingredient.percent_estimate < 2 %] - (< 2% [% lang("estimate") %]) + (< 2% - [% lang("estimate") %]) [% ELSE %] - ([% sprintf("%.1f", panel.ingredient.percent_estimate) %]% [% lang("estimate") %]) + ([% sprintf("%.1f", panel.ingredient.percent_estimate) %]% - [% lang("estimate") %]) [% END %] [% END %] ``, From e2e74276266fcefec634954be6b439bd843ac24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Oct 2024 16:58:18 +0200 Subject: [PATCH 14/16] < 2% --- .../health/ingredients/ingredient.tt.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json index 1491beb02bf89..40e617da5120d 100644 --- a/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json +++ b/templates/api/knowledge-panels/health/ingredients/ingredient.tt.json @@ -10,14 +10,14 @@ [% dash = "—" %] [% dash.repeat(panel.level) %] - [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %] + [% display_taxonomy_tag_name("ingredients", panel.ingredient_id) %][% sep %]: [% IF panel.ingredient.percent.defined %] - ([% sprintf("%.1f", panel.ingredient.percent) %]%) + [% sprintf("%.1f", panel.ingredient.percent) %]% [% ELSIF panel.ingredient.percent_estimate.defined %] [% IF panel.ingredient.percent_estimate < 2 %] - (< 2% - [% lang("estimate") %]) + < 2% ([% lang("estimate") %]) [% ELSE %] - ([% sprintf("%.1f", panel.ingredient.percent_estimate) %]% - [% lang("estimate") %]) + [% sprintf("%.1f", panel.ingredient.percent_estimate) %]% ([% lang("estimate") %]) [% END %] [% END %] ``, From 8fbe28fd817002f925e58327546a1252db10ef07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Thu, 17 Oct 2024 14:18:41 +0200 Subject: [PATCH 15/16] lint --- lib/ProductOpener/KnowledgePanelsIngredients.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ProductOpener/KnowledgePanelsIngredients.pm b/lib/ProductOpener/KnowledgePanelsIngredients.pm index 25d707e7be76d..0639ee99a0eec 100644 --- a/lib/ProductOpener/KnowledgePanelsIngredients.pm +++ b/lib/ProductOpener/KnowledgePanelsIngredients.pm @@ -77,7 +77,7 @@ sub create_ingredients_list_panel ($product_ref, $target_lc, $target_cc, $option if ((defined $product_ref->{ingredients_tags}) and (scalar @{$product_ref->{ingredients_tags}} > 0)) { my $ingredient_i = 0; # sequence number for ingredients - # creates each individual panels for each ingredient + # creates each individual panels for each ingredient my @ingredients_panels_ids = create_ingredients_panels_recursive($product_ref, \$ingredient_i, 0, $product_ref->{ingredients}, $target_lc, $target_cc, $options_ref); From 2a9cdf6c881ab3a3e6451136329ef0e2defdb58f Mon Sep 17 00:00:00 2001 From: Open Food Facts Bot Date: Thu, 17 Oct 2024 12:45:45 +0000 Subject: [PATCH 16/16] test: Update tests results --- .../web_html/world-product.html | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/tests/integration/expected_test_results/web_html/world-product.html b/tests/integration/expected_test_results/web_html/world-product.html index 308536767500d..289ba6e90b1d9 100644 --- a/tests/integration/expected_test_results/web_html/world-product.html +++ b/tests/integration/expected_test_results/web_html/world-product.html @@ -2638,17 +2638,17 @@

    Additives

    -

    Citric acid is a natural organic acid found in citrus fruits such as -lemons, oranges, and limes.

    -

    It is widely used in the food industry as a flavor enhancer, acidulant, -and preservative due to its tart and refreshing taste.

    -

    Citric acid is safe for consumption when used in moderation and is -considered a generally recognized as safe (GRAS) food additive by -regulatory agencies worldwide.

    + Citric acid: Citric acid is a weak organic acid that has the chemical formula C6H8O7. It occurs naturally in citrus fruits. In biochemistry, it is an intermediate in the citric acid cycle, which occurs in the metabolism of all aerobic organisms. More than a million tons of citric acid are manufactured every year. It is used widely as an acidifier, as a flavoring and chelating agent.A citrate is a derivative of citric acid; that is, the salts, esters, and the polyatomic anion found in solution. An example of the former, a salt is trisodium citrate; an ester is triethyl citrate. When part of a salt, the formula of the citrate ion is written as C6H5O3−7 or C3H5O-COO-3−3.
    + Source: + Wikipedia + + + + @@ -2702,19 +2702,17 @@

    Additives

    -

    Sodium carbonates (E500) are compounds commonly used in food preparation -as leavening agents, helping baked goods rise by releasing carbon dioxide -when they interact with acids.

    -

    Often found in baking soda, they regulate the pH of food, preventing it -from becoming too acidic or too alkaline. In the culinary world, sodium -carbonates can also enhance the texture and structure of foods, such as -noodles, by modifying the gluten network.

    -

    Generally recognized as safe, sodium carbonates are non-toxic when -consumed in typical amounts found in food.

    + Sodium carbonate: Sodium carbonate, Na2CO3, -also known as washing soda, soda ash and soda crystals, and in the monohydrate form as crystal carbonate- is the water-soluble sodium salt of carbonic acid. It most commonly occurs as a crystalline decahydrate, which readily effloresces to form a white powder, the monohydrate. Pure sodium carbonate is a white, odorless powder that is hygroscopic -absorbs moisture from the air-. It has a strongly alkaline taste, and forms a moderately basic solution in water. Sodium carbonate is well known domestically for its everyday use as a water softener. Historically it was extracted from the ashes of plants growing in sodium-rich soils, such as vegetation from the Middle East, kelp from Scotland and seaweed from Spain. Because the ashes of these sodium-rich plants were noticeably different from ashes of timber -used to create potash-, they became known as "soda ash". It is synthetically produced in large quantities from salt -sodium chloride- and limestone by a method known as the Solvay process. The manufacture of glass is one of the most important uses of sodium carbonate. Sodium carbonate acts as a flux for silica, lowering the melting point of the mixture to something achievable without special materials. This "soda glass" is mildly water-soluble, so some calcium carbonate is added to the melt mixture to make the glass produced insoluble. This type of glass is known as soda lime glass: "soda" for the sodium carbonate and "lime" for the calcium carbonate. Soda lime glass has been the most common form of glass for centuries. Sodium carbonate is also used as a relatively strong base in various settings. For example, it is used as a pH regulator to maintain stable alkaline conditions necessary for the action of the majority of photographic film developing agents. It acts as an alkali because when dissolved in water, it dissociates into the weak acid: carbonic acid and the strong alkali: sodium hydroxide. This gives sodium carbonate in solution the ability to attack metals such as aluminium with the release of hydrogen gas.It is a common additive in swimming pools used to raise the pH which can be lowered by chlorine tablets and other additives which contain acids. In cooking, it is sometimes used in place of sodium hydroxide for lyeing, especially with German pretzels and lye rolls. These dishes are treated with a solution of an alkaline substance to change the pH of the surface of the food and improve browning. In taxidermy, sodium carbonate added to boiling water will remove flesh from the bones of animal carcasses for trophy mounting or educational display. In chemistry, it is often used as an electrolyte. Electrolytes are usually salt-based, and sodium carbonate acts as a very good conductor in the process of electrolysis. In addition, unlike chloride ions, which form chlorine gas, carbonate ions are not corrosive to the anodes. It is also used as a primary standard for acid-base titrations because it is solid and air-stable, making it easy to weigh accurately.
    + Source: + Wikipedia + + + + @@ -2768,18 +2766,17 @@

    Additives

    -

    Sodium hydrogen carbonate, also known as E500ii, is a food additive -commonly used as a leavening agent.

    -

    When added to recipes, it releases carbon dioxide gas upon exposure to -heat or acids, causing dough to rise and resulting in a light, fluffy -texture in baked goods.

    -

    It is generally recognized as safe (GRAS) by regulatory authorities when -used in appropriate quantities and poses no significant health risks when -consumed in typical food applications.

    + Sodium carbonate: Sodium carbonate, Na2CO3, -also known as washing soda, soda ash and soda crystals, and in the monohydrate form as crystal carbonate- is the water-soluble sodium salt of carbonic acid. It most commonly occurs as a crystalline decahydrate, which readily effloresces to form a white powder, the monohydrate. Pure sodium carbonate is a white, odorless powder that is hygroscopic -absorbs moisture from the air-. It has a strongly alkaline taste, and forms a moderately basic solution in water. Sodium carbonate is well known domestically for its everyday use as a water softener. Historically it was extracted from the ashes of plants growing in sodium-rich soils, such as vegetation from the Middle East, kelp from Scotland and seaweed from Spain. Because the ashes of these sodium-rich plants were noticeably different from ashes of timber -used to create potash-, they became known as "soda ash". It is synthetically produced in large quantities from salt -sodium chloride- and limestone by a method known as the Solvay process. The manufacture of glass is one of the most important uses of sodium carbonate. Sodium carbonate acts as a flux for silica, lowering the melting point of the mixture to something achievable without special materials. This "soda glass" is mildly water-soluble, so some calcium carbonate is added to the melt mixture to make the glass produced insoluble. This type of glass is known as soda lime glass: "soda" for the sodium carbonate and "lime" for the calcium carbonate. Soda lime glass has been the most common form of glass for centuries. Sodium carbonate is also used as a relatively strong base in various settings. For example, it is used as a pH regulator to maintain stable alkaline conditions necessary for the action of the majority of photographic film developing agents. It acts as an alkali because when dissolved in water, it dissociates into the weak acid: carbonic acid and the strong alkali: sodium hydroxide. This gives sodium carbonate in solution the ability to attack metals such as aluminium with the release of hydrogen gas.It is a common additive in swimming pools used to raise the pH which can be lowered by chlorine tablets and other additives which contain acids. In cooking, it is sometimes used in place of sodium hydroxide for lyeing, especially with German pretzels and lye rolls. These dishes are treated with a solution of an alkaline substance to change the pH of the surface of the food and improve browning. In taxidermy, sodium carbonate added to boiling water will remove flesh from the bones of animal carcasses for trophy mounting or educational display. In chemistry, it is often used as an electrolyte. Electrolytes are usually salt-based, and sodium carbonate acts as a very good conductor in the process of electrolysis. In addition, unlike chloride ions, which form chlorine gas, carbonate ions are not corrosive to the anodes. It is also used as a primary standard for acid-base titrations because it is solid and air-stable, making it easy to weigh accurately.
    + Source: + Wikipedia + + + +