-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: facets for EU packager codes (EC) and for users (#9380)
- Fixes the normalization of the EC packager codes - Also fixes #9372 --------- Co-authored-by: Pierre Slamich <[email protected]> Co-authored-by: Alex Garel <[email protected]>
- Loading branch information
1 parent
1244f90
commit f8584ad
Showing
11 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
tests/integration/expected_test_results/facets/contributor-bob.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"count" : 1, | ||
"page" : 1, | ||
"page_count" : 1, | ||
"page_size" : 24, | ||
"products" : [ | ||
{ | ||
"product_name" : "Yogurt - Organic, Fair trade - Martinique" | ||
} | ||
], | ||
"skip" : 0 | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/integration/expected_test_results/facets/packager-code_fr-85-222-003-ce.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"count" : 1, | ||
"page" : 1, | ||
"page_count" : 1, | ||
"page_size" : 24, | ||
"products" : [ | ||
{ | ||
"emb_codes_tags" : [ | ||
"fr-85-222-003-ec" | ||
], | ||
"product_name" : "Apples - Organic, Fair trade - France" | ||
} | ||
], | ||
"skip" : 0 | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/integration/expected_test_results/facets/packager-code_fr-85-222-003-ec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"count" : 1, | ||
"page" : 1, | ||
"page_count" : 1, | ||
"page_size" : 24, | ||
"products" : [ | ||
{ | ||
"emb_codes_tags" : [ | ||
"fr-85-222-003-ec" | ||
], | ||
"product_name" : "Apples - Organic, Fair trade - France" | ||
} | ||
], | ||
"skip" : 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,18 @@ remove_all_products(); | |
|
||
wait_application_ready(); | ||
|
||
my $ua = new_client(); | ||
# First user | ||
|
||
my %create_user_args = (%default_user_form, (email => '[email protected]')); | ||
my $ua = new_client(); | ||
my %create_user_args = (%default_user_form, (email => '[email protected]', userid => "alice")); | ||
create_user($ua, \%create_user_args); | ||
|
||
# Second user | ||
|
||
my $ua2 = new_client(); | ||
my %create_user_args2 = (%default_user_form, (email => '[email protected]', userid => "bob")); | ||
create_user($ua2, \%create_user_args2); | ||
|
||
# Create some products to test facets | ||
|
||
my @products = ( | ||
|
@@ -130,6 +137,9 @@ my @products = ( | |
categories => "en:apples", | ||
labels => "en:organic,en:fair-trade", | ||
origins => "en:france", | ||
emb_codes => | ||
"FR 85.222.003 CE", # EU traceability code to check we normalize and query the code correctly (CE -> EC) | ||
countries => "France", | ||
), | ||
}, | ||
{ | ||
|
@@ -158,6 +168,22 @@ foreach my $product_ref (@products) { | |
edit_product($ua, $product_ref); | ||
} | ||
|
||
# Create another product with a different contributor | ||
|
||
edit_product( | ||
$ua2, | ||
{ | ||
%{dclone(\%empty_product_form)}, | ||
( | ||
code => '200000000013', | ||
product_name => "Yogurt - Organic, Fair trade - Martinique", | ||
categories => "en:yogurt", | ||
labels => "en:organic,en:fair-trade", | ||
origins => "en:france", | ||
), | ||
} | ||
); | ||
|
||
# Note: expected results are stored in json files, see execute_api_tests | ||
# We use the API with .json to test facets, in order to easily get the products that are returned | ||
my $tests_ref = [ | ||
|
@@ -254,11 +280,33 @@ my $tests_ref = [ | |
expected_status_code => 200, | ||
sort_products_by => 'product_name', | ||
}, | ||
# Contributor | ||
# EU packager code | ||
{ | ||
test_case => 'packager-code_fr-85-222-003-ce', | ||
method => 'GET', | ||
path => '/packager-code/fr-85-222-003-ce.json?fields=product_name,emb_codes_tags', | ||
expected_status_code => 200, | ||
sort_products_by => 'product_name', | ||
}, | ||
{ | ||
test_case => 'packager-code_fr-85-222-003-ec', # not normalized code (ec instead of ce) | ||
method => 'GET', | ||
path => '/packager-code/fr-85-222-003-ce.json?fields=product_name,emb_codes_tags', | ||
expected_status_code => 200, | ||
sort_products_by => 'product_name', | ||
}, | ||
# contributor facet | ||
{ | ||
test_case => 'contributor-alice', | ||
method => 'GET', | ||
path => '/contributor/alice.json?fields=product_name', | ||
expected_status_code => 200, | ||
sort_products_by => 'product_name', | ||
}, | ||
{ | ||
test_case => 'contributor_tests', | ||
test_case => 'contributor-bob', | ||
method => 'GET', | ||
path => '/contributor/tests.json?fields=product_name', | ||
path => '/contributor/bob.json?fields=product_name', | ||
expected_status_code => 200, | ||
sort_products_by => 'product_name', | ||
}, | ||
|