diff --git a/src/test/retail/local-retail.spec.ts b/src/test/retail/local-retail.spec.ts index a5241507a773d9a1b1c355aec1974835e0979790..d4712fef08756c6cea321a89a226bbe9b5c8021c 100644 --- a/src/test/retail/local-retail.spec.ts +++ b/src/test/retail/local-retail.spec.ts @@ -5,8 +5,12 @@ import { container } from "../../inversify/inversify.config"; import { GCLController } from "../../gcl/gcl.controller"; import HttpClient from "../../httpclient/http.service"; import SearchRequestFromUI from "./request-from-ui/search.request.json"; +import SelectRequestFromUI from "./request-from-ui/select.request.json"; import SearcResponseFromPS from "./response-from-ps/search.response.json"; +import SelectResponseFromPS from "./response-from-ps/select.response.json"; import SearchResponseToUI from "./response-to-ui/response.search.json"; +import SelectResponseToUI from "./response-to-ui/response.select.json"; + describe("Local-retail Controller Testing", () => { let controller: GCLController; beforeAll(async () => { @@ -24,4 +28,12 @@ describe("Local-retail Controller Testing", () => { const data = await controller.search(SearchRequestFromUI); expect(JSON.stringify(data)).toEqual(JSON.stringify(SearchResponseToUI)); }); + + it.only("Select API should be working fine", async () => { + jest + .spyOn(HttpClient.prototype, "post") + .mockImplementation(async () => SelectResponseFromPS); + const data = await controller.search(SelectRequestFromUI); + expect(JSON.stringify(data)).toEqual(JSON.stringify(SelectResponseToUI)); + }); }); diff --git a/src/test/retail/request-from-ui/select.request.json b/src/test/retail/request-from-ui/select.request.json new file mode 100644 index 0000000000000000000000000000000000000000..3acaeb52e790520c501bb073fdfc9798fac566c1 --- /dev/null +++ b/src/test/retail/request-from-ui/select.request.json @@ -0,0 +1,36 @@ +{ + "data": [ + { + "context": { + "transaction_id": "eed96a3f-c780-4157-a219-09ff871ee56c", + "bpp_id": "beckn-sandbox-bpp.becknprotocol.io", + "bpp_uri": "https://sandbox-bpp-network.becknprotocol.io", + "domain": "retail:1.1.0" + }, + "message": { + "orders": [ + { + "items": [ + { + "id": "./retail.kirana/ind.blr/247@tourism-bpp-infra2.becknprotocol.io.item", + "selected": { + "quantity": { + "count": 1 + } + } + } + ], + "provider": { + "id": "./retail.kirana/ind.blr/33@tourism-bpp-infra2.becknprotocol.io.provider" + }, + "fulfillments": [ + { + "id": "f1" + } + ] + } + ] + } + } + ] +} diff --git a/src/test/retail/response-from-ps/select.response.json b/src/test/retail/response-from-ps/select.response.json new file mode 100644 index 0000000000000000000000000000000000000000..a3db462bbba5986fc23b636f89205088787dd38f --- /dev/null +++ b/src/test/retail/response-from-ps/select.response.json @@ -0,0 +1,3 @@ +{"context":{"ttl":"PT10M","action":"select","timestamp":"2024-01-12T09:13:53.945Z","message_id":"2042a0f1-9b71-48a3-91c4-c4f3874e156b","transaction_id":"eed96a3f-c780-4157-a219-09ff871ee56c","domain":"retail:1.1.0","version":"1.1.0","bap_id":"ps-bap-network.becknprotocol.io","bap_uri":"https://ps-bap-network.becknprotocol.io","location":{"country":{"name":"India","code":"IND"},"city":{"name":"Bangalore","code":"std:080"}},"bpp_id":"beckn-sandbox-bpp.becknprotocol.io","bpp_uri":"https://sandbox-bpp-network.becknprotocol.io"},"responses":[{"context":{"domain":"retail:1.1.0","action":"on_select","version":"1.1.0","bpp_id":"beckn-sandbox-bpp.becknprotocol.io","bpp_uri":"https://sandbox-bpp-network.becknprotocol.io","country":"IND","city":"std:080","location":{"country":{"code":"IND"},"city":{"code":"std:080"}},"bap_id":"ps-bap-network.becknprotocol.io","bap_uri":"https://ps-bap-network.becknprotocol.io","transaction_id":"eed96a3f-c780-4157-a219-09ff871ee56c","message_id":"2042a0f1-9b71-48a3-91c4-c4f3874e156b","ttl":"PT10M","timestamp":"2024-01-12T09:14:00.481Z"},"message":{"order":{"provider":{"id":"./retail.kirana/ind.blr/33@tourism-bpp-infra2.becknprotocol.io.provider","descriptor":{"name":"Venky.Mahadevan@Bazaar"},"locations":[{"id":"./retail.kirana/ind.blr/1@tourism-bpp-infra2.becknprotocol.io.provider_location"}]},"items":[{"id":"./retail.kirana/ind.blr/247@tourism-bpp-infra2.becknprotocol.io.item","descriptor":{"images":[{"url":"https://tourism-bpp-infra2.becknprotocol.io/attachments/view/253.jpg"}],"name":"Isothermal Stainless Steel Hiking Flask MH500 Yellow - Water bottle","short_desc":"InstaCuppa Stainless Steel Thermos Flask Water Bottle with Sports Sipper Lid, Double Walled Vacuum Insulation","long_desc":"<div> <ul> <li>ULTRA MODERN DESIGN - Our thermos bottle is crafted with a unique and modern design. Gone are the +days of old and boring flasks. Guaranteed to impress your colleagues, friends & family.</li> <li>ADVANCED TEMPERATURE CONTROL – A double-wall, vacuum-insulated design helps +lock in heat for up to 12 hours and cold for up to 24!</li> <li>ELIMINATES CONDENSATION – Offering improved grip and control, these innovative dual-layer bottles offer a slip-resistant surface that’s free of sweat and condensation..</li> <li>LEAK-PROOF and ECO-FRIENDLY – Remove, and clean, the large, screw on lid provides faster access to water inside and won’t spill a drop even when it’s tipped upside or put in your gym bag.</li> <li>The distress quilted jacket is a versatile fashion choice you can wear on any occasion. A style essential piece for Women which will reveal your strong sense of personality</li> </ul> <div> <p><b>Product Details</b></p> <ul> <li>Advanced Temperature Retention.This thermos water bottle ensures your beverages will remain hot or cold for a long time.Hot for up to 12 hours.Cold for up to 24 hours.</li> <li>Retains Original Flavors.Vacuum insulation ensures this travel thermos water bottle is airtight and retains the original flavor of your beverages.Also, this bottle is B.P.A Free.</li> <li>Premium Quality Materials.This stylish bottle is a double-walled vacuum insulated and made from premium 304-grade stainless steel - which makes this flask bottle.</li> </ul> </div>"},"category_ids":["c1"],"price":{"listed_value":"1200.0","currency":"INR","value":"1200.0"}}],"fulfillments":[{"id":"f1","tracking":false}],"quote":{"price":{"currency":"INR","value":"1500.0"},"breakup":[{"title":"base-price","price":{"currency":"INR","value":"1200.0"}},{"title":"taxes","price":{"currency":"INR","value":"300.0"}}]},"type":"DEFAULT"}}}]} \ No newline at end of file diff --git a/src/test/retail/response-to-ui/response.select.json b/src/test/retail/response-to-ui/response.select.json new file mode 100644 index 0000000000000000000000000000000000000000..313e8d93212a5aed82f5a3c87b4a16f7cba72cca --- /dev/null +++ b/src/test/retail/response-to-ui/response.select.json @@ -0,0 +1,73 @@ +{ + "data": [ + { + "context": { + "domain": "retail:1.1.0", + "action": "on_select", + "version": "1.1.0", + "bpp_id": "beckn-sandbox-bpp.becknprotocol.io", + "bpp_uri": "https://sandbox-bpp-network.becknprotocol.io", + "country": "IND", + "city": "std:080", + "location": { + "country": { + "code": "IND" + }, + "city": { + "code": "std:080" + } + }, + "bap_id": "ps-bap-network.becknprotocol.io", + "bap_uri": "https://ps-bap-network.becknprotocol.io", + "transaction_id": "eed96a3f-c780-4157-a219-09ff871ee56c", + "message_id": "2042a0f1-9b71-48a3-91c4-c4f3874e156b", + "ttl": "PT10M", + "timestamp": "2024-01-12T09:14:00.481Z" + }, + "message": { + "order": { + "type": "DEFAULT", + "quote": { + "price": { + "currency": "INR", + "value": "1500.0" + }, + "breakup": [ + { + "title": "base-price", + "price": { + "currency": "INR", + "value": "1200.0" + } + }, + { + "title": "taxes", + "price": { + "currency": "INR", + "value": "300.0" + } + } + ] + }, + "provider": { + "id": "./retail.kirana/ind.blr/33@tourism-bpp-infra2.becknprotocol.io.provider", + "name": "Venky.Mahadevan@Bazaar" + }, + "items": [ + { + "id": "./retail.kirana/ind.blr/247@tourism-bpp-infra2.becknprotocol.io.item", + "name": "Isothermal Stainless Steel Hiking Flask MH500 Yellow - Water bottle", + "short_desc": "InstaCuppa Stainless Steel Thermos Flask Water Bottle with Sports Sipper Lid, Double Walled Vacuum Insulation", + "long_desc": "<div> <ul> <li>ULTRA MODERN DESIGN - Our thermos bottle is crafted with a unique and modern design. Gone are the days of old and boring flasks. Guaranteed to impress your colleagues, friends & family.</li> <li>ADVANCED TEMPERATURE CONTROL – A double-wall, vacuum-insulated design helps lock in heat for up to 12 hours and cold for up to 24!</li> <li>ELIMINATES CONDENSATION – Offering improved grip and control, these innovative dual-layer bottles offer a slip-resistant surface that’s free of sweat and condensation..</li> <li>LEAK-PROOF and ECO-FRIENDLY – Remove, and clean, the large, screw on lid provides faster access to water inside and won’t spill a drop even when it’s tipped upside or put in your gym bag.</li> <li>The distress quilted jacket is a versatile fashion choice you can wear on any occasion. A style essential piece for Women which will reveal your strong sense of personality</li> </ul> <div> <p><b>Product Details</b></p> <ul> <li>Advanced Temperature Retention.This thermos water bottle ensures your beverages will remain hot or cold for a long time.Hot for up to 12 hours.Cold for up to 24 hours.</li> <li>Retains Original Flavors.Vacuum insulation ensures this travel thermos water bottle is airtight and retains the original flavor of your beverages.Also, this bottle is B.P.A Free.</li> <li>Premium Quality Materials.This stylish bottle is a double-walled vacuum insulated and made from premium 304-grade stainless steel - which makes this flask bottle.</li> </ul> </div>", + "price": { + "listed_value": "1200.0", + "currency": "INR", + "value": "1200.0" + } + } + ] + } + } + } + ] +}