From 5dfbc451dd0e21339f93ceb27bed45b3c9aac013 Mon Sep 17 00:00:00 2001 From: Konstantin Kiritsenko Date: Tue, 12 Mar 2024 23:04:07 +0300 Subject: [PATCH] SG-208 react native codebase detect --- CHANGELOG.md | 1 + src/Backend/SgateShopgatePlugin/Bootstrap.php | 58 +- .../Views/frontend/index/index.tpl | 7 +- tests/Postman/collection.json | 4180 +++++++++-------- 4 files changed, 2259 insertions(+), 1987 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4375d8..16f3ff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this - ability to skip advanced price export when calling `get_items`, config called `skip_advanced_price_export` - webCheckout login route for guests - webCheckout will close browser when an item is added to cart on desktop site (inApp) +- CSS body tag that differentiates between R.Native (`.is-sg-codebase-v2`) & old Swift/Java based App (`.is-sg-codebase-v1`) ### Changed - category querying and lookup to be more performant diff --git a/src/Backend/SgateShopgatePlugin/Bootstrap.php b/src/Backend/SgateShopgatePlugin/Bootstrap.php index 754da17..b5da635 100644 --- a/src/Backend/SgateShopgatePlugin/Bootstrap.php +++ b/src/Backend/SgateShopgatePlugin/Bootstrap.php @@ -1288,10 +1288,7 @@ public function onCustomEvent(Enlight_Event_EventArgs $args) $view->assign('sgForgotPassword', false); $view->assign('sgFrontendAccount', false); $view->assign('sgActionName', false); - $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); - - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); + $this->assignCommonData($view, $args); } /** @@ -1305,7 +1302,6 @@ public function onFrontendCheckout(Enlight_Event_EventArgs $args) $view->addTemplateDir(__DIR__ . '/Views/'); $view->assign('sgWebCheckout', $this->isInWebView($args)); $view->assign('sgActionName', $args->getRequest()->getActionName()); - $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); $view->assign('sgPromotionVouchers', json_encode(Shopware()->Session()->offsetGet('promotionVouchers'))); $view->assign('sgAccountView', false); $view->assign('sgIsNewCustomer', false); @@ -1313,9 +1309,7 @@ public function onFrontendCheckout(Enlight_Event_EventArgs $args) $view->assign('sgFrontendRegister', false); $view->assign('sgHash', false); $view->assign('sgEmail', false); - - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); + $this->assignCommonData($view, $args); if ($this->isInWebView($args)) { $referer = array( @@ -1397,10 +1391,7 @@ public function onFrontendRegister(Enlight_Event_EventArgs $args) $view->assign('sgForgotPassword', false); $view->assign('sgFrontendAccount', false); $view->assign('sgActionName', false); - $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); - - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); + $this->assignCommonData($view, $args); } /** @@ -1416,10 +1407,7 @@ public function onFrontendAddress(Enlight_Event_EventArgs $args) $view->assign('sgForgotPassword', false); $view->assign('sgFrontendAccount', false); $view->assign('sgActionName', false); - $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); - - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); + $this->assignCommonData($view, $args); } /** @@ -1433,9 +1421,6 @@ public function onFrontendAccount(Enlight_Event_EventArgs $args) $view->addTemplateDir($this->Path() . 'Views/'); $view->assign('sgActionName', false); - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); - $nonSgPaths = array('/account/documents', '/account/ruecksendungen', '/bewertungen'); if (in_array($request->getPathInfo(), $nonSgPaths)) { $view->assign('sgAccountView', false); @@ -1466,16 +1451,14 @@ public function onFrontendAccount(Enlight_Event_EventArgs $args) $view->assign('sgCloudCallbackData', $sgCloudCallbackData); $view->assign('sgHash', $hash); $view->assign('sgEmail', $email); - $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); + $this->assignCommonData($view, $args); } public function onFrontendPassword(Enlight_Event_EventArgs $args) { $view = $args->getSubject()->View(); $view->assign('sgForgotPassword', true); - - $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); - $view->assign('sgCustomCss', $customCss); + $this->assignCommonData($view, $args); } public function onFrontendCustom(Enlight_Event_EventArgs $args) @@ -1488,12 +1471,41 @@ public function onFrontendCustom(Enlight_Event_EventArgs $args) $view->assign('sgFrontendRegister', false); $view->assign('sgFrontendAccount', false); $view->assign('sgActionName', false); + $this->assignCommonData($view, $args); + } + + /** + * Assigns data common to all frontend controllers + * + * @return void + */ + private function assignCommonData(Enlight_View_Default $view, Enlight_Event_EventArgs $args) + { $view->assign('sgSessionId', Shopware()->Session()->offsetGet('sessionId')); + $userAgent = $args->getSubject()->Request()->getHeader('user-agent'); + $isNative = $this->isNativeBase($userAgent); + $view->assign('sgIsNativeBase', $isNative); + $customCss = Shopware()->Config()->getByNamespace('SgateShopgatePlugin', 'SGATE_CUSTOM_CSS'); $view->assign('sgCustomCss', $customCss); } + /** + * Native SG App should have a Codebase variable with + * a version higher than 11 + * + * @param string $userAgent + * @return bool + */ + private function isNativeBase($userAgent) + { + $regex = '/libshopgate.*?Codebase:(\d+\.\d+(\.\d+)?)/'; + preg_match($regex, $userAgent, $matches); + + return version_compare(isset($matches[1]) ? $matches[1] : '0.0.0', '11.0.0', '>='); + } + /** * Removes hidden config form element */ diff --git a/src/Backend/SgateShopgatePlugin/Views/frontend/index/index.tpl b/src/Backend/SgateShopgatePlugin/Views/frontend/index/index.tpl index 40b8051..f411738 100644 --- a/src/Backend/SgateShopgatePlugin/Views/frontend/index/index.tpl +++ b/src/Backend/SgateShopgatePlugin/Views/frontend/index/index.tpl @@ -7,7 +7,7 @@ {/if} {/block} - +{block name="frontend_index_body_classes"}{$smarty.block.parent}{if $sgWebCheckout} {strip}is-sg-codebase-{if $sgIsNativeBase}v2{else}v1{/if}{/strip}{/if}{/block} {block name='frontend_index_navigation'} {if !$sgWebCheckout} {$smarty.block.parent} @@ -32,12 +32,13 @@ {/if} {if $sgSessionId || $sgActionName === 'confirm' || $sgActionName === 'shippingPayment' || $sgActionName === 'cart'} diff --git a/tests/Postman/collection.json b/tests/Postman/collection.json index 924b52c..647425e 100644 --- a/tests/Postman/collection.json +++ b/tests/Postman/collection.json @@ -1,2021 +1,2279 @@ { - "info": { - "_postman_id": "72babe50-8d15-4025-b1b2-bf064719644a", - "name": "Shopware 5 (Go)", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "5289226" - }, - "item": [ - { - "name": "Init", - "item": [ - { - "name": "System", - "item": [ - { - "name": "SW: Get shop info", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "// allowCookie=1\r", - "const jar = pm.cookies.jar();\r", - "jar.set(pm.environment.get(\"host\"), 'allowCookie', '1');" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/shops/1", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "shops", - "1" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Product", - "item": [ - { - "name": "SW: Get main product", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test(\"Get main product\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.data).to.haveOwnProperty('id').to.be.a('number');\r", - " pm.environment.set(\"gen_product_main_id\", jsonData.data.id);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/articles/SW10001?useNumberAsId=true", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "articles", - "SW10001" - ], - "query": [ - { - "key": "useNumberAsId", - "value": "true" - } - ] - } - }, - "response": [] - }, - { - "name": "SW: Get main category", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test(\"Get main category\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.data[0]).to.haveOwnProperty('id').to.be.a('number');\r", - " pm.environment.set(\"gen_category_main_id\", jsonData.data[0].id);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"filter\": [\r\n {\r\n \"property\": \"parentId\",\r\n \"expression\": \">\",\r\n \"value\": \"1\"\r\n }\r\n ],\r\n \"limit\": 1\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{sw_endpoint_api}}/categories", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "categories" - ] - } - }, - "response": [] - }, - { - "name": "SW: create inactive prod", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 201\", function () {\r", - " pm.response.to.have.status(201);\r", - "});\r", - "\r", - "pm.test(\"Get id of created product\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.data.id).to.be.a(\"number\");\r", - " pm.environment.set('created_product1_id', jsonData.data.id);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"name\": \"API: disabled product\",\r\n \"active\": false,\r\n \"tax\": 19,\r\n \"supplier\": \"Sport Shoes Inc.\",\r\n \"categories\": [\r\n {\r\n \"id\": {{gen_category_main_id}}\r\n }\r\n ],\r\n \"mainDetail\": {\r\n \"number\": \"API-INACTIVE\",\r\n \"active\": true,\r\n \"prices\": [\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"price\": 999\r\n }\r\n ]\r\n }\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{sw_endpoint_api}}/articles", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "articles" - ] - } - }, - "response": [] - }, - { - "name": "SW: create price grp", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 201\", function () {\r", - " pm.response.to.have.status(201);\r", - "});\r", - "\r", - "pm.test(\"Get id of created product\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.data.id).to.be.a(\"number\");\r", - " pm.environment.set('created_product2_id', jsonData.data.id);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"name\": \"API: price grp product\",\r\n \"active\": true,\r\n \"tax\": 19,\r\n \"supplier\": \"Active Runners LLC\",\r\n \"categories\": [\r\n {\r\n \"id\": {{gen_category_main_id}}\r\n }\r\n ],\r\n \"lastStock\": true, // stock cannot go into negatives (saleable)\r\n \"priceGroupActive\": true,\r\n \"priceGroupId\": 500,\r\n \"mainDetail\": {\r\n \"number\": \"API-PRICE-GRP\",\r\n \"active\": true,\r\n \"prices\": [\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"from\": \"1\",\r\n \"to\": \"3\",\r\n \"price\": 200,\r\n \"pseudoPrice\": 250, // fake price to cross out\r\n \"basePrice\": 90\r\n },\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"from\": \"4\",\r\n \"to\": \"7\",\r\n \"price\": 100,\r\n \"pseudoPrice\": 250,\r\n \"basePrice\": 90\r\n }\r\n ],\r\n \"inStock\": 500,\r\n \"minPurchase\": 2,\r\n \"maxPurchase\": 10,\r\n \"purchaseSteps\": 2,\r\n \"position\": 5\r\n }\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{sw_endpoint_api}}/articles", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "articles" - ] - } - }, - "response": [] - } - ] - } - ] + "info": { + "_postman_id": "72babe50-8d15-4025-b1b2-bf064719644a", + "name": "Shopware 5 (Go)", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "5289226" }, - { - "name": "Catalog", - "item": [ + "item": [ { - "name": "Export inactive", - "item": [ - { - "name": "SG: try inactive export", - "event": [ + "name": "Init", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Make sure the product is not exported as it's inactive\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.error).to.eql(82);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" - }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - }, - { - "key": "uids[]", - "value": "{{created_product1_id}}", - "type": "text" - } - ] + "name": "System", + "item": [ + { + "name": "SW: Get shop info", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// allowCookie=1\r", + "const jar = pm.cookies.jar();\r", + "jar.set(pm.environment.get(\"host\"), 'allowCookie', '1');" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/shops/1", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "shops", + "1" + ] + } + }, + "response": [] + } + ] }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] - } - }, - "response": [] - }, - { - "name": "SG: set export inactive", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"enable inactive product export\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "export_product_inactive", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "1", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] + "name": "Product", + "item": [ + { + "name": "SW: Get main product", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Get main product\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.data).to.haveOwnProperty('id').to.be.a('number');\r", + " pm.environment.set(\"gen_product_main_id\", jsonData.data.id);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/articles/SW10001?useNumberAsId=true", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "articles", + "SW10001" + ], + "query": [ + { + "key": "useNumberAsId", + "value": "true" + } + ] + } + }, + "response": [] + }, + { + "name": "SW: Get main category", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Get main category\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.data[0]).to.haveOwnProperty('id').to.be.a('number');\r", + " pm.environment.set(\"gen_category_main_id\", jsonData.data[0].id);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"filter\": [\r\n {\r\n \"property\": \"parentId\",\r\n \"expression\": \">\",\r\n \"value\": \"1\"\r\n }\r\n ],\r\n \"limit\": 1\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{sw_endpoint_api}}/categories", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "categories" + ] + } + }, + "response": [] + }, + { + "name": "SW: create inactive prod", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 201\", function () {\r", + " pm.response.to.have.status(201);\r", + "});\r", + "\r", + "pm.test(\"Get id of created product\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.data.id).to.be.a(\"number\");\r", + " pm.environment.set('created_product1_id', jsonData.data.id);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"name\": \"API: disabled product\",\r\n \"active\": false,\r\n \"tax\": 19,\r\n \"supplier\": \"Sport Shoes Inc.\",\r\n \"categories\": [\r\n {\r\n \"id\": {{gen_category_main_id}}\r\n }\r\n ],\r\n \"mainDetail\": {\r\n \"number\": \"API-INACTIVE\",\r\n \"active\": true,\r\n \"prices\": [\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"price\": 999\r\n }\r\n ]\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{sw_endpoint_api}}/articles", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "articles" + ] + } + }, + "response": [] + }, + { + "name": "SW: create price grp", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 201\", function () {\r", + " pm.response.to.have.status(201);\r", + "});\r", + "\r", + "pm.test(\"Get id of created product\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.data.id).to.be.a(\"number\");\r", + " pm.environment.set('created_product2_id', jsonData.data.id);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"name\": \"API: price grp product\",\r\n \"active\": true,\r\n \"tax\": 19,\r\n \"supplier\": \"Active Runners LLC\",\r\n \"categories\": [\r\n {\r\n \"id\": {{gen_category_main_id}}\r\n }\r\n ],\r\n \"lastStock\": true, // stock cannot go into negatives (saleable)\r\n \"priceGroupActive\": true,\r\n \"priceGroupId\": 1,\r\n \"mainDetail\": {\r\n \"number\": \"API-PRICE-GRP\",\r\n \"active\": true,\r\n \"prices\": [\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"from\": \"1\",\r\n \"to\": \"3\",\r\n \"price\": 200,\r\n \"pseudoPrice\": 250, // fake price to cross out\r\n \"basePrice\": 90\r\n },\r\n {\r\n \"customerGroupKey\": \"EK\",\r\n \"from\": \"4\",\r\n \"to\": \"7\",\r\n \"price\": 100,\r\n \"pseudoPrice\": 250,\r\n \"basePrice\": 90\r\n }\r\n ],\r\n \"inStock\": 500,\r\n \"minPurchase\": 2,\r\n \"maxPurchase\": 10,\r\n \"purchaseSteps\": 2,\r\n \"position\": 5\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{sw_endpoint_api}}/articles", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "articles" + ] + } + }, + "response": [] + } + ] } - }, - "response": [] - }, - { - "name": "SW: config cache clear", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/caches/config", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "caches", - "config" - ] - } - }, - "response": [] - }, - { - "name": "SG: try inactive export", - "event": [ + ] + }, + { + "name": "Catalog", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "pm.test(\"Check product gets exported now\", function () {", - " var jsonObject = xml2Json(responseBody);", - " pm.expect(jsonObject.items.item.$.uid).to.eql(pm.environment.get('created_product1_id').toString());", - " pm.expect(jsonObject.items.item.stock.is_saleable).to.eq('0');", - "});" + "name": "Export inactive", + "item": [ + { + "name": "SG: try inactive export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Make sure the product is not exported as it's inactive\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error).to.eql(82);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + }, + { + "key": "uids[]", + "value": "{{created_product1_id}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + }, + { + "name": "SG: set export inactive", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"enable inactive product export\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "export_product_inactive", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "1", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SW: config cache clear", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/caches/config", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "caches", + "config" + ] + } + }, + "response": [] + }, + { + "name": "SG: try inactive export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "pm.test(\"Check product gets exported now\", function () {", + " var jsonObject = xml2Json(responseBody);", + " pm.expect(jsonObject.items.item.$.uid).to.eql(pm.environment.get('created_product1_id').toString());", + " pm.expect(jsonObject.items.item.stock.is_saleable).to.eq('0');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + }, + { + "key": "uids[]", + "value": "{{created_product1_id}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + }, + { + "name": "SG: unset export inactive", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"disable inactive product export\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "export_product_inactive", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SW: config cache clear", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/caches/config", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "caches", + "config" + ] + } + }, + "response": [] + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" - }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - }, - { - "key": "uids[]", - "value": "{{created_product1_id}}", - "type": "text" - } - ] + "description": "SG-145 feature request. Exporting inactive products configuration." }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] - } - }, - "response": [] - }, - { - "name": "SG: unset export inactive", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"disable inactive product export\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", - "});" + "name": "Disable Cat Export", + "item": [ + { + "name": "SG: disable cat export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"enable setting\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"0\");", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "skip_category_assignment", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "1", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SG: get items w/o cats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "var jsonObject = xml2Json(responseBody);", + "pm.test(\"Check products have no categories exported\", function () {", + " console.log(jsonObject)", + " jsonObject.items.item.forEach(item => {", + " pm.expect(item.categories.category).to.be.undefined;", + " });", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + }, + { + "name": "SG: get cats normally", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "var jsonObject = xml2Json(responseBody);", + "pm.test(\"Check that categories are normally exporting\", function () {", + " pm.expect(jsonObject.items.category).to.be.lengthOf(5);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getCategories", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getCategories" + ] + } + }, + "response": [] + }, + { + "name": "SG: enable cat export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"enable inactive product export\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"1\");", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "skip_category_assignment", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SG: is normal export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "var jsonObject = xml2Json(responseBody);", + "pm.test(\"Check products have categories exported\", function () {", + " console.log(jsonObject)", + " jsonObject.items.item.forEach(item => {", + " pm.expect(item.categories.category).to.not.be.undefined;", + " });", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "export_product_inactive", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "0", - "type": "text" - } - ] + "description": "For merchants with expensive exports we allow to export products without categories. This should increase performance. Internal ref. SG-184." }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SW: config cache clear", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } + "name": "Check Prices (grps)", + "item": [ + { + "name": "SG: disable adv price export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"enable setting\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"0\");", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "skip_advanced_price_export", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "1", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SG: check no price export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "var jsonObject = xml2Json(responseBody);", + "pm.test(\"Check products have categories exported\", () => {", + " pm.expect(jsonObject.items.item.prices).to.not.be.undefined;", + " const price = jsonObject.items.item.prices;", + " pm.expect(price.price).to.eq('500');", + " pm.expect(price.sale_price).to.eq('400');", + " pm.expect(price.base_price).to.contain('200');", + " pm.expect(price.price).to.eq('500');", + "});", + "", + "pm.test(\"Check tier prices\", () => {", + " pm.expect(jsonObject.items.item.prices.tier_prices).to.be.undefined;", + "});", + "", + "function checkGrp(tier, discount, min, type, customerGrpId) {", + " pm.expect(tier._, 'incorrect discount').to.eq(discount);", + " pm.expect(tier.$.threshold, 'incorrect threshold').to.eq(min);", + " pm.expect(tier.$.type, 'icnorrect type').to.eq(type);", + " if (customerGrpId) {", + " pm.expect(tier.$.customer_group_uid, 'incorrect customer grp').to.eq(customerGrpId);", + " }", + "}", + "function checkFixedDiscount(tier, discount, min, type, max) {", + " checkGrp(tier, discount, min, type, null);", + " pm.expect(tier.$.max_quantity, 'incorrect max').to.eq(max);", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + }, + { + "key": "uids[]", + "value": "{{created_product2_id}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + }, + { + "name": "SG: enable adv price export", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"disable setting\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"1\");", + " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "skip_advanced_price_export", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } + }, + "response": [] + }, + { + "name": "SG: check prices", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Not an error\", function () {", + " pm.response.to.not.have.jsonBody('error');", + "});", + "", + "var jsonObject = xml2Json(responseBody);", + "pm.test(\"Check products have categories exported\", () => {", + " pm.expect(jsonObject.items.item.prices).to.not.be.undefined;", + " const price = jsonObject.items.item.prices;", + " pm.expect(price.price).to.eq('500');", + " pm.expect(price.sale_price).to.eq('400');", + " pm.expect(price.base_price).to.contain('200');", + " pm.expect(price.price).to.eq('500');", + "});", + "", + "pm.test(\"Check tier prices\", () => {", + " pm.expect(jsonObject.items.item.prices.tier_prices.tier_price).to.not.be.undefined;", + " const tiers = jsonObject.items.item.prices.tier_prices.tier_price;", + " checkGrp(tiers[0], '10', '5', 'percent', '1');", + " checkGrp(tiers[1], '20', '10', 'percent', '1');", + " checkGrp(tiers[2], '50', '15', 'percent', '1');", + " checkFixedDiscount(tiers[3], '200', '2', 'fixed', '3');", + "});", + "", + "function checkGrp(tier, discount, min, type, customerGrpId) {", + " pm.expect(tier._, 'incorrect discount').to.eq(discount);", + " pm.expect(tier.$.threshold, 'incorrect threshold').to.eq(min);", + " pm.expect(tier.$.type, 'icnorrect type').to.eq(type);", + " if (customerGrpId) {", + " pm.expect(tier.$.customer_group_uid, 'incorrect customer grp').to.eq(customerGrpId);", + " }", + "}", + "function checkFixedDiscount(tier, discount, min, type, max) {", + " checkGrp(tier, discount, min, type, null);", + " pm.expect(tier.$.max_quantity, 'incorrect max').to.eq(max);", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "*/*" + }, + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_get_items}}", + "type": "text" + }, + { + "key": "limit", + "value": "5", + "type": "text" + }, + { + "key": "offset", + "value": "0", + "type": "text" + }, + { + "key": "uids[]", + "value": "{{created_product2_id}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/getItems", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "getItems" + ] + } + }, + "response": [] + } + ] } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/caches/config", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "caches", - "config" - ] - } - }, - "response": [] - } - ], - "description": "SG-145 feature request. Exporting inactive products configuration." + ], + "description": "Catalog export related tests" }, { - "name": "Disable Cat Export", - "item": [ - { - "name": "SG: disable cat export", - "event": [ + "name": "Deactivate shop test", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"enable setting\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"0\");", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", - "});" + "name": "SG: try deactivate store", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"de-activation via plugin is not implemented\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.shopgate_settings).lengthOf(1);", + " pm.expect(jsonData.shopgate_settings[0].old).to.eq(false);", + "});" + ], + "type": "text/javascript" + } + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "skip_category_assignment", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "1", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SG: get items w/o cats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "var jsonObject = xml2Json(responseBody);", - "pm.test(\"Check products have no categories exported\", function () {", - " console.log(jsonObject)", - " jsonObject.items.item.forEach(item => {", - " pm.expect(item.categories.category).to.be.undefined;", - " });", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" - }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] - } - }, - "response": [] - }, - { - "name": "SG: get cats normally", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "var jsonObject = xml2Json(responseBody);", - "pm.test(\"Check that categories are normally exporting\", function () {", - " pm.expect(jsonObject.items.category).to.be.lengthOf(5);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "shop_is_active", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/setSettings", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "setSettings" + ] + } }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - } - ] + "response": [] }, - "url": { - "raw": "{{sg_endpoint_api}}/getCategories", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getCategories" - ] - } - }, - "response": [] - }, - { - "name": "SG: enable cat export", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"enable inactive product export\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"1\");", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", - "});" + "name": "SW: config cache clear", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/caches/config", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "caches", + "config" + ] + } }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "skip_category_assignment", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "0", - "type": "text" - } - ] + "response": [] }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SG: is normal export", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "var jsonObject = xml2Json(responseBody);", - "pm.test(\"Check products have categories exported\", function () {", - " console.log(jsonObject)", - " jsonObject.items.item.forEach(item => {", - " pm.expect(item.categories.category).to.not.be.undefined;", - " });", - "});" + "name": "SG: ping", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Ping works\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.pong).to.eq('OK');", + "});" + ], + "type": "text/javascript" + } + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" + "request": { + "method": "POST", + "header": [ + { + "key": "X-Shopgate-Auth-User", + "value": "{{gen_sg_header_auth_user}}" + }, + { + "key": "X-Shopgate-Auth-Token", + "value": "{{gen_sg_header_auth_token}}" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "shop_number", + "value": "{{sg_shop_number}}", + "type": "text" + }, + { + "key": "action", + "value": "{{framework_action_set_settings}}", + "type": "text" + }, + { + "key": "shopgate_settings[0][name]", + "value": "shop_is_active", + "type": "text" + }, + { + "key": "shopgate_settings[0][value]", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{sg_endpoint_api}}/ping", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "ping" + ] + } }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] + "response": [] } - }, - "response": [] - } - ], - "description": "For merchants with expensive exports we allow to export products without categories. This should increase performance. Internal ref. SG-184." + ], + "description": "SG runs a deactivation script after every import, so we need to make sure the store does not get deactivated by it\n\n```\n[shopgate_settings] => Array\n (\n [0] => Array\n (\n [name] => shop_is_active\n [value] => 0\n )\n\n )\n\n\n```\n\nStartFragment" }, { - "name": "Check Prices (grps)", - "item": [ - { - "name": "SG: disable adv price export", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"enable setting\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"0\");", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"1\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "skip_advanced_price_export", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "1", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SG: check no price export", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "var jsonObject = xml2Json(responseBody);", - "pm.test(\"Check products have categories exported\", () => {", - " pm.expect(jsonObject.items.item.prices).to.not.be.undefined;", - " const price = jsonObject.items.item.prices;", - " pm.expect(price.price).to.eq('500');", - " pm.expect(price.sale_price).to.eq('400');", - " pm.expect(price.base_price).to.contain('200');", - " pm.expect(price.price).to.eq('500');", - "});", - "", - "pm.test(\"Check tier prices\", () => {", - " pm.expect(jsonObject.items.item.prices.tier_prices).to.be.undefined;", - "});", - "", - "function checkGrp(tier, discount, min, type, customerGrpId) {", - " pm.expect(tier._, 'incorrect discount').to.eq(discount);", - " pm.expect(tier.$.threshold, 'incorrect threshold').to.eq(min);", - " pm.expect(tier.$.type, 'icnorrect type').to.eq(type);", - " if (customerGrpId) {", - " pm.expect(tier.$.customer_group_uid, 'incorrect customer grp').to.eq(customerGrpId);", - " }", - "}", - "function checkFixedDiscount(tier, discount, min, type, max) {", - " checkGrp(tier, discount, min, type, null);", - " pm.expect(tier.$.max_quantity, 'incorrect max').to.eq(max);", - "}" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" - }, - { - "key": "limit", - "value": "5", - "type": "text" - }, - { - "key": "offset", - "value": "0", - "type": "text" - }, - { - "key": "uids[]", - "value": "{{created_product2_id}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] - } - }, - "response": [] - }, - { - "name": "SG: enable adv price export", - "event": [ + "name": "Cleanup", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"disable setting\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].old).to.eq(\"1\");", - " pm.expect(jsonData.shopgate_settings[0].new).to.eq(\"0\");", - "});" + "name": "SW: remove prod 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Check success\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eq(true);\r", + "});" + ], + "type": "text/javascript" + } + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/articles/:articleId", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "articles", + ":articleId" + ], + "variable": [ + { + "key": "articleId", + "value": "{{created_product1_id}}" + } + ] + } }, - { - "key": "shopgate_settings[0][name]", - "value": "skip_advanced_price_export", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "0", - "type": "text" - } - ] + "response": [] }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SG: check prices", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Not an error\", function () {", - " pm.response.to.not.have.jsonBody('error');", - "});", - "", - "var jsonObject = xml2Json(responseBody);", - "pm.test(\"Check products have categories exported\", () => {", - " pm.expect(jsonObject.items.item.prices).to.not.be.undefined;", - " const price = jsonObject.items.item.prices;", - " pm.expect(price.price).to.eq('500');", - " pm.expect(price.sale_price).to.eq('400');", - " pm.expect(price.base_price).to.contain('200');", - " pm.expect(price.price).to.eq('500');", - "});", - "", - "pm.test(\"Check tier prices\", () => {", - " pm.expect(jsonObject.items.item.prices.tier_prices.tier_price).to.not.be.undefined;", - " const tiers = jsonObject.items.item.prices.tier_prices.tier_price;", - " checkGrp(tiers[0], '10', '5', 'percent', '1');", - " checkGrp(tiers[1], '20', '10', 'percent', '1');", - " checkGrp(tiers[2], '50', '15', 'percent', '1');", - " checkFixedDiscount(tiers[3], '200', '2', 'fixed', '3');", - "});", - "", - "function checkGrp(tier, discount, min, type, customerGrpId) {", - " pm.expect(tier._, 'incorrect discount').to.eq(discount);", - " pm.expect(tier.$.threshold, 'incorrect threshold').to.eq(min);", - " pm.expect(tier.$.type, 'icnorrect type').to.eq(type);", - " if (customerGrpId) {", - " pm.expect(tier.$.customer_group_uid, 'incorrect customer grp').to.eq(customerGrpId);", - " }", - "}", - "function checkFixedDiscount(tier, discount, min, type, max) {", - " checkGrp(tier, discount, min, type, null);", - " pm.expect(tier.$.max_quantity, 'incorrect max').to.eq(max);", - "}" + "name": "SW: remove prod 2", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Check success\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eq(true);\r", + "});" + ], + "type": "text/javascript" + } + } ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "*/*" - }, - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_get_items}}", - "type": "text" - }, - { - "key": "limit", - "value": "5", - "type": "text" + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/articles/:articleId", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "articles", + ":articleId" + ], + "variable": [ + { + "key": "articleId", + "value": "{{created_product2_id}}" + } + ] + } }, - { - "key": "offset", - "value": "0", - "type": "text" - }, - { - "key": "uids[]", - "value": "{{created_product2_id}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/getItems", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "getItems" - ] + "response": [] } - }, - "response": [] - } - ] - } - ], - "description": "Catalog export related tests" - }, - { - "name": "Deactivate shop test", - "item": [ - { - "name": "SG: try deactivate store", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"de-activation via plugin is not implemented\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.shopgate_settings).lengthOf(1);", - " pm.expect(jsonData.shopgate_settings[0].old).to.eq(false);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, - { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" - }, - { - "key": "shopgate_settings[0][name]", - "value": "shop_is_active", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "0", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/setSettings", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "setSettings" - ] - } - }, - "response": [] - }, - { - "name": "SW: config cache clear", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/caches/config", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "caches", - "config" - ] - } - }, - "response": [] + ] }, { - "name": "SG: ping", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Ping works\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.pong).to.eq('OK');", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-Shopgate-Auth-User", - "value": "{{gen_sg_header_auth_user}}" - }, - { - "key": "X-Shopgate-Auth-Token", - "value": "{{gen_sg_header_auth_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "shop_number", - "value": "{{sg_shop_number}}", - "type": "text" - }, + "name": "WebCheckout", + "item": [ { - "key": "action", - "value": "{{framework_action_set_settings}}", - "type": "text" + "name": "Login", + "item": [ + { + "name": "Guest", + "item": [ + { + "name": "SG: create guest cart", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});", + "", + "pm.test(\"Get session\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.sessionId).to.not.be.undefined;", + " pm.environment.set('gen_sessionId_guest', jsonData.sessionId);", + "});", + "", + "", + "// Allow cookie deletion by going to cookies -> Domain Allowlist", + "const jar = pm.cookies.jar();", + "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", + "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "User-Agent", + "value": "Shopgate PWA", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"articles\": [\n {\n \"product_id\": \"{{gen_product_main_id}}\",\n \"variant_id\": \"\",\n \"quantity\": 1,\n \"options\": []\n }\n ],\n \"customerId\": null\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{sg_endpoint_api}}/addToCart", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "addToCart" + ] + } + }, + "response": [] + }, + { + "name": "SG: login guest", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $", + "const $ = cheerio.load(pm.response.text());", + "pm.test(\"Check that guest got logged in\", function () {", + " const productInCart = $('.content--sku.content');", + " pm.expect(productInCart).to.be.not.undefined;", + " pm.expect(productInCart.text()).to.contain('SW10001');", + "});", + "", + "// Allow cookie deletion by going to cookies -> Domain Allowlist", + "const jar = pm.cookies.jar();", + "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", + "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "libshopgate", + "type": "text" + } + ], + "url": { + "raw": "{{sg_endpoint_api}}/login?sessionId={{gen_sessionId_guest}}&guest=1&redirectTo=checkout.cart", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "login" + ], + "query": [ + { + "key": "sessionId", + "value": "{{gen_sessionId_guest}}" + }, + { + "key": "guest", + "value": "1" + }, + { + "key": "redirectTo", + "value": "checkout.cart" + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "SW: Get customer 1", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// allowCookie=1\r", + "const jar = pm.cookies.jar();\r", + "jar.set(pm.environment.get(\"host\"), 'allowCookie', '1');" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"get customer data\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.not.be.undefined;", + " pm.expect(jsonData.data.number).to.not.be.undefined;", + " pm.environment.set('gen_customer_1_num', jsonData.data.number);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{sw_endpoint_api}}/customers/1", + "host": [ + "{{sw_endpoint_api}}" + ], + "path": [ + "customers", + "1" + ] + } + }, + "response": [] + }, + { + "name": "SG: login customer", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $", + "const $ = cheerio.load(pm.response.text());", + "pm.test(\"Check that customer got logged in\", function () {", + " const greeting = $('.account--display-greeting');", + " pm.expect(greeting).to.be.not.undefined;", + " pm.expect(greeting.text()).to.contain('Max');", + "});", + "", + "// Allow cookie deletion by going to cookies -> Domain Allowlist", + "const jar = pm.cookies.jar();", + "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", + "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "jwt", + "jwt": [ + { + "key": "payload", + "value": "{\"customer_id\": \"{{gen_customer_1_num}}\"}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "queryParam", + "type": "string" + }, + { + "key": "secret", + "value": "{{sg_api_key}}", + "type": "string" + }, + { + "key": "isSecretBase64Encoded", + "value": false, + "type": "boolean" + }, + { + "key": "algorithm", + "value": "HS256", + "type": "string" + }, + { + "key": "headerPrefix", + "value": "Bearer", + "type": "string" + }, + { + "key": "queryParamKey", + "value": "token", + "type": "string" + }, + { + "key": "header", + "value": "{}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "PostmanRuntime libshopgate", + "type": "text" + } + ], + "url": { + "raw": "{{sg_endpoint_api}}/login", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "SG: login & prod page", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $", + "const $ = cheerio.load(pm.response.text());", + "pm.test(\"Check that we have a sessionId being sent to App\", function () {", + " const session = $('script:contains(\"sessionId\")');", + " pm.expect(session).to.be.not.undefined;", + " pm.expect(session.text()).to.contain(\"{'sessionId': '\");", + "});", + "", + "// Allow cookie deletion by going to cookies -> Domain Allowlist", + "const jar = pm.cookies.jar();", + "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", + "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "jwt", + "jwt": [ + { + "key": "payload", + "value": "{\"customer_id\": \"{{gen_customer_1_num}}\"}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "queryParam", + "type": "string" + }, + { + "key": "secret", + "value": "{{sg_api_key}}", + "type": "string" + }, + { + "key": "isSecretBase64Encoded", + "value": false, + "type": "boolean" + }, + { + "key": "algorithm", + "value": "HS256", + "type": "string" + }, + { + "key": "headerPrefix", + "value": "Bearer", + "type": "string" + }, + { + "key": "queryParamKey", + "value": "token", + "type": "string" + }, + { + "key": "header", + "value": "{}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "PostmanRuntime libshopgate", + "type": "text" + } + ], + "url": { + "raw": "{{sg_endpoint_api}}/login?redirectTo=detail.index.sArticle.3", + "host": [ + "{{sg_endpoint_api}}" + ], + "path": [ + "login" + ], + "query": [ + { + "key": "redirectTo", + "value": "detail.index.sArticle.3" + } + ] + }, + "description": "Logs in, redirects to product page & checks that the session is being sent to the App." + }, + "response": [] + } + ] }, { - "key": "shopgate_settings[0][name]", - "value": "shop_is_active", - "type": "text" - }, - { - "key": "shopgate_settings[0][value]", - "value": "0", - "type": "text" - } - ] - }, - "url": { - "raw": "{{sg_endpoint_api}}/ping", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "ping" - ] - } - }, - "response": [] - } - ], - "description": "SG runs a deactivation script after every import, so we need to make sure the store does not get deactivated by it\n\n```\n[shopgate_settings] => Array\n (\n [0] => Array\n (\n [name] => shop_is_active\n [value] => 0\n )\n\n )\n\n\n```\n\nStartFragment" - }, - { - "name": "Cleanup", - "item": [ - { - "name": "SW: remove prod 1", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test(\"Check success\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.success).to.eq(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/articles/:articleId", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "articles", - ":articleId" - ], - "variable": [ - { - "key": "articleId", - "value": "{{created_product1_id}}" - } - ] - } - }, - "response": [] - }, - { - "name": "SW: remove prod 2", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test(\"Check success\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.success).to.eq(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/articles/:articleId", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "articles", - ":articleId" - ], - "variable": [ - { - "key": "articleId", - "value": "{{created_product2_id}}" + "name": "SG-208 react native base", + "item": [ + { + "name": "Old app - Apple", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $\r", + "const $ = cheerio.load(pm.response.text());\r", + "\r", + "pm.test(\"Check we redirected to register page\", function () {\r", + " const bodyClass = $('.is-sg-codebase-v1');\r", + " console.log(bodyClass);\r", + " pm.expect(bodyClass).to.be.lengthOf(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow cookie deletion by going to cookies -> Domain Allowlist\r", + "const jar = pm.cookies.jar();\r", + "jar.unset(pm.environment.get(\"host\"), 'session-', function (error) {\r", + " if (error) {\r", + " console.log(error.message)\r", + " }\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disabledSystemHeaders": {} + }, + "request": { + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "PostmanRuntime Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 libshopgate/25.0 (Shopgate Standalone 10.75.0 Codebase:10.75.0 NOAPPLEPAY)", + "type": "text", + "description": "Apple old WebC version" + } + ], + "url": { + "raw": "{{sw_domain}}/account#show-registration", + "host": [ + "{{sw_domain}}" + ], + "path": [ + "account" + ], + "hash": "show-registration" + } + }, + "response": [] + }, + { + "name": "Old app - Android", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $\r", + "const $ = cheerio.load(pm.response.text());\r", + "\r", + "pm.test(\"Check we redirected to register page\", function () {\r", + " const bodyClass = $('.is-sg-codebase-v1');\r", + " pm.expect(bodyClass).to.be.lengthOf(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow cookie deletion by going to cookies -> Domain Allowlist\r", + "const jar = pm.cookies.jar();\r", + "jar.unset(pm.environment.get(\"host\"), 'session-', function (error) {\r", + " if (error) {\r", + " console.log(error.message)\r", + " }\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disabledSystemHeaders": {} + }, + "request": { + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "PostmanRuntime Mozilla/5.0 (Linux; Android 12; Nokia 5.3 Build/SKQ1.211230.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.230 Mobile Safari/537.36 libshopgate/25.0 (Shopgate 5.43.0 Codebase:5.43.0) Mozilla/5.0 (Linux; Android 12; Nokia 5.3 Build/SKQ1.211230.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.143 Mobile Safari/537.36 libshopgate/25.0 (Bowling Shop Berlin 24 5.58.0 Codebase:5.58.0)", + "type": "text", + "description": "Android old WebC version" + } + ], + "url": { + "raw": "{{sw_domain}}/account/login", + "host": [ + "{{sw_domain}}" + ], + "path": [ + "account", + "login" + ] + } + }, + "response": [] + }, + { + "name": "Native App", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $\r", + "const $ = cheerio.load(pm.response.text());\r", + "\r", + "pm.test(\"Check we redirected to register page\", function () {\r", + " const bodyClass = $('.is-sg-codebase-v2');\r", + " pm.expect(bodyClass).to.be.lengthOf(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow cookie deletion by going to cookies -> Domain Allowlist\r", + "const jar = pm.cookies.jar();\r", + "jar.unset(pm.environment.get(\"host\"), 'session-', function (error) {\r", + " if (error) {\r", + " console.log(error.message)\r", + " }\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disabledSystemHeaders": {} + }, + "request": { + "method": "GET", + "header": [ + { + "key": "User-Agent", + "value": "PostmanRuntime Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 libshopgate/25.0 (RN Engage 11.0.0-beta.5 Codebase:11.0.0-beta.5) Mozilla/5.0 (Linux; Android 12; Nokia 5.3 Build/SKQ1.211230.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.143 Mobile Safari/537.36 libshopgate/25.0 (Jagdwelt 24 11.0.2 Codebase:11.0.2)", + "type": "text", + "description": "New WebC version" + } + ], + "url": { + "raw": "{{sw_domain}}/account/login", + "host": [ + "{{sw_domain}}" + ], + "path": [ + "account", + "login" + ] + } + }, + "response": [] + }, + { + "name": "No app", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Load the HTML response to $\r", + "const $ = cheerio.load(pm.response.text());\r", + "\r", + "pm.test(\"Check we redirected to register page\", function () {\r", + " const bodyClass = $('.is-sg-codebase-v1')\r", + " pm.expect(bodyClass).to.be.lengthOf(0);\r", + " const classTwo = $('.is-sg-codebase-v2')\r", + " pm.expect(classTwo).to.be.lengthOf(0);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow cookie deletion by going to cookies -> Domain Allowlist\r", + "const jar = pm.cookies.jar();\r", + "jar.unset(pm.environment.get(\"host\"), 'session-', function (error) {\r", + " if (error) {\r", + " console.log(error.message)\r", + " }\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disabledSystemHeaders": {} + }, + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{sw_domain}}/account/login", + "host": [ + "{{sw_domain}}" + ], + "path": [ + "account", + "login" + ] + } + }, + "response": [] + } + ], + "description": "Newer app does not need header margin-top setting. We will need to remove it when the Shopgate `Codebase` in the User-Agent is more than 11 & make sure it doesn't appear" } - ] - } - }, - "response": [] + ] } - ] - }, - { - "name": "WebCheckout", - "item": [ - { - "name": "SW: Get customer 1", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "// allowCookie=1\r", - "const jar = pm.cookies.jar();\r", - "jar.set(pm.environment.get(\"host\"), 'allowCookie', '1');" - ], - "type": "text/javascript" - } - }, + ], + "auth": { + "type": "basic", + "basic": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"get customer data\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.data).to.not.be.undefined;", - " pm.expect(jsonData.data.number).to.not.be.undefined;", - " pm.environment.set('gen_customer_1_num', jsonData.data.number);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{sw_endpoint_api}}/customers/1", - "host": [ - "{{sw_endpoint_api}}" - ], - "path": [ - "customers", - "1" - ] - } - }, - "response": [] - }, - { - "name": "SG: login customer", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "// Load the HTML response to $", - "const $ = cheerio.load(pm.response.text());", - "pm.test(\"Check that customer got logged in\", function () {", - " const greeting = $('.account--display-greeting');", - " pm.expect(greeting).to.be.not.undefined;", - " pm.expect(greeting.text()).to.contain('Max');", - "});", - "", - "// Allow cookie deletion by going to cookies -> Domain Allowlist", - "const jar = pm.cookies.jar();", - "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", - "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "jwt", - "jwt": [ - { - "key": "payload", - "value": "{\"customer_id\": \"{{gen_customer_1_num}}\"}", - "type": "string" - }, - { - "key": "addTokenTo", - "value": "queryParam", - "type": "string" - }, - { - "key": "secret", - "value": "{{sg_api_key}}", - "type": "string" - }, - { - "key": "isSecretBase64Encoded", - "value": false, - "type": "boolean" - }, - { - "key": "algorithm", - "value": "HS256", - "type": "string" - }, - { - "key": "headerPrefix", - "value": "Bearer", - "type": "string" - }, - { - "key": "queryParamKey", - "value": "token", - "type": "string" - }, - { - "key": "header", - "value": "{}", - "type": "string" - } - ] + "key": "password", + "value": "{{sw_api_key}}", + "type": "string" }, - "method": "GET", - "header": [ - { - "key": "User-Agent", - "value": "PostmanRuntime libshopgate", - "type": "text" - } - ], - "url": { - "raw": "{{sg_endpoint_api}}/login", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "login" - ] - } - }, - "response": [] - }, - { - "name": "SG: create guest cart", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - "});", - "", - "pm.test(\"Get session\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.sessionId).to.not.be.undefined;", - " pm.environment.set('gen_sessionId_guest', jsonData.sessionId);", - "});", - "", - "", - "// Allow cookie deletion by going to cookies -> Domain Allowlist", - "const jar = pm.cookies.jar();", - "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", - "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "User-Agent", - "value": "Shopgate PWA", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"articles\": [\n {\n \"product_id\": \"{{gen_product_main_id}}\",\n \"variant_id\": \"\",\n \"quantity\": 1,\n \"options\": []\n }\n ],\n \"customerId\": null\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{sg_endpoint_api}}/addToCart", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "addToCart" - ] + "key": "username", + "value": "demo", + "type": "string" } - }, - "response": [] - }, + ] + }, + "event": [ { - "name": "SG: login guest", - "event": [ - { - "listen": "test", - "script": { + "listen": "prerequest", + "script": { + "type": "text/javascript", "exec": [ - "// Load the HTML response to $", - "const $ = cheerio.load(pm.response.text());", - "pm.test(\"Check that guest got logged in\", function () {", - " const productInCart = $('.content--sku.content');", - " pm.expect(productInCart).to.be.not.undefined;", - " pm.expect(productInCart.text()).to.contain('SW10001');", - "});", - "", - "// Allow cookie deletion by going to cookies -> Domain Allowlist", - "const jar = pm.cookies.jar();", - "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", - "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{sg_endpoint_api}}/login?sessionId={{gen_sessionId_guest}}&guest=1&redirectTo=checkout.cart", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "login" - ], - "query": [ - { - "key": "sessionId", - "value": "{{gen_sessionId_guest}}" - }, - { - "key": "guest", - "value": "1" - }, - { - "key": "redirectTo", - "value": "checkout.cart" - } - ] + "/**", + " * SG Token generation", + " */", + "var tstamp = Math.floor(Date.now() / 1000);", + "", + "// Use the CryptoJS", + "var authUser = pm.environment.get('sg_customer_number') + \"-\" + tstamp;", + "var tokenData = \"SPA-\" + pm.environment.get('sg_customer_number') + \"-\" + tstamp + \"-\" + pm.environment.get('sg_api_key');", + "", + "var authToken = CryptoJS.SHA1(tokenData).toString();", + "", + "// Set the new header values", + "pm.environment.set(\"gen_sg_header_auth_user\", authUser);", + "pm.environment.set(\"gen_sg_header_auth_token\", authToken);" + ] } - }, - "response": [] }, { - "name": "SG: login & prod page", - "event": [ - { - "listen": "test", - "script": { + "listen": "test", + "script": { + "type": "text/javascript", "exec": [ - "// Load the HTML response to $", - "const $ = cheerio.load(pm.response.text());", - "pm.test(\"Check that we have a sessionId being sent to App\", function () {", - " const session = $('script:contains(\"sessionId\")');", - " pm.expect(session).to.be.not.undefined;", - " pm.expect(session.text()).to.contain(\"{'sessionId': '\");", - "});", - "", - "// Allow cookie deletion by going to cookies -> Domain Allowlist", - "const jar = pm.cookies.jar();", - "jar.unset(pm.environment.get(\"host\"), 'session-1', (error) => error && console.log(error.message));", - "jar.unset(pm.environment.get(\"host\"), 'slt', (error) => error && console.log(error.message));" - ], - "type": "text/javascript" - } + "" + ] } - ], - "request": { - "auth": { - "type": "jwt", - "jwt": [ - { - "key": "payload", - "value": "{\"customer_id\": \"{{gen_customer_1_num}}\"}", - "type": "string" - }, - { - "key": "addTokenTo", - "value": "queryParam", - "type": "string" - }, - { - "key": "secret", - "value": "{{sg_api_key}}", - "type": "string" - }, - { - "key": "isSecretBase64Encoded", - "value": false, - "type": "boolean" - }, - { - "key": "algorithm", - "value": "HS256", - "type": "string" - }, - { - "key": "headerPrefix", - "value": "Bearer", - "type": "string" - }, - { - "key": "queryParamKey", - "value": "token", - "type": "string" - }, - { - "key": "header", - "value": "{}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [ - { - "key": "User-Agent", - "value": "PostmanRuntime libshopgate", - "type": "text" - } - ], - "url": { - "raw": "{{sg_endpoint_api}}/login?redirectTo=detail.index.sArticle.3", - "host": [ - "{{sg_endpoint_api}}" - ], - "path": [ - "login" - ], - "query": [ - { - "key": "redirectTo", - "value": "detail.index.sArticle.3" - } - ] - }, - "description": "Logs in, redirects to product page & checks that the session is being sent to the App." - }, - "response": [] } - ] - } - ], - "auth": { - "type": "basic", - "basic": [ - { - "key": "password", - "value": "{{sw_api_key}}", - "type": "string" - }, - { - "key": "username", - "value": "demo", - "type": "string" - } ] - }, - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "/**", - " * SG Token generation", - " */", - "var tstamp = Math.floor(Date.now() / 1000);", - "", - "// Use the CryptoJS", - "var authUser = pm.environment.get('sg_customer_number') + \"-\" + tstamp;", - "var tokenData = \"SPA-\" + pm.environment.get('sg_customer_number') + \"-\" + tstamp + \"-\" + pm.environment.get('sg_api_key');", - "", - "var authToken = CryptoJS.SHA1(tokenData).toString();", - "", - "// Set the new header values", - "pm.environment.set(\"gen_sg_header_auth_user\", authUser);", - "pm.environment.set(\"gen_sg_header_auth_token\", authToken);" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] }