From 3b03630c2a1d1e3f4b454dc73d5b881f694fdd65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Thu, 17 Nov 2022 12:40:48 +0100 Subject: [PATCH 1/3] fix knowledge panels API --- lib/ProductOpener/API.pm | 1 + lib/ProductOpener/Display.pm | 33 - lib/ProductOpener/KnowledgePanels.pm | 33 + tests/integration/api_v3_product_read.t | 28 + .../get-attribute-groups-fr.json | 308 +++++ .../get-attribute-groups.json | 308 +++++ .../get-existing-product.json | 1 + .../get-knowledge-panels-fr.json | 1079 +++++++++++++++++ .../get-knowledge-panels.json | 1079 +++++++++++++++++ 9 files changed, 2837 insertions(+), 33 deletions(-) create mode 100644 tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups-fr.json create mode 100644 tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups.json create mode 100644 tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json create mode 100644 tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json diff --git a/lib/ProductOpener/API.pm b/lib/ProductOpener/API.pm index fcf539afef633..cbf0f472aa1e6 100644 --- a/lib/ProductOpener/API.pm +++ b/lib/ProductOpener/API.pm @@ -66,6 +66,7 @@ use ProductOpener::Export qw/:all/; use ProductOpener::Tags qw/:all/; use ProductOpener::Text qw/:all/; use ProductOpener::Attributes qw/:all/; +use ProductOpener::KnowledgePanels qw/:all/; use ProductOpener::Ecoscore qw/localize_ecoscore/; use ProductOpener::APIProductRead qw/:all/; diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm index aa115e6d5e627..7e21fdacc3ee0 100644 --- a/lib/ProductOpener/Display.pm +++ b/lib/ProductOpener/Display.pm @@ -4626,39 +4626,6 @@ sub add_params_to_query ($request_ref, $query_ref) { return; } -=head2 initialize_knowledge_panels_options( $knowledge_panels_options_ref, $request_ref ) - -Initialize the options for knowledge panels from parameters. - -=cut - -sub initialize_knowledge_panels_options ($knowledge_panels_options_ref, $request_ref) { - - # Activate physical activity knowledge panel only when specified - if (single_param("activate_knowledge_panel_physical_activities")) { - $knowledge_panels_options_ref->{activate_knowledge_panel_physical_activities} = 1; - } - - # Specify if we knowledge panels are requested from the app or the website - # in order to allow different behaviours (e.g. showing ingredients before nutrition on the web) - # possible values: "web", "app" - my $knowledge_panels_client = single_param("knowledge_panels_client"); - # set a default value if client is not defined to app or web - if ( (not defined $knowledge_panels_client) - or (($knowledge_panels_client ne "web") and ($knowledge_panels_client ne "app"))) - { - # Default to app mode - $knowledge_panels_client = 'app'; - # but if it's not an api request, we consider it should be web - if (not defined $request_ref->{api}) { - $knowledge_panels_client = "web"; - } - } - $knowledge_panels_options_ref->{knowledge_panels_client} = $knowledge_panels_client; - - return; -} - sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $page) { $request_ref->{page_type} = "products"; diff --git a/lib/ProductOpener/KnowledgePanels.pm b/lib/ProductOpener/KnowledgePanels.pm index 9f783f6365d89..75a6549af04d2 100644 --- a/lib/ProductOpener/KnowledgePanels.pm +++ b/lib/ProductOpener/KnowledgePanels.pm @@ -44,6 +44,7 @@ BEGIN { use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); @EXPORT_OK = qw( + &initialize_knowledge_panels_options &create_knowledge_panels ); # symbols to export on request @@ -69,6 +70,38 @@ use Data::DeepAccess qw(deep_get); =head1 FUNCTIONS +=head2 initialize_knowledge_panels_options( $knowledge_panels_options_ref, $request_ref ) + +Initialize the options for knowledge panels from parameters. + +=cut + +sub initialize_knowledge_panels_options ($knowledge_panels_options_ref, $request_ref) { + + # Activate physical activity knowledge panel only when specified + if (single_param("activate_knowledge_panel_physical_activities")) { + $knowledge_panels_options_ref->{activate_knowledge_panel_physical_activities} = 1; + } + + # Specify if we knowledge panels are requested from the app or the website + # in order to allow different behaviours (e.g. showing ingredients before nutrition on the web) + # possible values: "web", "app" + my $knowledge_panels_client = single_param("knowledge_panels_client"); + # set a default value if client is not defined to app or web + if ( (not defined $knowledge_panels_client) + or (($knowledge_panels_client ne "web") and ($knowledge_panels_client ne "app"))) + { + # Default to app mode + $knowledge_panels_client = 'app'; + # but if it's not an api request, we consider it should be web + if (not defined $request_ref->{api}) { + $knowledge_panels_client = "web"; + } + } + $knowledge_panels_options_ref->{knowledge_panels_client} = $knowledge_panels_client; + + return; +} =head2 create_knowledge_panels( $product_ref, $target_lc, $target_cc, $options_ref ) diff --git a/tests/integration/api_v3_product_read.t b/tests/integration/api_v3_product_read.t index 6ea6a5e4b7240..a55d10817b03c 100644 --- a/tests/integration/api_v3_product_read.t +++ b/tests/integration/api_v3_product_read.t @@ -71,6 +71,34 @@ my $tests_ref = [ query_string => '?fields=images_to_update_en', expected_status_code => 200, }, + { + test_case => 'get-attribute-groups', + method => 'GET', + path => '/api/v3/product/200000000034', + query_string => '?fields=attribute_groups', + expected_status_code => 200, + }, + { + test_case => 'get-attribute-groups-fr', + method => 'GET', + path => '/api/v3/product/200000000034', + query_string => '?fields=attribute_groups&lc=fr', + expected_status_code => 200, + }, + { + test_case => 'get-knowledge-panels', + method => 'GET', + path => '/api/v3/product/200000000034', + query_string => '?fields=knowledge_panels', + expected_status_code => 200, + }, + { + test_case => 'get-knowledge-panels-fr', + method => 'GET', + path => '/api/v3/product/200000000034', + query_string => '?fields=knowledge_panels&lc=fr', + expected_status_code => 200, + }, ]; execute_api_tests(__FILE__, $tests_ref); diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups-fr.json b/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups-fr.json new file mode 100644 index 0000000000000..1a699d71d6b4e --- /dev/null +++ b/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups-fr.json @@ -0,0 +1,308 @@ +{ + "code" : "200000000034", + "errors" : [], + "product" : { + "attribute_groups" : [ + { + "attributes" : [ + { + "description" : "", + "description_short" : "Données manquantes pour calculer le Nutri-Score", + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "id" : "nutriscore", + "match" : 0, + "name" : "Nutri-Score", + "panel_id" : "nutriscore", + "status" : "unknown", + "title" : "Nutri-Score inconnu" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-salt-unknown.svg", + "id" : "low_salt", + "missing" : "Données nutritionnelles manquantes", + "name" : "Sel", + "status" : "unknown", + "title" : "Sel en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-fat-unknown.svg", + "id" : "low_fat", + "missing" : "Données nutritionnelles manquantes", + "name" : "Matières grasses", + "status" : "unknown", + "title" : "Matières grasses en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-sugars-unknown.svg", + "id" : "low_sugars", + "missing" : "Données nutritionnelles manquantes", + "name" : "Sucres", + "status" : "unknown", + "title" : "Sucres en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-saturated-fat-unknown.svg", + "id" : "low_saturated_fat", + "missing" : "Données nutritionnelles manquantes", + "name" : "Acides gras saturés", + "status" : "unknown", + "title" : "Acides gras saturés en quantité inconnue" + } + ], + "id" : "nutritional_quality", + "name" : "Qualité nutritionnelle" + }, + { + "attributes" : [ + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-gluten.svg", + "id" : "allergens_no_gluten", + "match" : 100, + "name" : "Gluten", + "status" : "known", + "title" : "Ne contient pas : Gluten" + }, + { + "debug" : "en:milk in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-milk.svg", + "id" : "allergens_no_milk", + "match" : 0, + "name" : "Lait", + "status" : "known", + "title" : "Contient : Lait" + }, + { + "debug" : "en:eggs in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-eggs.svg", + "id" : "allergens_no_eggs", + "match" : 0, + "name" : "Œufs", + "status" : "known", + "title" : "Contient : Œufs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-nuts.svg", + "id" : "allergens_no_nuts", + "match" : 100, + "name" : "Fruits à coque", + "status" : "known", + "title" : "Ne contient pas : Fruits à coque" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-peanuts.svg", + "id" : "allergens_no_peanuts", + "match" : 100, + "name" : "Arachides", + "status" : "known", + "title" : "Ne contient pas : Arachides" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sesame-seeds.svg", + "id" : "allergens_no_sesame_seeds", + "match" : 100, + "name" : "Graines de sésame", + "status" : "known", + "title" : "Ne contient pas : Graines de sésame" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-soybeans.svg", + "id" : "allergens_no_soybeans", + "match" : 100, + "name" : "Soja", + "status" : "known", + "title" : "Ne contient pas : Soja" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-celery.svg", + "id" : "allergens_no_celery", + "match" : 100, + "name" : "Céleri", + "status" : "known", + "title" : "Ne contient pas : Céleri" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-mustard.svg", + "id" : "allergens_no_mustard", + "match" : 100, + "name" : "Moutarde", + "status" : "known", + "title" : "Ne contient pas : Moutarde" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-lupin.svg", + "id" : "allergens_no_lupin", + "match" : 100, + "name" : "Lupin", + "status" : "known", + "title" : "Ne contient pas : Lupin" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-fish.svg", + "id" : "allergens_no_fish", + "match" : 100, + "name" : "Poisson", + "status" : "known", + "title" : "Ne contient pas : Poisson" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-crustaceans.svg", + "id" : "allergens_no_crustaceans", + "match" : 100, + "name" : "Crustacés", + "status" : "known", + "title" : "Ne contient pas : Crustacés" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-molluscs.svg", + "id" : "allergens_no_molluscs", + "match" : 100, + "name" : "Mollusques", + "status" : "known", + "title" : "Ne contient pas : Mollusques" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sulphur-dioxide-and-sulphites.svg", + "id" : "allergens_no_sulphur_dioxide_and_sulphites", + "match" : 100, + "name" : "Anhydride sulfureux et sulfites", + "status" : "known", + "title" : "Ne contient pas : Anhydride sulfureux et sulfites" + } + ], + "id" : "allergens", + "name" : "Allergènes", + "warning" : "Il est toujours possible que les données sur les allergènes soient manquantes, incomplètes, incorrectes ou que la composition du produit ait changé. Si vous êtes allergique, vérifiez toujours les informations sur l'emballage réel du produit." + }, + { + "attributes" : [ + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/non-vegan.svg", + "id" : "vegan", + "match" : 0, + "name" : "Végétalien", + "panel_id" : "ingredients_analysis_en:non-vegan", + "status" : "known", + "title" : "Non végétalien" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/vegetarian.svg", + "id" : "vegetarian", + "match" : 100, + "name" : "Végétarien", + "panel_id" : "ingredients_analysis_en:vegetarian", + "status" : "known", + "title" : "Végétarien" + }, + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-palm-oil.svg", + "id" : "palm_oil_free", + "match" : 0, + "name" : "Sans huile de palme", + "panel_id" : "ingredients_analysis_en:palm-oil", + "status" : "known", + "title" : "Huile de palme" + } + ], + "id" : "ingredients_analysis", + "name" : "Ingrédients" + }, + { + "attributes" : [ + { + "description" : "", + "description_short" : "Aliments transformés", + "grade" : "b", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "id" : "nova", + "match" : 75, + "name" : "Groupe NOVA", + "panel_id" : "nova", + "status" : "known", + "title" : "NOVA 3" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/0-additives.svg", + "id" : "additives", + "match" : 100, + "name" : "Additifs", + "panel_id" : "additives", + "status" : "known", + "title" : "Sans additifs" + } + ], + "id" : "processing", + "name" : "Transformation des aliments" + }, + { + "attributes" : [ + { + "description" : "L'agriculture biologique vise à protéger l'environnement et à conserver la biodiversité en prohibant ou limitant l'utilisation d'engrais synthétiques, de pesticides et d'additifs alimentaires.", + "description_short" : "Encourage la durabilité écologique et la biodiversité.", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/organic.svg", + "id" : "labels_organic", + "match" : 100, + "name" : "Agriculture biologique", + "status" : "known", + "title" : "Produit bio" + }, + { + "description" : "Quand vous achetez des produits du commerce équitable, les producteurs dans les pays en développement sont payés un prix plus haut et plus équitable, ce qui les aide à atteindre des plus hauts standards sociaux et environnementaux et à les conserver.", + "description_short" : "Les produits du commerce équitable aident les producteurs des pays en voie de développement.", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/not-fair-trade.svg", + "id" : "labels_fair_trade", + "match" : 0, + "name" : "Commerce équitable", + "status" : "known", + "title" : "Ne provient pas du commerce équitable" + } + ], + "id" : "labels", + "name" : "Labels" + } + ] + }, + "result" : { + "id" : "product_found", + "lc_name" : "Product found", + "name" : "Product found" + }, + "status" : "success", + "warnings" : [] +} diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups.json b/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups.json new file mode 100644 index 0000000000000..8f6c9e989e14f --- /dev/null +++ b/tests/integration/expected_test_results/api_v3_product_read/get-attribute-groups.json @@ -0,0 +1,308 @@ +{ + "code" : "200000000034", + "errors" : [], + "product" : { + "attribute_groups" : [ + { + "attributes" : [ + { + "description" : "", + "description_short" : "Missing data to compute the Nutri-Score", + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "id" : "nutriscore", + "match" : 0, + "name" : "Nutri-Score", + "panel_id" : "nutriscore", + "status" : "unknown", + "title" : "Nutri-Score unknown" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-salt-unknown.svg", + "id" : "low_salt", + "missing" : "Missing nutrition facts", + "name" : "Salt", + "status" : "unknown", + "title" : "Salt in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-fat-unknown.svg", + "id" : "low_fat", + "missing" : "Missing nutrition facts", + "name" : "Fat", + "status" : "unknown", + "title" : "Fat in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-sugars-unknown.svg", + "id" : "low_sugars", + "missing" : "Missing nutrition facts", + "name" : "Sugars", + "status" : "unknown", + "title" : "Sugars in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-saturated-fat-unknown.svg", + "id" : "low_saturated_fat", + "missing" : "Missing nutrition facts", + "name" : "Saturated fat", + "status" : "unknown", + "title" : "Saturated fat in unknown quantity" + } + ], + "id" : "nutritional_quality", + "name" : "Nutritional quality" + }, + { + "attributes" : [ + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-gluten.svg", + "id" : "allergens_no_gluten", + "match" : 100, + "name" : "Gluten", + "status" : "known", + "title" : "Does not contain: Gluten" + }, + { + "debug" : "en:milk in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-milk.svg", + "id" : "allergens_no_milk", + "match" : 0, + "name" : "Milk", + "status" : "known", + "title" : "Contains: Milk" + }, + { + "debug" : "en:eggs in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-eggs.svg", + "id" : "allergens_no_eggs", + "match" : 0, + "name" : "Eggs", + "status" : "known", + "title" : "Contains: Eggs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-nuts.svg", + "id" : "allergens_no_nuts", + "match" : 100, + "name" : "Nuts", + "status" : "known", + "title" : "Does not contain: Nuts" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-peanuts.svg", + "id" : "allergens_no_peanuts", + "match" : 100, + "name" : "Peanuts", + "status" : "known", + "title" : "Does not contain: Peanuts" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sesame-seeds.svg", + "id" : "allergens_no_sesame_seeds", + "match" : 100, + "name" : "Sesame seeds", + "status" : "known", + "title" : "Does not contain: Sesame seeds" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-soybeans.svg", + "id" : "allergens_no_soybeans", + "match" : 100, + "name" : "Soybeans", + "status" : "known", + "title" : "Does not contain: Soybeans" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-celery.svg", + "id" : "allergens_no_celery", + "match" : 100, + "name" : "Celery", + "status" : "known", + "title" : "Does not contain: Celery" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-mustard.svg", + "id" : "allergens_no_mustard", + "match" : 100, + "name" : "Mustard", + "status" : "known", + "title" : "Does not contain: Mustard" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-lupin.svg", + "id" : "allergens_no_lupin", + "match" : 100, + "name" : "Lupin", + "status" : "known", + "title" : "Does not contain: Lupin" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-fish.svg", + "id" : "allergens_no_fish", + "match" : 100, + "name" : "Fish", + "status" : "known", + "title" : "Does not contain: Fish" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-crustaceans.svg", + "id" : "allergens_no_crustaceans", + "match" : 100, + "name" : "Crustaceans", + "status" : "known", + "title" : "Does not contain: Crustaceans" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-molluscs.svg", + "id" : "allergens_no_molluscs", + "match" : 100, + "name" : "Molluscs", + "status" : "known", + "title" : "Does not contain: Molluscs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sulphur-dioxide-and-sulphites.svg", + "id" : "allergens_no_sulphur_dioxide_and_sulphites", + "match" : 100, + "name" : "Sulphur dioxide and sulphites", + "status" : "known", + "title" : "Does not contain: Sulphur dioxide and sulphites" + } + ], + "id" : "allergens", + "name" : "Allergens", + "warning" : "There is always a possibility that data about allergens may be missing, incomplete, incorrect or that the product's composition has changed. If you are allergic, always check the information on the actual product packaging." + }, + { + "attributes" : [ + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/non-vegan.svg", + "id" : "vegan", + "match" : 0, + "name" : "Vegan", + "panel_id" : "ingredients_analysis_en:non-vegan", + "status" : "known", + "title" : "Non-vegan" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/vegetarian.svg", + "id" : "vegetarian", + "match" : 100, + "name" : "Vegetarian", + "panel_id" : "ingredients_analysis_en:vegetarian", + "status" : "known", + "title" : "Vegetarian" + }, + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-palm-oil.svg", + "id" : "palm_oil_free", + "match" : 0, + "name" : "Palm oil free", + "panel_id" : "ingredients_analysis_en:palm-oil", + "status" : "known", + "title" : "Palm oil" + } + ], + "id" : "ingredients_analysis", + "name" : "Ingredients" + }, + { + "attributes" : [ + { + "description" : "", + "description_short" : "Processed foods", + "grade" : "b", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "id" : "nova", + "match" : 75, + "name" : "NOVA group", + "panel_id" : "nova", + "status" : "known", + "title" : "NOVA 3" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/0-additives.svg", + "id" : "additives", + "match" : 100, + "name" : "Additives", + "panel_id" : "additives", + "status" : "known", + "title" : "Without additives" + } + ], + "id" : "processing", + "name" : "Food processing" + }, + { + "attributes" : [ + { + "description" : "Organic farming aims to protect the environment and to conserve biodiversity by prohibiting or limiting the use of synthetic fertilizers, pesticides and food additives.", + "description_short" : "Promotes ecological sustainability and biodiversity.", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/organic.svg", + "id" : "labels_organic", + "match" : 100, + "name" : "Organic farming", + "status" : "known", + "title" : "Organic product" + }, + { + "description" : "When you buy fair trade products, producers in developing countries are paid an higher and fairer price, which helps them improve and sustain higher social and often environmental standards.", + "description_short" : "Fair trade products help producers in developing countries.", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/not-fair-trade.svg", + "id" : "labels_fair_trade", + "match" : 0, + "name" : "Fair trade", + "status" : "known", + "title" : "Not a fair trade product" + } + ], + "id" : "labels", + "name" : "Labels" + } + ] + }, + "result" : { + "id" : "product_found", + "lc_name" : "Product found", + "name" : "Product found" + }, + "status" : "success", + "warnings" : [] +} diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json b/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json index 99ce27e1ff616..64a76c0207253 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json @@ -69,6 +69,7 @@ "20xxxxxxxxxx", "2xxxxxxxxxxx" ], + "compared_to_category" : "en:snacks", "complete" : 0, "completeness" : 0.5, "correctors_tags" : [], 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 new file mode 100644 index 0000000000000..e0560302a2b8d --- /dev/null +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json @@ -0,0 +1,1079 @@ +{ + "code" : "200000000034", + "errors" : [], + "product" : { + "knowledge_panels" : { + "carbon_footprint" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Le chiffre d'émission carbone est issu de la base de données Agribalyse de l'ADEME, pour la catégorie : \n Biscuit sec, sans précision\n (Source : Base de données ADEME Agribalyse)\n

\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Etape", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_carbon_impact_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 86.4490565865388, + "text" : "86.4 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Transformation" + }, + { + "percent" : 7.40512661892125, + "text" : "7.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Conditionnement" + }, + { + "percent" : 2.44549029302522, + "text" : "2.4 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transport" + }, + { + "percent" : 3.04594655954887, + "text" : "3.0 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 0.655173174089646, + "text" : "0.7 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consommation" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Détail des impacts par étapes du cycle de vie" + } + } + ], + "evaluation" : "average", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/car.svg", + "subtitle" : "444 g de CO² pour 100g de produit", + "title" : "Équivaut à parcourir 2.3 km dans une voiture à essence" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "L'Eco-Score est un score expérimental qui synthétise les impacts environnementaux des produits alimentaires." + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n L'Eco-Score a été initialement conçu pour la France et est en cours d'extension à d'autres pays européens. La formule de l'Eco-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise et mieux adaptée à chaque pays.\n \n ", + "type" : "note" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_agribalyse" + ], + "title" : "Analyse du cycle de vie" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_origins_of_ingredients", + "ecoscore_threatened_species", + "ecoscore_packaging" + ], + "title" : "Bonus et malus" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_total" + ], + "title" : "Eco-Score pour ce produit" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

En savoir plus sur l'Eco-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/ecoscore-d.svg", + "title" : "Éco-Score D - Impact environnemental élevé", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_agribalyse" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Catégorie : \n Biscuit sec, sans précision\n

\n \n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Etape", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_lca_impacts_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 80.3235532201964, + "text" : "80.3 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Transformation" + }, + { + "percent" : 11.4323646504281, + "text" : "11.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Conditionnement" + }, + { + "percent" : 3.66880158328128, + "text" : "3.7 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transport" + }, + { + "percent" : 2.37118922373698, + "text" : "2.4 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 2.20492840669224, + "text" : "2.2 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consommation" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Détail des impacts par étapes du cycle de vie" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "c", + "subtitle" : "Catégorie : Biscuit sec, sans précision", + "title" : "Impact moyen des produits de la même catégorie : C (Score: 58/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les origines des ingrédients de ce produit ne sont pas renseignées.

\n Si elles sont indiquées sur l'emballage, vous pouvez modifier la fiche produit et les ajouter.

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Malus : -5", + "title" : "Informations manquantes sur les origines des ingrédients" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_packaging" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les informations sur l'emballage de ce produit ne sont pas renseignées.\n ", + "type" : "warning" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n Pour un calcul plus précis de l'Eco-Score, vous pouvez modifier la fiche produit et les ajouter.\n

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "subtitle" : "Malus : -15", + "title" : "Informations d'emballage manquantes pour ce produit" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_production_system" : { + "evaluation" : "neutral", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "title" : "Pas de labels avec des avantages environnementaux" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_threatened_species" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Contient de l'huile de palme

\n

Les forêts tropicales d'Asie, d'Afrique et d'Amérique latine sont détruites pour créer et étendre les plantations de palmiers à huile. La déforestation contribue au changement climatique et met en danger des espèces telles que l'orang-outan, l'éléphant pygmée et le rhinocéros de Sumatra.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/monkey_unhappy.svg", + "subtitle" : "Malus : -10", + "title" : "Ingrédients qui menacent des espèces" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_total" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Score d'analyse du cycle de vie : 58
\n Somme des bonus et malus :\n \n -30\n

\n Score final : 28/100\n \n ", + "type" : "summary" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "subtitle" : "Produit : Some product - 100 g", + "title" : "Impact pour ce produit: D (Score: 28/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "environment_card" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ecoscore" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "carbon_footprint" + ], + "title" : "Empreinte carbone" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "packaging_recycling", + "panel_ids" : [ + "packaging_recycling" + ], + "title" : "Conditionnement" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "origins_of_ingredients" + ], + "title" : "Transport" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "palm_oil" + ], + "title" : "Espèces menacées" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Environnement" + }, + "topics" : [ + "environment" + ], + "type" : "card" + }, + "health_card" : { + "elements" : [ + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "nutrition", + "panel_ids" : [ + "nutriscore" + ], + "title" : "Nutrition", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nutrition_facts_table", + "serving_size" + ], + "title" : "" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "ingredients", + "panel_ids" : [ + "ingredients" + ], + "title" : "Ingrédients", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nova" + ], + "title" : "Transformation des aliments" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ingredients_analysis", + "ingredients_analysis_details" + ], + "title" : "Analyse des ingrédients" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Santé" + }, + "topics" : [ + "health" + ], + "type" : "card" + }, + "ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "edit_field_id" : "ingredients_text_en", + "edit_field_type" : "ingredients_text", + "edit_field_value" : "apple, milk, eggs, palm oil", + "html" : "apple, milk, eggs, palm oil", + "language" : "Anglais", + "lc" : "en" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "Allergènes : \n Œufs, Lait\n " + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/ingredients.svg", + "title" : "4 ingrédients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:palm-oil" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:non-vegan" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:vegetarian" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "L'analyse est basée uniquement sur les ingrédients listés et ne prend pas en compte les méthodes de fabrication." + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + }, + "ingredients_analysis_details" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "apple, milk, eggs, palm oil" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "
    \n
  1. apple -> en:apple - vegan: yes - vegetarian: yes - percent_min: 25 - percent_max: 100
  2. \n
  3. milk -> en:milk - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 50
  4. \n
  5. eggs -> en:egg - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 33.3333333333333
  6. \n
  7. palm oil -> en:palm-oil - vegan: yes - vegetarian: yes - from_palm_oil: yes - percent_min: 0 - percent_max: 25
  8. \n
\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/off-magnifying-glass.svg", + "title" : "Détail de l'analyse des ingrédients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:non-vegan" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingrédients non végétaliens :\n Lait, Œuf\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/leaf.svg", + "title" : "Non végétalien" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:palm-oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingrédients contenant de l'huile de palme :\n Huile de palme\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "title" : "Huile de palme" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:vegetarian" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Aucun ingrédient non végétarien détecté\n \n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "good", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/vegetarian.svg", + "title" : "Végétarien" + }, + "topics" : [ + "health" + ] + }, + "nova" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n\n \n \n

Éléments qui indiquent que le produit est dans le groupe 3 - Aliments transformés :

\n \n \n \n\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Les produits alimentaires sont classés en 4 groupes selon leur degré de transformation :

\n
    \n
  1. Aliments non transformés ou minimalement transformés
  2. \n
  3. Ingrédients culinaires transformés
  4. \n
  5. Aliments transformés
  6. \n
  7. Aliments ultra-transformés
  8. \n
\n
\n

La détermination du groupe est basée sur la catégorie du produit et sur les ingrédients qu'il contient.

\n

En savoir plus sur la classification NOVA

\n" + } + } + ], + "level" : "info", + "title_element" : { + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "title" : "Aliments transformés" + }, + "topics" : [ + "health" + ] + }, + "nutriscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "Les données nutritionnelles du produit doivent être spécifiées afin de calculer le Nutri-Score.\n ", + "type" : "warning" + } + }, + { + "action_element" : { + "actions" : [ + "add_nutrition_facts" + ], + "html" : "Pourriez-vous ajouter les informations nécessaires pour calculer le Nutri-Score ?" + }, + "element_type" : "action" + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

En savoir plus sur le Nutri-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "subtitle" : "Données nutritionnelles manquantes", + "title" : "Données manquantes pour calculer le Nutri-Score", + "type" : "grade" + }, + "topics" : [ + "health" + ] + }, + "nutrition_facts_table" : { + "elements" : [ + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "style" : "max-width:15rem", + "text" : "Tableau nutritionnel", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : true, + "text" : "Tel que vendu
pour 100 g / 100 ml", + "text_for_small_screens" : "100g", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : false, + "text" : "Tel que vendu
par portion (10 g)", + "text_for_small_screens" : "par portion", + "type" : "text" + }, + { + "column_group_id" : "comparisons", + "shown_by_default" : true, + "text" : "Comparé à: Snacks", + "type" : "text" + } + ], + "id" : "nutrition_facts_table", + "rows" : [ + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Matières grasses" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Acides gras saturés" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Glucides" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Sucres" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fibres alimentaires" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Protéines" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Sel" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fruits‚ légumes‚ noix et huiles de colza‚ noix et olive (estimation par analyse de la liste des ingrédients)" + }, + { + "text" : "25 %" + }, + { + "text" : "25 %" + }, + { + "text" : "" + } + ] + } + ], + "title" : "Tableau nutritionnel" + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/scale-balance.svg", + "title" : "Tableau nutritionnel" + }, + "topics" : [ + "health" + ] + }, + "origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les origines des ingrédients de ce produit ne sont pas renseignées.

\n Si elles sont indiquées sur l'emballage, vous pouvez modifier la fiche produit et les ajouter.

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Informations manquantes sur les origines des ingrédients", + "title" : "Origines des ingrédients" + }, + "topics" : [ + "environment" + ] + }, + "packaging_recycling" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les informations sur l'emballage de ce produit ne sont pas renseignées.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "evaluation" : "neutral", + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "title" : "Informations d'emballage manquantes pour ce produit" + }, + "topics" : [ + "environment" + ] + }, + "palm_oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Les forêts tropicales d'Asie, d'Afrique et d'Amérique latine sont détruites pour créer et étendre les plantations de palmiers à huile. La déforestation contribue au changement climatique et met en danger des espèces telles que l'orang-outan, l'éléphant pygmée et le rhinocéros de Sumatra.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "subtitle" : "Stimule la déforestation et menace des espèces telles que l'orang-outan", + "title" : "Contient de l'huile de palme" + }, + "topics" : [ + "environment" + ] + }, + "root" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "health_card" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "environment_card" + } + } + ], + "expanded" : true, + "type" : "root" + }, + "serving_size" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Taille d'une portion :\n 10 g\n " + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + } + } + }, + "result" : { + "id" : "product_found", + "lc_name" : "Product found", + "name" : "Product found" + }, + "status" : "success", + "warnings" : [] +} 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 new file mode 100644 index 0000000000000..a961233b3c77b --- /dev/null +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json @@ -0,0 +1,1079 @@ +{ + "code" : "200000000034", + "errors" : [], + "product" : { + "knowledge_panels" : { + "carbon_footprint" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Biscuit (cookie)\n (Source: ADEME Agribalyse Database)\n

\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Stage", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_carbon_impact_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 86.4490565865388, + "text" : "86.4 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Processing" + }, + { + "percent" : 7.40512661892125, + "text" : "7.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Packaging" + }, + { + "percent" : 2.44549029302522, + "text" : "2.4 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transportation" + }, + { + "percent" : 3.04594655954887, + "text" : "3.0 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 0.655173174089646, + "text" : "0.7 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consumption" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Details of the impacts by stages of the life cycle" + } + } + ], + "evaluation" : "average", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/car.svg", + "subtitle" : "444 g CO² per 100g of product", + "title" : "Equal to driving 2.3 km in a petrol car" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "The Eco-Score is an experimental score that summarizes the environmental impacts of food products." + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ", + "type" : "note" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_agribalyse" + ], + "title" : "Life cycle analysis" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_origins_of_ingredients", + "ecoscore_threatened_species", + "ecoscore_packaging" + ], + "title" : "Bonuses and maluses" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_total" + ], + "title" : "Eco-Score for this product" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Learn more about the Eco-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/ecoscore-d.svg", + "title" : "Eco-Score D - High environmental impact", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_agribalyse" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Category: \n Biscuit (cookie)\n

\n \n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Stage", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_lca_impacts_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 80.3235532201964, + "text" : "80.3 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Processing" + }, + { + "percent" : 11.4323646504281, + "text" : "11.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Packaging" + }, + { + "percent" : 3.66880158328128, + "text" : "3.7 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transportation" + }, + { + "percent" : 2.37118922373698, + "text" : "2.4 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 2.20492840669224, + "text" : "2.2 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consumption" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Details of the impacts by stages of the life cycle" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "c", + "subtitle" : "Category: Biscuit (cookie)", + "title" : "Average impact of products of the same category: C (Score: 58/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The origins of the ingredients of this product are not indicated.

\n If they are indicated on the packaging, you can modify the product sheet and add them.

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Malus: -5", + "title" : "Missing origins of ingredients information" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_packaging" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The information about the packaging of this product is not filled in.\n ", + "type" : "warning" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n For a more precise calculation of the Eco-Score, you can modify the product page and add them.\n

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "subtitle" : "Malus: -15", + "title" : "Missing packaging information for this product" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_production_system" : { + "evaluation" : "neutral", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "title" : "No labels with environmental benefits" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_threatened_species" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Contains palm oil

\n

Tropical forests in Asia, Africa and Latin America are destroyed to create and expand oil palm tree plantations. The deforestation contributes to climate change, and it endangers species such as the orangutan, the pigmy elephant and the Sumatran rhino.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/monkey_unhappy.svg", + "subtitle" : "Malus: -10", + "title" : "Ingredients that threatens species" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_total" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Life cycle analysis score: 58
\n Sum of bonuses and maluses:\n \n -30\n

\n Final score: 28/100\n \n ", + "type" : "summary" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "subtitle" : "Product: Some product - 100 g", + "title" : "Impact for this product: D (Score: 28/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "environment_card" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ecoscore" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "carbon_footprint" + ], + "title" : "Carbon footprint" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "packaging_recycling", + "panel_ids" : [ + "packaging_recycling" + ], + "title" : "Packaging" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "origins_of_ingredients" + ], + "title" : "Transportation" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "palm_oil" + ], + "title" : "Threatened species" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Environment" + }, + "topics" : [ + "environment" + ], + "type" : "card" + }, + "health_card" : { + "elements" : [ + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "nutrition", + "panel_ids" : [ + "nutriscore" + ], + "title" : "Nutrition", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nutrition_facts_table", + "serving_size" + ], + "title" : "" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "ingredients", + "panel_ids" : [ + "ingredients" + ], + "title" : "Ingredients", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nova" + ], + "title" : "Food processing" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ingredients_analysis", + "ingredients_analysis_details" + ], + "title" : "Ingredients analysis" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Health" + }, + "topics" : [ + "health" + ], + "type" : "card" + }, + "ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "edit_field_id" : "ingredients_text_en", + "edit_field_type" : "ingredients_text", + "edit_field_value" : "apple, milk, eggs, palm oil", + "html" : "apple, milk, eggs, palm oil", + "language" : "English", + "lc" : "en" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "Allergens: \n Eggs, Milk\n " + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/ingredients.svg", + "title" : "4 ingredients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:palm-oil" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:non-vegan" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:vegetarian" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "The analysis is based solely on the ingredients listed and does not take into account processing methods." + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + }, + "ingredients_analysis_details" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "apple, milk, eggs, palm oil" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "
    \n
  1. apple -> en:apple - vegan: yes - vegetarian: yes - percent_min: 25 - percent_max: 100
  2. \n
  3. milk -> en:milk - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 50
  4. \n
  5. eggs -> en:egg - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 33.3333333333333
  6. \n
  7. palm oil -> en:palm-oil - vegan: yes - vegetarian: yes - from_palm_oil: yes - percent_min: 0 - percent_max: 25
  8. \n
\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/off-magnifying-glass.svg", + "title" : "Details of the analysis of the ingredients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:non-vegan" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Non-vegan ingredients:\n Milk, Egg\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/leaf.svg", + "title" : "Non-vegan" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:palm-oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingredients that contain palm oil:\n Palm oil\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "title" : "Palm oil" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:vegetarian" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n No non-vegetarian ingredients detected\n \n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "good", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/vegetarian.svg", + "title" : "Vegetarian" + }, + "topics" : [ + "health" + ] + }, + "nova" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n\n \n \n

Elements that indicate the product is in the 3 - Processed foods group:

\n \n \n \n\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Food products are classified into 4 groups according to their degree of processing:

\n
    \n
  1. Unprocessed or minimally processed foods
  2. \n
  3. Processed culinary ingredients
  4. \n
  5. Processed foods
  6. \n
  7. Ultra processed foods
  8. \n
\n
\n

The determination of the group is based on the category of the product and on the ingredients it contains.

\n

Learn more about the NOVA classification

\n" + } + } + ], + "level" : "info", + "title_element" : { + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "title" : "Processed foods" + }, + "topics" : [ + "health" + ] + }, + "nutriscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "The nutrition facts of the product must be specified in order to compute the Nutri-Score.\n ", + "type" : "warning" + } + }, + { + "action_element" : { + "actions" : [ + "add_nutrition_facts" + ], + "html" : "Could you add the information needed to compute the Nutri-Score?" + }, + "element_type" : "action" + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Learn more about the Nutri-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "subtitle" : "Missing nutrition facts", + "title" : "Missing data to compute the Nutri-Score", + "type" : "grade" + }, + "topics" : [ + "health" + ] + }, + "nutrition_facts_table" : { + "elements" : [ + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "style" : "max-width:15rem", + "text" : "Nutrition facts", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : true, + "text" : "As sold
for 100 g / 100 ml", + "text_for_small_screens" : "100g", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : false, + "text" : "As sold
per serving (10 g)", + "text_for_small_screens" : "per serving", + "type" : "text" + }, + { + "column_group_id" : "comparisons", + "shown_by_default" : true, + "text" : "Compared to: Snacks", + "type" : "text" + } + ], + "id" : "nutrition_facts_table", + "rows" : [ + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fat" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Saturated fat" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Carbohydrates" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Sugars" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fiber" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Proteins" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Salt" + }, + { + "text" : "?" + }, + { + "text" : "?" + }, + { + "text" : "" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fruits‚ vegetables‚ nuts and rapeseed‚ walnut and olive oils (estimate from ingredients list analysis)" + }, + { + "text" : "25 %" + }, + { + "text" : "25 %" + }, + { + "text" : "" + } + ] + } + ], + "title" : "Nutrition facts" + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/scale-balance.svg", + "title" : "Nutrition facts" + }, + "topics" : [ + "health" + ] + }, + "origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The origins of the ingredients of this product are not indicated.

\n If they are indicated on the packaging, you can modify the product sheet and add them.

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Missing origins of ingredients information", + "title" : "Origins of ingredients" + }, + "topics" : [ + "environment" + ] + }, + "packaging_recycling" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The information about the packaging of this product is not filled in.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "evaluation" : "neutral", + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "title" : "Missing packaging information for this product" + }, + "topics" : [ + "environment" + ] + }, + "palm_oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Tropical forests in Asia, Africa and Latin America are destroyed to create and expand oil palm tree plantations. The deforestation contributes to climate change, and it endangers species such as the orangutan, the pigmy elephant and the Sumatran rhino.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "subtitle" : "Drives deforestation and threatens species such as the orangutan", + "title" : "Contains palm oil" + }, + "topics" : [ + "environment" + ] + }, + "root" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "health_card" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "environment_card" + } + } + ], + "expanded" : true, + "type" : "root" + }, + "serving_size" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Serving size:\n 10 g\n " + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + } + } + }, + "result" : { + "id" : "product_found", + "lc_name" : "Product found", + "name" : "Product found" + }, + "status" : "success", + "warnings" : [] +} From 09bb5a3875e3128d1a5fcf83926a3c964b8aca93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Thu, 17 Nov 2022 15:16:30 +0100 Subject: [PATCH 2/3] lint --- tests/integration/api_v3_product_read.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/api_v3_product_read.t b/tests/integration/api_v3_product_read.t index a55d10817b03c..0cce139b48be2 100644 --- a/tests/integration/api_v3_product_read.t +++ b/tests/integration/api_v3_product_read.t @@ -84,7 +84,7 @@ my $tests_ref = [ path => '/api/v3/product/200000000034', query_string => '?fields=attribute_groups&lc=fr', expected_status_code => 200, - }, + }, { test_case => 'get-knowledge-panels', method => 'GET', @@ -98,7 +98,7 @@ my $tests_ref = [ path => '/api/v3/product/200000000034', query_string => '?fields=knowledge_panels&lc=fr', expected_status_code => 200, - }, + }, ]; execute_api_tests(__FILE__, $tests_ref); From 1f31ed67e1fce7f3ddc1ce0c0ac4cca8c6f0026f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Thu, 17 Nov 2022 16:23:03 +0100 Subject: [PATCH 3/3] new tests --- tests/integration/api_v2_product_read.t | 28 + .../get-attribute-groups-fr.json | 302 +++++ .../get-attribute-groups.json | 302 +++++ .../get-knowledge-panels-fr.json | 1043 +++++++++++++++++ .../get-knowledge-panels.json | 1043 +++++++++++++++++ .../get-existing-product.json | 1 - .../get-knowledge-panels-fr.json | 30 - .../get-knowledge-panels.json | 30 - 8 files changed, 2718 insertions(+), 61 deletions(-) create mode 100644 tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups-fr.json create mode 100644 tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups.json create mode 100644 tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json create mode 100644 tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json diff --git a/tests/integration/api_v2_product_read.t b/tests/integration/api_v2_product_read.t index eea17fb5876fe..0737337957519 100644 --- a/tests/integration/api_v2_product_read.t +++ b/tests/integration/api_v2_product_read.t @@ -64,6 +64,34 @@ my $tests_ref = [ query_string => '?fields=product_name,categories_tags,categories_tags_en', expected_status_code => 200, }, + { + test_case => 'get-attribute-groups', + method => 'GET', + path => '/api/v2/product/200000000034', + query_string => '?fields=attribute_groups', + expected_status_code => 200, + }, + { + test_case => 'get-attribute-groups-fr', + method => 'GET', + path => '/api/v2/product/200000000034', + query_string => '?fields=attribute_groups&lc=fr', + expected_status_code => 200, + }, + { + test_case => 'get-knowledge-panels', + method => 'GET', + path => '/api/v2/product/200000000034', + query_string => '?fields=knowledge_panels', + expected_status_code => 200, + }, + { + test_case => 'get-knowledge-panels-fr', + method => 'GET', + path => '/api/v2/product/200000000034', + query_string => '?fields=knowledge_panels&lc=fr', + expected_status_code => 200, + }, ]; execute_api_tests(__FILE__, $tests_ref); diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups-fr.json b/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups-fr.json new file mode 100644 index 0000000000000..5c89417635d43 --- /dev/null +++ b/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups-fr.json @@ -0,0 +1,302 @@ +{ + "code" : "200000000034", + "product" : { + "attribute_groups" : [ + { + "attributes" : [ + { + "description" : "", + "description_short" : "Données manquantes pour calculer le Nutri-Score", + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "id" : "nutriscore", + "match" : 0, + "name" : "Nutri-Score", + "panel_id" : "nutriscore", + "status" : "unknown", + "title" : "Nutri-Score inconnu" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-salt-unknown.svg", + "id" : "low_salt", + "missing" : "Données nutritionnelles manquantes", + "name" : "Sel", + "status" : "unknown", + "title" : "Sel en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-fat-unknown.svg", + "id" : "low_fat", + "missing" : "Données nutritionnelles manquantes", + "name" : "Matières grasses", + "status" : "unknown", + "title" : "Matières grasses en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-sugars-unknown.svg", + "id" : "low_sugars", + "missing" : "Données nutritionnelles manquantes", + "name" : "Sucres", + "status" : "unknown", + "title" : "Sucres en quantité inconnue" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-saturated-fat-unknown.svg", + "id" : "low_saturated_fat", + "missing" : "Données nutritionnelles manquantes", + "name" : "Acides gras saturés", + "status" : "unknown", + "title" : "Acides gras saturés en quantité inconnue" + } + ], + "id" : "nutritional_quality", + "name" : "Qualité nutritionnelle" + }, + { + "attributes" : [ + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-gluten.svg", + "id" : "allergens_no_gluten", + "match" : 100, + "name" : "Gluten", + "status" : "known", + "title" : "Ne contient pas : Gluten" + }, + { + "debug" : "en:milk in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-milk.svg", + "id" : "allergens_no_milk", + "match" : 0, + "name" : "Lait", + "status" : "known", + "title" : "Contient : Lait" + }, + { + "debug" : "en:eggs in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-eggs.svg", + "id" : "allergens_no_eggs", + "match" : 0, + "name" : "Œufs", + "status" : "known", + "title" : "Contient : Œufs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-nuts.svg", + "id" : "allergens_no_nuts", + "match" : 100, + "name" : "Fruits à coque", + "status" : "known", + "title" : "Ne contient pas : Fruits à coque" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-peanuts.svg", + "id" : "allergens_no_peanuts", + "match" : 100, + "name" : "Arachides", + "status" : "known", + "title" : "Ne contient pas : Arachides" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sesame-seeds.svg", + "id" : "allergens_no_sesame_seeds", + "match" : 100, + "name" : "Graines de sésame", + "status" : "known", + "title" : "Ne contient pas : Graines de sésame" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-soybeans.svg", + "id" : "allergens_no_soybeans", + "match" : 100, + "name" : "Soja", + "status" : "known", + "title" : "Ne contient pas : Soja" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-celery.svg", + "id" : "allergens_no_celery", + "match" : 100, + "name" : "Céleri", + "status" : "known", + "title" : "Ne contient pas : Céleri" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-mustard.svg", + "id" : "allergens_no_mustard", + "match" : 100, + "name" : "Moutarde", + "status" : "known", + "title" : "Ne contient pas : Moutarde" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-lupin.svg", + "id" : "allergens_no_lupin", + "match" : 100, + "name" : "Lupin", + "status" : "known", + "title" : "Ne contient pas : Lupin" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-fish.svg", + "id" : "allergens_no_fish", + "match" : 100, + "name" : "Poisson", + "status" : "known", + "title" : "Ne contient pas : Poisson" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-crustaceans.svg", + "id" : "allergens_no_crustaceans", + "match" : 100, + "name" : "Crustacés", + "status" : "known", + "title" : "Ne contient pas : Crustacés" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-molluscs.svg", + "id" : "allergens_no_molluscs", + "match" : 100, + "name" : "Mollusques", + "status" : "known", + "title" : "Ne contient pas : Mollusques" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sulphur-dioxide-and-sulphites.svg", + "id" : "allergens_no_sulphur_dioxide_and_sulphites", + "match" : 100, + "name" : "Anhydride sulfureux et sulfites", + "status" : "known", + "title" : "Ne contient pas : Anhydride sulfureux et sulfites" + } + ], + "id" : "allergens", + "name" : "Allergènes", + "warning" : "Il est toujours possible que les données sur les allergènes soient manquantes, incomplètes, incorrectes ou que la composition du produit ait changé. Si vous êtes allergique, vérifiez toujours les informations sur l'emballage réel du produit." + }, + { + "attributes" : [ + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/non-vegan.svg", + "id" : "vegan", + "match" : 0, + "name" : "Végétalien", + "panel_id" : "ingredients_analysis_en:non-vegan", + "status" : "known", + "title" : "Non végétalien" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/vegetarian.svg", + "id" : "vegetarian", + "match" : 100, + "name" : "Végétarien", + "panel_id" : "ingredients_analysis_en:vegetarian", + "status" : "known", + "title" : "Végétarien" + }, + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-palm-oil.svg", + "id" : "palm_oil_free", + "match" : 0, + "name" : "Sans huile de palme", + "panel_id" : "ingredients_analysis_en:palm-oil", + "status" : "known", + "title" : "Huile de palme" + } + ], + "id" : "ingredients_analysis", + "name" : "Ingrédients" + }, + { + "attributes" : [ + { + "description" : "", + "description_short" : "Aliments transformés", + "grade" : "b", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "id" : "nova", + "match" : 75, + "name" : "Groupe NOVA", + "panel_id" : "nova", + "status" : "known", + "title" : "NOVA 3" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/0-additives.svg", + "id" : "additives", + "match" : 100, + "name" : "Additifs", + "panel_id" : "additives", + "status" : "known", + "title" : "Sans additifs" + } + ], + "id" : "processing", + "name" : "Transformation des aliments" + }, + { + "attributes" : [ + { + "description" : "L'agriculture biologique vise à protéger l'environnement et à conserver la biodiversité en prohibant ou limitant l'utilisation d'engrais synthétiques, de pesticides et d'additifs alimentaires.", + "description_short" : "Encourage la durabilité écologique et la biodiversité.", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/organic.svg", + "id" : "labels_organic", + "match" : 100, + "name" : "Agriculture biologique", + "status" : "known", + "title" : "Produit bio" + }, + { + "description" : "Quand vous achetez des produits du commerce équitable, les producteurs dans les pays en développement sont payés un prix plus haut et plus équitable, ce qui les aide à atteindre des plus hauts standards sociaux et environnementaux et à les conserver.", + "description_short" : "Les produits du commerce équitable aident les producteurs des pays en voie de développement.", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/not-fair-trade.svg", + "id" : "labels_fair_trade", + "match" : 0, + "name" : "Commerce équitable", + "status" : "known", + "title" : "Ne provient pas du commerce équitable" + } + ], + "id" : "labels", + "name" : "Labels" + } + ] + }, + "status" : 1, + "status_verbose" : "product found" +} diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups.json b/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups.json new file mode 100644 index 0000000000000..3443f467ccac3 --- /dev/null +++ b/tests/integration/expected_test_results/api_v2_product_read/get-attribute-groups.json @@ -0,0 +1,302 @@ +{ + "code" : "200000000034", + "product" : { + "attribute_groups" : [ + { + "attributes" : [ + { + "description" : "", + "description_short" : "Missing data to compute the Nutri-Score", + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "id" : "nutriscore", + "match" : 0, + "name" : "Nutri-Score", + "panel_id" : "nutriscore", + "status" : "unknown", + "title" : "Nutri-Score unknown" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-salt-unknown.svg", + "id" : "low_salt", + "missing" : "Missing nutrition facts", + "name" : "Salt", + "status" : "unknown", + "title" : "Salt in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-fat-unknown.svg", + "id" : "low_fat", + "missing" : "Missing nutrition facts", + "name" : "Fat", + "status" : "unknown", + "title" : "Fat in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-sugars-unknown.svg", + "id" : "low_sugars", + "missing" : "Missing nutrition facts", + "name" : "Sugars", + "status" : "unknown", + "title" : "Sugars in unknown quantity" + }, + { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutrient-level-saturated-fat-unknown.svg", + "id" : "low_saturated_fat", + "missing" : "Missing nutrition facts", + "name" : "Saturated fat", + "status" : "unknown", + "title" : "Saturated fat in unknown quantity" + } + ], + "id" : "nutritional_quality", + "name" : "Nutritional quality" + }, + { + "attributes" : [ + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-gluten.svg", + "id" : "allergens_no_gluten", + "match" : 100, + "name" : "Gluten", + "status" : "known", + "title" : "Does not contain: Gluten" + }, + { + "debug" : "en:milk in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-milk.svg", + "id" : "allergens_no_milk", + "match" : 0, + "name" : "Milk", + "status" : "known", + "title" : "Contains: Milk" + }, + { + "debug" : "en:eggs in allergens", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-eggs.svg", + "id" : "allergens_no_eggs", + "match" : 0, + "name" : "Eggs", + "status" : "known", + "title" : "Contains: Eggs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-nuts.svg", + "id" : "allergens_no_nuts", + "match" : 100, + "name" : "Nuts", + "status" : "known", + "title" : "Does not contain: Nuts" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-peanuts.svg", + "id" : "allergens_no_peanuts", + "match" : 100, + "name" : "Peanuts", + "status" : "known", + "title" : "Does not contain: Peanuts" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sesame-seeds.svg", + "id" : "allergens_no_sesame_seeds", + "match" : 100, + "name" : "Sesame seeds", + "status" : "known", + "title" : "Does not contain: Sesame seeds" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-soybeans.svg", + "id" : "allergens_no_soybeans", + "match" : 100, + "name" : "Soybeans", + "status" : "known", + "title" : "Does not contain: Soybeans" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-celery.svg", + "id" : "allergens_no_celery", + "match" : 100, + "name" : "Celery", + "status" : "known", + "title" : "Does not contain: Celery" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-mustard.svg", + "id" : "allergens_no_mustard", + "match" : 100, + "name" : "Mustard", + "status" : "known", + "title" : "Does not contain: Mustard" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-lupin.svg", + "id" : "allergens_no_lupin", + "match" : 100, + "name" : "Lupin", + "status" : "known", + "title" : "Does not contain: Lupin" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-fish.svg", + "id" : "allergens_no_fish", + "match" : 100, + "name" : "Fish", + "status" : "known", + "title" : "Does not contain: Fish" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-crustaceans.svg", + "id" : "allergens_no_crustaceans", + "match" : 100, + "name" : "Crustaceans", + "status" : "known", + "title" : "Does not contain: Crustaceans" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-molluscs.svg", + "id" : "allergens_no_molluscs", + "match" : 100, + "name" : "Molluscs", + "status" : "known", + "title" : "Does not contain: Molluscs" + }, + { + "debug" : "4 ingredients (0 unknown)", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/no-sulphur-dioxide-and-sulphites.svg", + "id" : "allergens_no_sulphur_dioxide_and_sulphites", + "match" : 100, + "name" : "Sulphur dioxide and sulphites", + "status" : "known", + "title" : "Does not contain: Sulphur dioxide and sulphites" + } + ], + "id" : "allergens", + "name" : "Allergens", + "warning" : "There is always a possibility that data about allergens may be missing, incomplete, incorrect or that the product's composition has changed. If you are allergic, always check the information on the actual product packaging." + }, + { + "attributes" : [ + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/non-vegan.svg", + "id" : "vegan", + "match" : 0, + "name" : "Vegan", + "panel_id" : "ingredients_analysis_en:non-vegan", + "status" : "known", + "title" : "Non-vegan" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/vegetarian.svg", + "id" : "vegetarian", + "match" : 100, + "name" : "Vegetarian", + "panel_id" : "ingredients_analysis_en:vegetarian", + "status" : "known", + "title" : "Vegetarian" + }, + { + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/contains-palm-oil.svg", + "id" : "palm_oil_free", + "match" : 0, + "name" : "Palm oil free", + "panel_id" : "ingredients_analysis_en:palm-oil", + "status" : "known", + "title" : "Palm oil" + } + ], + "id" : "ingredients_analysis", + "name" : "Ingredients" + }, + { + "attributes" : [ + { + "description" : "", + "description_short" : "Processed foods", + "grade" : "b", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "id" : "nova", + "match" : 75, + "name" : "NOVA group", + "panel_id" : "nova", + "status" : "known", + "title" : "NOVA 3" + }, + { + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/0-additives.svg", + "id" : "additives", + "match" : 100, + "name" : "Additives", + "panel_id" : "additives", + "status" : "known", + "title" : "Without additives" + } + ], + "id" : "processing", + "name" : "Food processing" + }, + { + "attributes" : [ + { + "description" : "Organic farming aims to protect the environment and to conserve biodiversity by prohibiting or limiting the use of synthetic fertilizers, pesticides and food additives.", + "description_short" : "Promotes ecological sustainability and biodiversity.", + "grade" : "a", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/organic.svg", + "id" : "labels_organic", + "match" : 100, + "name" : "Organic farming", + "status" : "known", + "title" : "Organic product" + }, + { + "description" : "When you buy fair trade products, producers in developing countries are paid an higher and fairer price, which helps them improve and sustain higher social and often environmental standards.", + "description_short" : "Fair trade products help producers in developing countries.", + "grade" : "e", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/not-fair-trade.svg", + "id" : "labels_fair_trade", + "match" : 0, + "name" : "Fair trade", + "status" : "known", + "title" : "Not a fair trade product" + } + ], + "id" : "labels", + "name" : "Labels" + } + ] + }, + "status" : 1, + "status_verbose" : "product found" +} 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 new file mode 100644 index 0000000000000..361b5e7c99964 --- /dev/null +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json @@ -0,0 +1,1043 @@ +{ + "code" : "200000000034", + "product" : { + "knowledge_panels" : { + "carbon_footprint" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Le chiffre d'émission carbone est issu de la base de données Agribalyse de l'ADEME, pour la catégorie : \n Biscuit sec, sans précision\n (Source : Base de données ADEME Agribalyse)\n

\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Etape", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_carbon_impact_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 86.4490565865388, + "text" : "86.4 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Transformation" + }, + { + "percent" : 7.40512661892125, + "text" : "7.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Conditionnement" + }, + { + "percent" : 2.44549029302522, + "text" : "2.4 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transport" + }, + { + "percent" : 3.04594655954887, + "text" : "3.0 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 0.655173174089646, + "text" : "0.7 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consommation" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Détail des impacts par étapes du cycle de vie" + } + } + ], + "evaluation" : "average", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/car.svg", + "subtitle" : "444 g de CO² pour 100g de produit", + "title" : "Équivaut à parcourir 2.3 km dans une voiture à essence" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "L'Eco-Score est un score expérimental qui synthétise les impacts environnementaux des produits alimentaires." + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n L'Eco-Score a été initialement conçu pour la France et est en cours d'extension à d'autres pays européens. La formule de l'Eco-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise et mieux adaptée à chaque pays.\n \n ", + "type" : "note" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_agribalyse" + ], + "title" : "Analyse du cycle de vie" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_origins_of_ingredients", + "ecoscore_threatened_species", + "ecoscore_packaging" + ], + "title" : "Bonus et malus" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_total" + ], + "title" : "Eco-Score pour ce produit" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

En savoir plus sur l'Eco-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/ecoscore-d.svg", + "title" : "Éco-Score D - Impact environnemental élevé", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_agribalyse" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Catégorie : \n Biscuit sec, sans précision\n

\n
    \n
  • \n Score environnemental PEF : 0.45\n (plus le score est bas, plus l'impact est faible)\n
  • \n
  • \n dont impact sur le changement climatique : 4.44\n kg CO2 eq/kg de produit\n
  • \n
\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Etape", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_lca_impacts_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 80.3235532201964, + "text" : "80.3 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Transformation" + }, + { + "percent" : 11.4323646504281, + "text" : "11.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Conditionnement" + }, + { + "percent" : 3.66880158328128, + "text" : "3.7 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transport" + }, + { + "percent" : 2.37118922373698, + "text" : "2.4 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 2.20492840669224, + "text" : "2.2 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consommation" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Détail des impacts par étapes du cycle de vie" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "c", + "subtitle" : "Catégorie : Biscuit sec, sans précision", + "title" : "Impact moyen des produits de la même catégorie : C (Score: 58/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les origines des ingrédients de ce produit ne sont pas renseignées.

\n Si elles sont indiquées sur l'emballage, vous pouvez modifier la fiche produit et les ajouter.

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Malus : -5", + "title" : "Informations manquantes sur les origines des ingrédients" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_packaging" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les informations sur l'emballage de ce produit ne sont pas renseignées.\n ", + "type" : "warning" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n Pour un calcul plus précis de l'Eco-Score, vous pouvez modifier la fiche produit et les ajouter.\n

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "subtitle" : "Malus : -15", + "title" : "Informations d'emballage manquantes pour ce produit" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_production_system" : { + "evaluation" : "neutral", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "title" : "Pas de labels avec des avantages environnementaux" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_threatened_species" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Contient de l'huile de palme

\n

Les forêts tropicales d'Asie, d'Afrique et d'Amérique latine sont détruites pour créer et étendre les plantations de palmiers à huile. La déforestation contribue au changement climatique et met en danger des espèces telles que l'orang-outan, l'éléphant pygmée et le rhinocéros de Sumatra.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/monkey_unhappy.svg", + "subtitle" : "Malus : -10", + "title" : "Ingrédients qui menacent des espèces" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_total" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Score d'analyse du cycle de vie : 58
\n Somme des bonus et malus :\n \n -30\n

\n Score final : 28/100\n \n ", + "type" : "summary" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "subtitle" : "Produit : Some product - 100 g", + "title" : "Impact pour ce produit: D (Score: 28/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "environment_card" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ecoscore" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "carbon_footprint" + ], + "title" : "Empreinte carbone" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "packaging_recycling", + "panel_ids" : [ + "packaging_recycling" + ], + "title" : "Conditionnement" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "origins_of_ingredients" + ], + "title" : "Transport" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "palm_oil" + ], + "title" : "Espèces menacées" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Environnement" + }, + "topics" : [ + "environment" + ], + "type" : "card" + }, + "health_card" : { + "elements" : [ + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "nutrition", + "panel_ids" : [ + "nutriscore" + ], + "title" : "Nutrition", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nutrition_facts_table", + "serving_size" + ], + "title" : "" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "ingredients", + "panel_ids" : [ + "ingredients" + ], + "title" : "Ingrédients", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nova" + ], + "title" : "Transformation des aliments" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ingredients_analysis", + "ingredients_analysis_details" + ], + "title" : "Analyse des ingrédients" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Santé" + }, + "topics" : [ + "health" + ], + "type" : "card" + }, + "ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "edit_field_id" : "ingredients_text_en", + "edit_field_type" : "ingredients_text", + "edit_field_value" : "apple, milk, eggs, palm oil", + "html" : "apple, milk, eggs, palm oil", + "language" : "Anglais", + "lc" : "en" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "Allergènes : \n Œufs, Lait\n " + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/ingredients.svg", + "title" : "4 ingrédients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:palm-oil" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:non-vegan" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:vegetarian" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "L'analyse est basée uniquement sur les ingrédients listés et ne prend pas en compte les méthodes de fabrication." + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + }, + "ingredients_analysis_details" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "apple, milk, eggs, palm oil" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "
    \n
  1. apple -> en:apple - vegan: yes - vegetarian: yes - percent_min: 25 - percent_max: 100
  2. \n
  3. milk -> en:milk - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 50
  4. \n
  5. eggs -> en:egg - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 33.3333333333333
  6. \n
  7. palm oil -> en:palm-oil - vegan: yes - vegetarian: yes - from_palm_oil: yes - percent_min: 0 - percent_max: 25
  8. \n
\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/off-magnifying-glass.svg", + "title" : "Détail de l'analyse des ingrédients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:non-vegan" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingrédients non végétaliens :\n Lait, Œuf\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/leaf.svg", + "title" : "Non végétalien" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:palm-oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingrédients contenant de l'huile de palme :\n Huile de palme\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "title" : "Huile de palme" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:vegetarian" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Aucun ingrédient non végétarien détecté\n \n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "good", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/vegetarian.svg", + "title" : "Végétarien" + }, + "topics" : [ + "health" + ] + }, + "nova" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n\n \n \n

Éléments qui indiquent que le produit est dans le groupe 3 - Aliments transformés :

\n
    \n \n
  • Catégorie : Snacks sucrés
  • \n \n
\n \n \n\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Les produits alimentaires sont classés en 4 groupes selon leur degré de transformation :

\n
    \n
  1. Aliments non transformés ou minimalement transformés
  2. \n
  3. Ingrédients culinaires transformés
  4. \n
  5. Aliments transformés
  6. \n
  7. Aliments ultra-transformés
  8. \n
\n
\n

La détermination du groupe est basée sur la catégorie du produit et sur les ingrédients qu'il contient.

\n

En savoir plus sur la classification NOVA

\n" + } + } + ], + "level" : "info", + "title_element" : { + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "title" : "Aliments transformés" + }, + "topics" : [ + "health" + ] + }, + "nutriscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "Les données nutritionnelles du produit doivent être spécifiées afin de calculer le Nutri-Score.\n ", + "type" : "warning" + } + }, + { + "action_element" : { + "actions" : [ + "add_nutrition_facts" + ], + "html" : "Pourriez-vous ajouter les informations nécessaires pour calculer le Nutri-Score ?" + }, + "element_type" : "action" + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

En savoir plus sur le Nutri-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "subtitle" : "Données nutritionnelles manquantes", + "title" : "Données manquantes pour calculer le Nutri-Score", + "type" : "grade" + }, + "topics" : [ + "health" + ] + }, + "nutrition_facts_table" : { + "elements" : [ + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "style" : "max-width:15rem", + "text" : "Tableau nutritionnel", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : true, + "text" : "Tel que vendu
pour 100 g / 100 ml", + "text_for_small_screens" : "100g", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : false, + "text" : "Tel que vendu
par portion (10 g)", + "text_for_small_screens" : "par portion", + "type" : "text" + } + ], + "id" : "nutrition_facts_table", + "rows" : [ + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Matières grasses" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Acides gras saturés" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Glucides" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Sucres" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fibres alimentaires" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Protéines" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Sel" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fruits‚ légumes‚ noix et huiles de colza‚ noix et olive (estimation par analyse de la liste des ingrédients)" + }, + { + "text" : "25 %" + }, + { + "text" : "25 %" + } + ] + } + ], + "title" : "Tableau nutritionnel" + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/scale-balance.svg", + "title" : "Tableau nutritionnel" + }, + "topics" : [ + "health" + ] + }, + "origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les origines des ingrédients de ce produit ne sont pas renseignées.

\n Si elles sont indiquées sur l'emballage, vous pouvez modifier la fiche produit et les ajouter.

\n Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre les informations avec notre plateforme gratuite pour les producteurs.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Informations manquantes sur les origines des ingrédients", + "title" : "Origines des ingrédients" + }, + "topics" : [ + "environment" + ] + }, + "packaging_recycling" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Les informations sur l'emballage de ce produit ne sont pas renseignées.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "evaluation" : "neutral", + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "title" : "Informations d'emballage manquantes pour ce produit" + }, + "topics" : [ + "environment" + ] + }, + "palm_oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Les forêts tropicales d'Asie, d'Afrique et d'Amérique latine sont détruites pour créer et étendre les plantations de palmiers à huile. La déforestation contribue au changement climatique et met en danger des espèces telles que l'orang-outan, l'éléphant pygmée et le rhinocéros de Sumatra.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "subtitle" : "Stimule la déforestation et menace des espèces telles que l'orang-outan", + "title" : "Contient de l'huile de palme" + }, + "topics" : [ + "environment" + ] + }, + "root" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "health_card" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "environment_card" + } + } + ], + "expanded" : true, + "type" : "root" + }, + "serving_size" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Taille d'une portion :\n 10 g\n " + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + } + } + }, + "status" : 1, + "status_verbose" : "product found" +} 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 new file mode 100644 index 0000000000000..ad0bbb68960f5 --- /dev/null +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json @@ -0,0 +1,1043 @@ +{ + "code" : "200000000034", + "product" : { + "knowledge_panels" : { + "carbon_footprint" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

The carbon emission figure comes from ADEME's Agribalyse database, for the category: \n Biscuit (cookie)\n (Source: ADEME Agribalyse Database)\n

\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Stage", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_carbon_impact_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 86.4490565865388, + "text" : "86.4 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Processing" + }, + { + "percent" : 7.40512661892125, + "text" : "7.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Packaging" + }, + { + "percent" : 2.44549029302522, + "text" : "2.4 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transportation" + }, + { + "percent" : 3.04594655954887, + "text" : "3.0 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 0.655173174089646, + "text" : "0.7 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consumption" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Details of the impacts by stages of the life cycle" + } + } + ], + "evaluation" : "average", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/car.svg", + "subtitle" : "444 g CO² per 100g of product", + "title" : "Equal to driving 2.3 km in a petrol car" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "The Eco-Score is an experimental score that summarizes the environmental impacts of food products." + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n The Eco-Score was initially developped for France and it is being extended to other European countries. The Eco-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country.\n \n ", + "type" : "note" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_agribalyse" + ], + "title" : "Life cycle analysis" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_origins_of_ingredients", + "ecoscore_threatened_species", + "ecoscore_packaging" + ], + "title" : "Bonuses and maluses" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ecoscore_total" + ], + "title" : "Eco-Score for this product" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Learn more about the Eco-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/ecoscore-d.svg", + "title" : "Eco-Score D - High environmental impact", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_agribalyse" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Category: \n Biscuit (cookie)\n

\n
    \n
  • \n PEF environmental score: 0.45\n (the lower the score, the lower the impact)\n
  • \n
  • \n including impact on climate change: 4.44\n kg CO2 eq/kg of product\n
  • \n
\n ", + "type" : "summary" + } + }, + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "text" : "Stage", + "type" : "text" + }, + { + "text" : "Impact", + "type" : "percent" + } + ], + "id" : "ecoscore_lca_impacts_by_stages_table", + "rows" : [ + { + "id" : "agriculture", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "text" : "Agriculture" + }, + { + "percent" : 80.3235532201964, + "text" : "80.3 %" + } + ] + }, + { + "id" : "processing", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/processing.svg", + "text" : "Processing" + }, + { + "percent" : 11.4323646504281, + "text" : "11.4 %" + } + ] + }, + { + "id" : "packaging", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "text" : "Packaging" + }, + { + "percent" : 3.66880158328128, + "text" : "3.7 %" + } + ] + }, + { + "id" : "transportation", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/transportation.svg", + "text" : "Transportation" + }, + { + "percent" : 2.37118922373698, + "text" : "2.4 %" + } + ] + }, + { + "id" : "distribution", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/distribution.svg", + "text" : "Distribution" + }, + { + "percent" : 2.20492840669224, + "text" : "2.2 %" + } + ] + }, + { + "id" : "consumption", + "values" : [ + { + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/consumption.svg", + "text" : "Consumption" + }, + { + "percent" : 0, + "text" : "0.0 %" + } + ] + } + ], + "table_type" : "percents", + "title" : "Details of the impacts by stages of the life cycle" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "c", + "subtitle" : "Category: Biscuit (cookie)", + "title" : "Average impact of products of the same category: C (Score: 58/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The origins of the ingredients of this product are not indicated.

\n If they are indicated on the packaging, you can modify the product sheet and add them.

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Malus: -5", + "title" : "Missing origins of ingredients information" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_packaging" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The information about the packaging of this product is not filled in.\n ", + "type" : "warning" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n For a more precise calculation of the Eco-Score, you can modify the product page and add them.\n

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "subtitle" : "Malus: -15", + "title" : "Missing packaging information for this product" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_production_system" : { + "evaluation" : "neutral", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/agriculture.svg", + "title" : "No labels with environmental benefits" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_threatened_species" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Contains palm oil

\n

Tropical forests in Asia, Africa and Latin America are destroyed to create and expand oil palm tree plantations. The deforestation contributes to climate change, and it endangers species such as the orangutan, the pigmy elephant and the Sumatran rhino.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/monkey_unhappy.svg", + "subtitle" : "Malus: -10", + "title" : "Ingredients that threatens species" + }, + "topics" : [ + "environment" + ] + }, + "ecoscore_total" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Life cycle analysis score: 58
\n Sum of bonuses and maluses:\n \n -30\n

\n Final score: 28/100\n \n ", + "type" : "summary" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "d", + "subtitle" : "Product: Some product - 100 g", + "title" : "Impact for this product: D (Score: 28/100)", + "type" : "grade" + }, + "topics" : [ + "environment" + ] + }, + "environment_card" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ecoscore" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "carbon_footprint" + ], + "title" : "Carbon footprint" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "packaging_recycling", + "panel_ids" : [ + "packaging_recycling" + ], + "title" : "Packaging" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "origins_of_ingredients" + ], + "title" : "Transportation" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "palm_oil" + ], + "title" : "Threatened species" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Environment" + }, + "topics" : [ + "environment" + ], + "type" : "card" + }, + "health_card" : { + "elements" : [ + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "nutrition", + "panel_ids" : [ + "nutriscore" + ], + "title" : "Nutrition", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nutrition_facts_table", + "serving_size" + ], + "title" : "" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_group_id" : "ingredients", + "panel_ids" : [ + "ingredients" + ], + "title" : "Ingredients", + "type" : "subcard" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "nova" + ], + "title" : "Food processing" + } + }, + { + "element_type" : "panel_group", + "panel_group_element" : { + "panel_ids" : [ + "ingredients_analysis", + "ingredients_analysis_details" + ], + "title" : "Ingredients analysis" + } + } + ], + "expanded" : true, + "title_element" : { + "title" : "Health" + }, + "topics" : [ + "health" + ], + "type" : "card" + }, + "ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "edit_field_id" : "ingredients_text_en", + "edit_field_type" : "ingredients_text", + "edit_field_value" : "apple, milk, eggs, palm oil", + "html" : "apple, milk, eggs, palm oil", + "language" : "English", + "lc" : "en" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "Allergens: \n Eggs, Milk\n " + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/ingredients.svg", + "title" : "4 ingredients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:palm-oil" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:non-vegan" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "ingredients_analysis_en:vegetarian" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "The analysis is based solely on the ingredients listed and does not take into account processing methods." + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + }, + "ingredients_analysis_details" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "apple, milk, eggs, palm oil" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "
    \n
  1. apple -> en:apple - vegan: yes - vegetarian: yes - percent_min: 25 - percent_max: 100
  2. \n
  3. milk -> en:milk - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 50
  4. \n
  5. eggs -> en:egg - vegan: no - vegetarian: yes - percent_min: 0 - percent_max: 33.3333333333333
  6. \n
  7. palm oil -> en:palm-oil - vegan: yes - vegetarian: yes - from_palm_oil: yes - percent_min: 0 - percent_max: 25
  8. \n
\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/off-magnifying-glass.svg", + "title" : "Details of the analysis of the ingredients" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:non-vegan" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Non-vegan ingredients:\n Milk, Egg\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/leaf.svg", + "title" : "Non-vegan" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:palm-oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n Ingredients that contain palm oil:\n Palm oil\n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "title" : "Palm oil" + }, + "topics" : [ + "health" + ] + }, + "ingredients_analysis_en:vegetarian" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n \n No non-vegetarian ingredients detected\n \n \n ", + "type" : "summary" + } + } + ], + "evaluation" : "good", + "level" : "info", + "size" : "small", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_size" : "small", + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/vegetarian.svg", + "title" : "Vegetarian" + }, + "topics" : [ + "health" + ] + }, + "nova" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n\n \n \n

Elements that indicate the product is in the 3 - Processed foods group:

\n
    \n \n
  • Category: Sweet snacks
  • \n \n
\n \n \n\n" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Food products are classified into 4 groups according to their degree of processing:

\n
    \n
  1. Unprocessed or minimally processed foods
  2. \n
  3. Processed culinary ingredients
  4. \n
  5. Processed foods
  6. \n
  7. Ultra processed foods
  8. \n
\n
\n

The determination of the group is based on the category of the product and on the ingredients it contains.

\n

Learn more about the NOVA classification

\n" + } + } + ], + "level" : "info", + "title_element" : { + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nova-group-3.svg", + "title" : "Processed foods" + }, + "topics" : [ + "health" + ] + }, + "nutriscore" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "The nutrition facts of the product must be specified in order to compute the Nutri-Score.\n ", + "type" : "warning" + } + }, + { + "action_element" : { + "actions" : [ + "add_nutrition_facts" + ], + "html" : "Could you add the information needed to compute the Nutri-Score?" + }, + "element_type" : "action" + }, + { + "element_type" : "text", + "text_element" : { + "html" : "" + } + }, + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Learn more about the Nutri-Score

\n" + } + } + ], + "level" : "info", + "title_element" : { + "grade" : "unknown", + "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/nutriscore-unknown.svg", + "subtitle" : "Missing nutrition facts", + "title" : "Missing data to compute the Nutri-Score", + "type" : "grade" + }, + "topics" : [ + "health" + ] + }, + "nutrition_facts_table" : { + "elements" : [ + { + "element_type" : "table", + "table_element" : { + "columns" : [ + { + "style" : "max-width:15rem", + "text" : "Nutrition facts", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : true, + "text" : "As sold
for 100 g / 100 ml", + "text_for_small_screens" : "100g", + "type" : "text" + }, + { + "column_group_id" : "product", + "shown_by_default" : false, + "text" : "As sold
per serving (10 g)", + "text_for_small_screens" : "per serving", + "type" : "text" + } + ], + "id" : "nutrition_facts_table", + "rows" : [ + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fat" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Saturated fat" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Carbohydrates" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 1, + "style" : "max-width:15rem", + "text" : "Sugars" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fiber" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Proteins" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Salt" + }, + { + "text" : "?" + }, + { + "text" : "?" + } + ] + }, + { + "values" : [ + { + "level" : 0, + "style" : "max-width:15rem", + "text" : "Fruits‚ vegetables‚ nuts and rapeseed‚ walnut and olive oils (estimate from ingredients list analysis)" + }, + { + "text" : "25 %" + }, + { + "text" : "25 %" + } + ] + } + ], + "title" : "Nutrition facts" + } + } + ], + "evaluation" : "unknown", + "expand_for" : "large", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/scale-balance.svg", + "title" : "Nutrition facts" + }, + "topics" : [ + "health" + ] + }, + "origins_of_ingredients" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The origins of the ingredients of this product are not indicated.

\n If they are indicated on the packaging, you can modify the product sheet and add them.

\n If you are the manufacturer of this product, you can send us the information with our free platform for producers.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "expanded" : false, + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/public.svg", + "subtitle" : "Missing origins of ingredients information", + "title" : "Origins of ingredients" + }, + "topics" : [ + "environment" + ] + }, + "packaging_recycling" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n The information about the packaging of this product is not filled in.\n ", + "type" : "warning" + } + } + ], + "evaluation" : "unknown", + "level" : "info", + "title_element" : { + "evaluation" : "neutral", + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/packaging.svg", + "title" : "Missing packaging information for this product" + }, + "topics" : [ + "environment" + ] + }, + "palm_oil" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n

Tropical forests in Asia, Africa and Latin America are destroyed to create and expand oil palm tree plantations. The deforestation contributes to climate change, and it endangers species such as the orangutan, the pigmy elephant and the Sumatran rhino.

\n ", + "type" : "summary" + } + } + ], + "evaluation" : "bad", + "level" : "info", + "title_element" : { + "icon_color_from_evaluation" : true, + "icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/palm-oil.svg", + "subtitle" : "Drives deforestation and threatens species such as the orangutan", + "title" : "Contains palm oil" + }, + "topics" : [ + "environment" + ] + }, + "root" : { + "elements" : [ + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "health_card" + } + }, + { + "element_type" : "panel", + "panel_element" : { + "panel_id" : "environment_card" + } + } + ], + "expanded" : true, + "type" : "root" + }, + "serving_size" : { + "elements" : [ + { + "element_type" : "text", + "text_element" : { + "html" : "\n Serving size:\n 10 g\n " + } + } + ], + "expanded" : true, + "level" : "info", + "topics" : [ + "health" + ], + "type" : "inline" + } + } + }, + "status" : 1, + "status_verbose" : "product found" +} diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json b/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json index 64a76c0207253..99ce27e1ff616 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-existing-product.json @@ -69,7 +69,6 @@ "20xxxxxxxxxx", "2xxxxxxxxxxx" ], - "compared_to_category" : "en:snacks", "complete" : 0, "completeness" : 0.5, "correctors_tags" : [], 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 e0560302a2b8d..c88bdd57453d2 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 @@ -794,12 +794,6 @@ "text" : "Tel que vendu
par portion (10 g)", "text_for_small_screens" : "par portion", "type" : "text" - }, - { - "column_group_id" : "comparisons", - "shown_by_default" : true, - "text" : "Comparé à: Snacks", - "type" : "text" } ], "id" : "nutrition_facts_table", @@ -816,9 +810,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -834,9 +825,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -852,9 +840,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -870,9 +855,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -888,9 +870,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -906,9 +885,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -924,9 +900,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -942,9 +915,6 @@ }, { "text" : "25 %" - }, - { - "text" : "" } ] } 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 a961233b3c77b..da7820db7e6f3 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 @@ -794,12 +794,6 @@ "text" : "As sold
per serving (10 g)", "text_for_small_screens" : "per serving", "type" : "text" - }, - { - "column_group_id" : "comparisons", - "shown_by_default" : true, - "text" : "Compared to: Snacks", - "type" : "text" } ], "id" : "nutrition_facts_table", @@ -816,9 +810,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -834,9 +825,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -852,9 +840,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -870,9 +855,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -888,9 +870,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -906,9 +885,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -924,9 +900,6 @@ }, { "text" : "?" - }, - { - "text" : "" } ] }, @@ -942,9 +915,6 @@ }, { "text" : "25 %" - }, - { - "text" : "" } ] }