diff --git a/src/components/PriceCountChip.vue b/src/components/PriceCountChip.vue index 379f1025331..557f47ccde4 100644 --- a/src/components/PriceCountChip.vue +++ b/src/components/PriceCountChip.vue @@ -2,7 +2,7 @@ {{ $t('PriceCountChip.PriceCount', { count: count }) }} - {{ count }} + {{ count }} diff --git a/src/components/ProductCard.vue b/src/components/ProductCard.vue index c3caae8a702..bc615cf4ad9 100644 --- a/src/components/ProductCard.vue +++ b/src/components/ProductCard.vue @@ -7,7 +7,7 @@ -

{{ getProductTitle() }}

+

{{ getProductTitle() }}

diff --git a/src/views/Home.vue b/src/views/Home.vue index f5f2b4f8b02..40548be9c48 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -45,7 +45,7 @@ @@ -95,7 +95,7 @@ export default { methods: { getTodayPriceCount() { this.loading = true - return api.getPrices({ created__gte: utils.currentStartOfDay(), size: 2 }) + return api.getPrices({ created__gte: utils.currentStartOfDay(), size: 1 }) .then((data) => { this.todayPriceCount = data.total this.loading = false diff --git a/tests/e2e/spec.cy.js b/tests/e2e/spec.cy.js new file mode 100644 index 00000000000..c573868443c --- /dev/null +++ b/tests/e2e/spec.cy.js @@ -0,0 +1,30 @@ +describe('Basic tests', () => { + beforeEach(() => { + cy.intercept('GET', 'http://127.0.0.1:8000/api/v1/prices?page=1&size=1&order_by=-created*', { fixture: 'prices.json' }) + cy.intercept('GET', 'http://127.0.0.1:8000/api/v1/prices?page=1&size=10&order_by=-date&product_code=3011360030498', { fixture: 'prices_3011360030498.json' }) + cy.intercept('GET', 'http://127.0.0.1:8000/api/v1/prices?page=1&size=10&order_by=-date&category_tag=en%3Apitted-apricot', { fixture: 'prices_pitted_apricot.json' }) + cy.intercept('GET', 'http://127.0.0.1:8000/api/v1/products/code/3011360030498', { fixture: 'product_3011360030498.json' }) + }) + + it('loads the home page', () => { + cy.visit('/') + cy.contains('Welcome to Open Prices!') // en by default + cy.get('#price-count').contains('42') + }) + + it('displays a product page', () => { + cy.visit('/products/3011360030498') + cy.contains('Welcome to Open Prices!').should('not.exist') + cy.get('#product-title').contains('Mayonnaise Classique') + cy.get('#price-count').contains('1') + cy.contains('Unknown product').should('not.exist') + }) + + it('displays a raw product page', () => { + cy.visit('/products/en:pitted-apricot') + cy.contains('Welcome to Open Prices!').should('not.exist') + cy.get('.v-card-title').contains('Pitted apricot') + // cy.get('#price-count').contains('1') + cy.contains('Unknown product') // to fix + }) +}) diff --git a/tests/fixtures/example.json b/tests/fixtures/example.json new file mode 100644 index 00000000000..02e4254378e --- /dev/null +++ b/tests/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/tests/fixtures/prices.json b/tests/fixtures/prices.json new file mode 100644 index 00000000000..d9d3f392302 --- /dev/null +++ b/tests/fixtures/prices.json @@ -0,0 +1,624 @@ +{ + "items": [ + { + "product_code": null, + "product_name": null, + "category_tag": "en:pitted-apricot", + "labels_tags": null, + "origins_tags": [ + "en:germany" + ], + "price": 3.0, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": "KILOGRAM", + "currency": "AED", + "location_osm_id": 32520537, + "location_osm_type": "WAY", + "date": "2024-03-20", + "proof_id": 224, + "id": 759, + "product_id": null, + "location_id": 32, + "owner": "user1", + "created": "2024-03-20T14:27:21.575599+01:00", + "product": null, + "proof": { + "id": 224, + "file_path": "0001/TWZOnskQhz.webp", + "mimetype": "image/webp", + "type": "RECEIPT", + "owner": "user1", + "price_count": 9, + "created": "2024-03-20T01:40:46.098715+01:00" + }, + "location": { + "osm_id": 32520537, + "osm_type": "WAY", + "price_count": 16, + "id": 32, + "osm_name": "Monoprix", + "osm_display_name": "Monoprix, Rue Lafayette, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France", + "osm_address_postcode": "38000", + "osm_address_city": "Grenoble", + "osm_address_country": "France", + "osm_lat": 45.1904063, + "osm_lon": 5.7286464, + "created": "2024-02-09T17:43:00.113125+01:00", + "updated": "2024-03-31T22:13:49.569736+02:00" + } + }, + { + "product_code": "3564700011270", + "product_name": null, + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 4.0, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "AED", + "location_osm_id": 32520537, + "location_osm_type": "WAY", + "date": "2024-03-16", + "proof_id": 222, + "id": 758, + "product_id": 366, + "location_id": 32, + "owner": "user1", + "created": "2024-03-16T12:05:19.479540+01:00", + "product": { + "code": "3564700011270", + "price_count": 3, + "id": 366, + "source": "off", + "product_name": "Noix de cajou", + "product_quantity": 400, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Tokapi,Marque Repère", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/356/470/001/1270/front_fr.47.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 8, + "created": "2024-02-18T19:39:38.121039+01:00", + "updated": "2024-04-25T17:48:42.732245+02:00" + }, + "proof": { + "id": 222, + "file_path": "0001/VbZgKvbVK5.webp", + "mimetype": "image/webp", + "type": "PRICE_TAG", + "owner": "user1", + "price_count": 4, + "created": "2024-03-09T10:26:09.875616+01:00" + }, + "location": { + "osm_id": 32520537, + "osm_type": "WAY", + "price_count": 16, + "id": 32, + "osm_name": "Monoprix", + "osm_display_name": "Monoprix, Rue Lafayette, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France", + "osm_address_postcode": "38000", + "osm_address_city": "Grenoble", + "osm_address_country": "France", + "osm_lat": 45.1904063, + "osm_lon": 5.7286464, + "created": "2024-02-09T17:43:00.113125+01:00", + "updated": "2024-03-31T22:13:49.569736+02:00" + } + }, + { + "product_code": null, + "product_name": null, + "category_tag": "en:apricots", + "labels_tags": null, + "origins_tags": [ + "en:africa" + ], + "price": 6.0, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": "KILOGRAM", + "currency": "AED", + "location_osm_id": 32520537, + "location_osm_type": "WAY", + "date": "2024-03-15", + "proof_id": 222, + "id": 757, + "product_id": null, + "location_id": 32, + "owner": "user1", + "created": "2024-03-15T23:32:37.588511+01:00", + "product": null, + "proof": { + "id": 222, + "file_path": "0001/VbZgKvbVK5.webp", + "mimetype": "image/webp", + "type": "PRICE_TAG", + "owner": "user1", + "price_count": 4, + "created": "2024-03-09T10:26:09.875616+01:00" + }, + "location": { + "osm_id": 32520537, + "osm_type": "WAY", + "price_count": 16, + "id": 32, + "osm_name": "Monoprix", + "osm_display_name": "Monoprix, Rue Lafayette, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France", + "osm_address_postcode": "38000", + "osm_address_city": "Grenoble", + "osm_address_country": "France", + "osm_lat": 45.1904063, + "osm_lon": 5.7286464, + "created": "2024-02-09T17:43:00.113125+01:00", + "updated": "2024-03-31T22:13:49.569736+02:00" + } + }, + { + "product_code": "3564700428023", + "product_name": "GEL WC JAVEL AGRUMES 750ML MR", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 0.8, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 752, + "product_id": 317, + "location_id": 36, + "owner": "user2", + "created": "2024-02-18T19:39:38.271003+01:00", + "product": { + "code": "3564700428023", + "price_count": 3, + "id": 317, + "source": null, + "product_name": null, + "product_quantity": null, + "product_quantity_unit": null, + "categories_tags": [], + "brands": null, + "brands_tags": [], + "labels_tags": [], + "image_url": null, + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 0, + "created": "2024-02-18T19:39:29.516217+01:00", + "updated": "2024-02-18T19:39:38.294398+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 61, + "id": 36, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.805746+01:00", + "updated": "2024-02-18T19:39:38.406241+01:00" + } + }, + { + "product_code": "5021991941320", + "product_name": "SWEET VANILLE 40G BIO", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 2.08, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 751, + "product_id": 371, + "location_id": 36, + "owner": "user2", + "created": "2024-02-18T19:39:38.227889+01:00", + "product": { + "code": "5021991941320", + "price_count": 1, + "id": 371, + "source": "off", + "product_name": "Sweet vanilli", + "product_quantity": 40, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Clipper", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/502/199/194/1320/front_fr.24.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 5, + "created": "2024-02-18T19:39:38.244617+01:00", + "updated": "2024-02-18T19:39:38.267541+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 61, + "id": 36, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.805746+01:00", + "updated": "2024-02-18T19:39:38.406241+01:00" + } + }, + { + "product_code": "3228857000371", + "product_name": "LE MOMENT BURGER NATURE", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 1.76, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 750, + "product_id": 370, + "location_id": 36, + "owner": "user2", + "created": "2024-02-18T19:39:38.205921+01:00", + "product": { + "code": "3228857000371", + "price_count": 1, + "id": 370, + "source": "off", + "product_name": "Burger nature", + "product_quantity": 300, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Harrys", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/322/885/700/0371/front_fr.49.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 17, + "created": "2024-02-18T19:39:38.211726+01:00", + "updated": "2024-02-18T19:39:38.223164+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 61, + "id": 36, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.805746+01:00", + "updated": "2024-02-18T19:39:38.406241+01:00" + } + }, + { + "product_code": "3564700291634", + "product_name": "CREME LEG SE UHT 18% 3X20CL MR", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 1.85, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 749, + "product_id": 369, + "location_id": 38, + "owner": "user2", + "created": "2024-02-18T19:39:38.188458+01:00", + "product": { + "code": "3564700291634", + "price_count": 1, + "id": 369, + "source": "off", + "product_name": "Crème légère UHT 18% semi-épaisse", + "product_quantity": 600, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Délisse,Marque Repère", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/356/470/029/1634/front_fr.85.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 16, + "created": "2024-02-18T19:39:38.196472+01:00", + "updated": "2024-02-18T19:39:38.208130+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 62, + "id": 38, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.807454+01:00", + "updated": "2024-02-18T19:39:38.360423+01:00" + } + }, + { + "product_code": "3011360030498", + "product_name": "MAYO CLASSIQUE TUBE 175G", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 0.67, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 748, + "product_id": 368, + "location_id": 38, + "owner": "user2", + "created": "2024-02-18T19:39:38.155260+01:00", + "product": { + "code": "3011360030498", + "price_count": 1, + "id": 368, + "source": "off", + "product_name": "Mayonnaise Classique", + "product_quantity": 175, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Lesieur", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/301/136/003/0498/front_en.119.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 78, + "created": "2024-02-18T19:39:38.162303+01:00", + "updated": "2024-02-18T19:39:38.186691+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 62, + "id": 38, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.807454+01:00", + "updated": "2024-02-18T19:39:38.360423+01:00" + } + }, + { + "product_code": "3564700007440", + "product_name": "FROMAGE BLC NAT 7,6% MG 1KG MR", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 1.95, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 747, + "product_id": 367, + "location_id": 36, + "owner": "user2", + "created": "2024-02-18T19:39:38.131076+01:00", + "product": { + "code": "3564700007440", + "price_count": 1, + "id": 367, + "source": "off", + "product_name": "Fromage blanc au lait entier", + "product_quantity": 1000, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Marque Repère, Délisse", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/356/470/000/7440/front_fr.39.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 21, + "created": "2024-02-18T19:39:38.137732+01:00", + "updated": "2024-02-18T19:39:38.147674+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 61, + "id": 36, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.805746+01:00", + "updated": "2024-02-18T19:39:38.406241+01:00" + } + }, + { + "product_code": "3564700011270", + "product_name": "NOIX DE CAJOU GRIL 400G TOKAPI", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 4.99, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-10-02", + "proof_id": 218, + "id": 746, + "product_id": 366, + "location_id": 38, + "owner": "user2", + "created": "2024-02-18T19:39:38.112339+01:00", + "product": { + "code": "3564700011270", + "price_count": 3, + "id": 366, + "source": "off", + "product_name": "Noix de cajou", + "product_quantity": 400, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Tokapi,Marque Repère", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/356/470/001/1270/front_fr.47.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 8, + "created": "2024-02-18T19:39:38.121039+01:00", + "updated": "2024-04-25T17:48:42.732245+02:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 62, + "id": 38, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.807454+01:00", + "updated": "2024-02-18T19:39:38.360423+01:00" + } + } + ], + "total": 42, + "page": 2, + "size": 10, + "pages": 5 +} diff --git a/tests/fixtures/prices_3011360030498.json b/tests/fixtures/prices_3011360030498.json new file mode 100644 index 00000000000..77d5a033653 --- /dev/null +++ b/tests/fixtures/prices_3011360030498.json @@ -0,0 +1,73 @@ +{ + "items": [ + { + "product_code": "3011360030498", + "product_name": "MAYO CLASSIQUE TUBE 175G", + "category_tag": null, + "labels_tags": null, + "origins_tags": null, + "price": 0.67, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": null, + "currency": "EUR", + "location_osm_id": 1234038503, + "location_osm_type": "WAY", + "date": "2022-07-08", + "proof_id": 218, + "id": 748, + "product_id": 368, + "location_id": 38, + "owner": "user2", + "created": "2024-02-18T19:39:38.155260+01:00", + "product": { + "code": "3011360030498", + "price_count": 1, + "id": 368, + "source": "off", + "product_name": "Mayonnaise Classique", + "product_quantity": 175, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Lesieur", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/301/136/003/0498/front_en.119.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 78, + "created": "2024-02-18T19:39:38.162303+01:00", + "updated": "2024-02-18T19:39:38.186691+01:00" + }, + "proof": { + "id": 218, + "file_path": "0001/B1LWjiRGAa.png", + "mimetype": "image/png", + "type": "RECEIPT", + "owner": "user2", + "price_count": 122, + "created": "2024-02-18T19:32:45.909387+01:00" + }, + "location": { + "osm_id": 1234038503, + "osm_type": "WAY", + "price_count": 62, + "id": 38, + "osm_name": "E. Leclerc", + "osm_display_name": "E. Leclerc, V 64, Pré Nouvel, Échirolles, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38130, France", + "osm_address_postcode": "38130", + "osm_address_city": "Échirolles", + "osm_address_country": "France", + "osm_lat": 45.1498691, + "osm_lon": 5.6920308, + "created": "2024-02-18T19:39:23.807454+01:00", + "updated": "2024-02-18T19:39:38.360423+01:00" + } + } + ], + "total": 1, + "page": 1, + "size": 10, + "pages": 1 +} \ No newline at end of file diff --git a/tests/fixtures/prices_pitted_apricot.json b/tests/fixtures/prices_pitted_apricot.json new file mode 100644 index 00000000000..954e376bc72 --- /dev/null +++ b/tests/fixtures/prices_pitted_apricot.json @@ -0,0 +1,104 @@ +{ + "items": [ + { + "product_code": null, + "product_name": null, + "category_tag": "en:pitted-apricot", + "labels_tags": null, + "origins_tags": [ + "en:unknown" + ], + "price": 4.0, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": "UNIT", + "currency": "AED", + "location_osm_id": 32520537, + "location_osm_type": "WAY", + "date": "2024-03-31", + "proof_id": 224, + "id": 760, + "product_id": null, + "location_id": 32, + "owner": "user1", + "created": "2024-03-31T22:10:53.037731+02:00", + "product": null, + "proof": { + "id": 224, + "file_path": "0001/TWZOnskQhz.webp", + "mimetype": "image/webp", + "type": "RECEIPT", + "owner": "user1", + "price_count": 9, + "created": "2024-03-20T01:40:46.098715+01:00" + }, + "location": { + "osm_id": 32520537, + "osm_type": "WAY", + "price_count": 16, + "id": 32, + "osm_name": "Monoprix", + "osm_display_name": "Monoprix, Rue Lafayette, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France", + "osm_address_postcode": "38000", + "osm_address_city": "Grenoble", + "osm_address_country": "France", + "osm_lat": 45.1904063, + "osm_lon": 5.7286464, + "created": "2024-02-09T17:43:00.113125+01:00", + "updated": "2024-03-31T22:13:49.569736+02:00" + } + }, + { + "product_code": null, + "product_name": null, + "category_tag": "en:pitted-apricot", + "labels_tags": null, + "origins_tags": [ + "en:germany" + ], + "price": 3.0, + "price_is_discounted": false, + "price_without_discount": null, + "price_per": "KILOGRAM", + "currency": "AED", + "location_osm_id": 32520537, + "location_osm_type": "WAY", + "date": "2024-03-20", + "proof_id": 224, + "id": 759, + "product_id": null, + "location_id": 32, + "owner": "user1", + "created": "2024-03-20T14:27:21.575599+01:00", + "product": null, + "proof": { + "id": 224, + "file_path": "0001/TWZOnskQhz.webp", + "mimetype": "image/webp", + "type": "RECEIPT", + "owner": "user1", + "price_count": 9, + "created": "2024-03-20T01:40:46.098715+01:00" + }, + "location": { + "osm_id": 32520537, + "osm_type": "WAY", + "price_count": 16, + "id": 32, + "osm_name": "Monoprix", + "osm_display_name": "Monoprix, Rue Lafayette, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France", + "osm_address_postcode": "38000", + "osm_address_city": "Grenoble", + "osm_address_country": "France", + "osm_lat": 45.1904063, + "osm_lon": 5.7286464, + "created": "2024-02-09T17:43:00.113125+01:00", + "updated": "2024-03-31T22:13:49.569736+02:00" + } + } + ], + "total": 2, + "page": 1, + "size": 10, + "pages": 1 +} \ No newline at end of file diff --git a/tests/fixtures/product_3011360030498.json b/tests/fixtures/product_3011360030498.json new file mode 100644 index 00000000000..09428cdff56 --- /dev/null +++ b/tests/fixtures/product_3011360030498.json @@ -0,0 +1,20 @@ +{ + "code": "3011360030498", + "price_count": 1, + "id": 368, + "source": "off", + "product_name": "Mayonnaise Classique", + "product_quantity": 175, + "product_quantity_unit": null, + "categories_tags": [], + "brands": "Lesieur", + "brands_tags": [], + "labels_tags": [], + "image_url": "https://images.openfoodfacts.net/images/products/301/136/003/0498/front_en.119.400.jpg", + "nutriscore_grade": null, + "ecoscore_grade": null, + "nova_group": null, + "unique_scans_n": 78, + "created": "2024-02-18T19:39:38.162303+01:00", + "updated": "2024-02-18T19:39:38.186691+01:00" +} diff --git a/tests/support/commands.js b/tests/support/commands.js new file mode 100644 index 00000000000..66ea16ef0e3 --- /dev/null +++ b/tests/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add('login', (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file diff --git a/tests/support/e2e.js b/tests/support/e2e.js new file mode 100644 index 00000000000..0e7290a13d9 --- /dev/null +++ b/tests/support/e2e.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') \ No newline at end of file