From c25b86a188c28a37a6ec20e050e3b1a88c3d61fa Mon Sep 17 00:00:00 2001 From: Refringe Date: Mon, 8 Apr 2024 16:26:51 -0400 Subject: [PATCH] Removes outdated deploy files --- .ansible/inventory | 11 - .ansible/playbook.yml | 49 - .ansible/requirements.yml | 2 - .ansible/templates/.php-env.j2 | 19 - .ansible/templates/app.blade.php.j2 | 23 - .drone-docker.yml | 102 - ...layer-Tarkov-Items.postman_collection.json | 3255 ----------------- docs/Walkthrough.md | 293 -- 8 files changed, 3754 deletions(-) delete mode 100644 .ansible/inventory delete mode 100644 .ansible/playbook.yml delete mode 100644 .ansible/requirements.yml delete mode 100644 .ansible/templates/.php-env.j2 delete mode 100644 .ansible/templates/app.blade.php.j2 delete mode 100644 .drone-docker.yml delete mode 100644 docs/Singleplayer-Tarkov-Items.postman_collection.json delete mode 100644 docs/Walkthrough.md diff --git a/.ansible/inventory b/.ansible/inventory deleted file mode 100644 index 5301913..0000000 --- a/.ansible/inventory +++ /dev/null @@ -1,11 +0,0 @@ -all: - children: - sptarkov: - hosts: - sp-tarkov: - ansible_host: {{ DEPLOY_HOSTNAME }} - ansible_user: {{ DEPLOY_USER }} - ansible_connection: paramiko_ssh - ansible_ssh_pass: {{ DEPLOY_SSH_KEY_PASSPHRASE }} - ansible_ssh_user: {{ DEPLOY_USER }} - ansible_ssh_private_key_file: /drone/src/private.key # Hardcoded because created by the Drone plugin \ No newline at end of file diff --git a/.ansible/playbook.yml b/.ansible/playbook.yml deleted file mode 100644 index 97683b0..0000000 --- a/.ansible/playbook.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- name: install and configure PHP8 and composer - hosts: sptarkov - - tasks: - - name: Delete spt-items-api before adding everything again - file: - state: absent - path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" - - name: Copy the project - copy: - src: ../api/ - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" - - name: Copy PHP .env file - template: - src: ./templates/.php-env.j2 - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}/.env" - - name: Get JS chunks name - shell: - cmd: find "{{ lookup('env', 'SPT_ITEMS_PATH') }}" -type f -name "*chunk.js" -printf "%f\n" - register: find_output - - name: Get file names from find output - set_fact: - chunk_list: "{{ find_output['stdout'].split('\n') }}" - - name: Copy app.blade.php file - template: - src: ./templates/app.blade.php.j2 - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}/resources/views/app.blade.php" - - - name: Download and installs all composer libs and dependencies - community.general.composer: - command: install - working_dir: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" - - # Ensure the permissions - - name: Reset files permissions - file: - path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" - owner: "{{ lookup('env', 'DEPLOY_USER') }}" - group: "{{ lookup('env', 'DEPLOY_USER_GROUP') }}" - mode: 0775 - recurse: yes - - - name: Initialize database - uri: - url: "https://{{ lookup('env', 'SPT_ITEMS_HOSTNAME') }}/api/refresh" - method: GET - status_code: [200, 204] - timeout: 60 \ No newline at end of file diff --git a/.ansible/requirements.yml b/.ansible/requirements.yml deleted file mode 100644 index 8230258..0000000 --- a/.ansible/requirements.yml +++ /dev/null @@ -1,2 +0,0 @@ -collections: -- name: community.general # For composer \ No newline at end of file diff --git a/.ansible/templates/.php-env.j2 b/.ansible/templates/.php-env.j2 deleted file mode 100644 index a5166a2..0000000 --- a/.ansible/templates/.php-env.j2 +++ /dev/null @@ -1,19 +0,0 @@ -APP_NAME="Item Finder" -APP_ENV=production -APP_KEY= -APP_DEBUG=false -APP_URL="https://{{ lookup('env', 'SPT_ITEMS_HOSTNAME') }}" -APP_TIMEZONE=UTC - -LOG_CHANNEL=stack -LOG_SLACK_WEBHOOK_URL= - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret - -CACHE_DRIVER=file -QUEUE_CONNECTION=sync \ No newline at end of file diff --git a/.ansible/templates/app.blade.php.j2 b/.ansible/templates/app.blade.php.j2 deleted file mode 100644 index 643efe2..0000000 --- a/.ansible/templates/app.blade.php.j2 +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - Item Finder - - - -
- - {% for chunk in chunk_list %} - - {% endfor %} - - - diff --git a/.drone-docker.yml b/.drone-docker.yml deleted file mode 100644 index ea92d0a..0000000 --- a/.drone-docker.yml +++ /dev/null @@ -1,102 +0,0 @@ -kind: pipeline -type: docker -name: db deployment - -trigger: - event: - - push - -steps: - - name: replace hosts and user variables - image: ubuntu:impish - environment: - SPT_ITEMS_HOSTNAME: - from_secret: spt_items_hostname - DEPLOY_HOSTNAME: - from_secret: deploy_hostname - DEPLOY_USER: - from_secret: deploy_username - DEPLOY_PRIVATE_KEY: - from_secret: deploy_ssh_key - DEPLOY_SSH_KEY_PASSPHRASE: - from_secret: deploy_ssh_key_passphrase - commands: - - sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./frontend/.env.example - - mv ./frontend/.env.example ./frontend/.env - - echo "$DEPLOY_PRIVATE_KEY" > private.key && chmod 600 private.key - - sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible/inventory - - sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible/inventory - - sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible/inventory - - - name: install dependencies and build frontend - image: node:lts-alpine3.14 - commands: - - node -v - - npm -v - - yarn --version - - yarn --cwd ./frontend install - - yarn --cwd ./frontend build --pure-lockfile - - rm -rf ./api/public/static/* - - cp -r ./frontend/build/* ./api/public - - rm ./api/public/index.html - depends_on: - - replace hosts and user variables - - - name: frontend - image: nginx:1.21.4-alpine - commands: - - cp -r ./frontend/build/* /usr/share/nginx/html - - cp ./frontend/src/cypress/nginx_config/default.conf /etc/nginx/conf.d/default.conf - - nginx -g "daemon off;" - detach: true - depends_on: - - install dependencies and build frontend - - - name: test frontend - image: cypress/browsers:node16.5.0-chrome94-ff93 - commands: - - node -v - - npm -v - - yarn --version - - yarn --cwd ./frontend cy:ci - depends_on: - - install dependencies and build frontend - - - name: check db ansible syntax - image: plugins/ansible:3 - settings: - playbook: ./.ansible/playbook.yml - inventory: ./.ansible/inventory - galaxy: ./.ansible/requirements.yml - syntax_check: true - depends_on: - - clone - when: - branch: - - development - - - name: apply ansible playbook for items database - image: plugins/ansible:3 - settings: - playbook: ./.ansible/playbook.yml - inventory: ./.ansible/inventory - galaxy: ./.ansible/requirements.yml - timeout: 60 - verbose: 2 - environment: - SPT_ITEMS_HOSTNAME: - from_secret: spt_items_hostname - DEPLOY_HOSTNAME: - from_secret: deploy_hostname - DEPLOY_USER: - from_secret: deploy_username - DEPLOY_USER_GROUP: - from_secret: deploy_user_group - SPT_ITEMS_PATH: - from_secret: db_deploy_path - depends_on: - - test frontend - when: - branch: - - master - - main \ No newline at end of file diff --git a/docs/Singleplayer-Tarkov-Items.postman_collection.json b/docs/Singleplayer-Tarkov-Items.postman_collection.json deleted file mode 100644 index 96a2136..0000000 --- a/docs/Singleplayer-Tarkov-Items.postman_collection.json +++ /dev/null @@ -1,3255 +0,0 @@ -{ - "info": { - "_postman_id": "9901d119-c259-4502-af52-588e6084f007", - "name": "Singleplayer-Tarkov-Items", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "3974453" - }, - "item": [ - { - "name": "Local", - "item": [ - { - "name": "Default locale", - "item": [ - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\",\n \"_props\": {\n \"AllowSpawnOnLocations\": [],\n \"AnimationVariantsNumber\": 0,\n \"BackgroundColor\": \"orange\",\n \"CanRequireOnRagfair\": true,\n \"CanSellOnRagfair\": true,\n \"ChangePriceCoef\": 1,\n \"ConflictingItems\": [],\n \"CreditsPrice\": 24943,\n \"Description\": \"Condensed milk\",\n \"DiscardingBlock\": false,\n \"ExamineExperience\": 20,\n \"ExamineTime\": 1,\n \"ExaminedByDefault\": false,\n \"ExtraSizeDown\": 0,\n \"ExtraSizeForceAdd\": false,\n \"ExtraSizeLeft\": 0,\n \"ExtraSizeRight\": 0,\n \"ExtraSizeUp\": 0,\n \"FixedPrice\": false,\n \"Height\": 1,\n \"HideEntrails\": false,\n \"IsAlwaysAvailableForInsurance\": false,\n \"IsLockedafterEquip\": false,\n \"IsUnbuyable\": false,\n \"IsUndiscardable\": false,\n \"IsUngivable\": false,\n \"IsUnsaleable\": false,\n \"ItemSound\": \"food_tin_can\",\n \"LootExperience\": 50,\n \"MaxResource\": 1,\n \"MergesWithChildren\": false,\n \"Name\": \"Condensed milk\",\n \"NotShownInSlot\": false,\n \"Prefab\": {\n \"path\": \"assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_loot.bundle\",\n \"rcid\": \"\"\n },\n \"QuestItem\": false,\n \"RagFairCommissionModifier\": 1,\n \"Rarity\": \"Rare\",\n \"RepairCost\": 0,\n \"RepairSpeed\": 0,\n \"SendToClient\": false,\n \"ShortName\": \"Condensed milk\",\n \"SpawnChance\": 9,\n \"StackMaxSize\": 1,\n \"StackObjectsCount\": 1,\n \"StimulatorBuffs\": \"Buffs_food_condensed_milk\",\n \"Unlootable\": false,\n \"UnlootableFromSide\": [],\n \"UnlootableFromSlot\": \"FirstPrimaryWeapon\",\n \"UsePrefab\": {\n \"path\": \"assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_container.bundle\",\n \"rcid\": \"\"\n },\n \"Weight\": 0.4,\n \"Width\": 1,\n \"effects_damage\": [],\n \"effects_health\": {\n \"Energy\": {\n \"value\": 75\n },\n \"Hydration\": {\n \"value\": -65\n }\n },\n \"foodEffectType\": \"afterUse\",\n \"foodUseTime\": 4\n },\n \"_proto\": \"5734770f24597738025ee254\",\n \"_type\": \"Item\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n}" - } - ] - }, - { - "name": "Get item Name by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Can of condensed milk');\r", - "});\r", - "\r", - "pm.test('Item short name is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.ShortName).to.eql('Cond. milk');\r", - "});\r", - "\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/nameByID?id=5734773724597737fd047c14", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "nameByID" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n}" - } - ] - }, - { - "name": "Get item Names", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Returns more than one result', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).length.to.greaterThan(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/names", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "names" - ] - } - }, - "response": [ - { - "name": "Get Item Names", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "[\n {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n }\n]" - } - ] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Can of condensed milk');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Condensed milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Cond. milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "English locale", - "item": [ - { - "name": "Get item Name by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Can of condensed milk');\r", - "});\r", - "\r", - "pm.test('Item short name is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.ShortName).to.eql('Cond. milk');\r", - "});\r", - "\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/nameByID?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "nameByID" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n}" - } - ] - }, - { - "name": "Get item Names", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Returns more than one result', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).length.to.greaterThan(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/names?locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "names" - ], - "query": [ - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [ - { - "name": "Get Item Names", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "[\n {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n }\n]" - } - ] - }, - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Can of condensed milk');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14&locale=en", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "en" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Condensed milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Can of condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Cond. milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"LOCALE\", \"en\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "French locale", - "item": [ - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Conserve de lait concentré');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14&locale=fr", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "fr" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Lait concentré\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Lait conc.\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Get item Name by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Conserve de lait concentré');\r", - "});\r", - "\r", - "pm.test('Item short name is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.ShortName).to.eql('Lait conc.');\r", - "});\r", - "\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/nameByID?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "nameByID" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n}" - } - ] - }, - { - "name": "Get item Names", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Returns more than one result', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).length.to.greaterThan(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/names?locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "names" - ], - "query": [ - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [ - { - "name": "Get Item Names", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "[\n {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n },\n \"locale\": {\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n }\n]" - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"LOCALE\", \"fr\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "RefreshAll", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.expect(pm.response.code).to.be.oneOf([200,204]);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/refresh", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "refresh" - ] - } - }, - "response": [] - }, - { - "name": "Get all locales", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('At least one locale is present', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).length.greaterThan(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/locales/", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "locales", - "" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"SPT_API\", \"http://localhost:8000\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "Deployed", - "item": [ - { - "name": "Default locale", - "item": [ - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\",\n \"_props\": {\n \"AllowSpawnOnLocations\": [],\n \"AnimationVariantsNumber\": 0,\n \"BackgroundColor\": \"orange\",\n \"CanRequireOnRagfair\": true,\n \"CanSellOnRagfair\": true,\n \"ChangePriceCoef\": 1,\n \"ConflictingItems\": [],\n \"CreditsPrice\": 24943,\n \"Description\": \"Condensed milk\",\n \"DiscardingBlock\": false,\n \"ExamineExperience\": 20,\n \"ExamineTime\": 1,\n \"ExaminedByDefault\": false,\n \"ExtraSizeDown\": 0,\n \"ExtraSizeForceAdd\": false,\n \"ExtraSizeLeft\": 0,\n \"ExtraSizeRight\": 0,\n \"ExtraSizeUp\": 0,\n \"FixedPrice\": false,\n \"Height\": 1,\n \"HideEntrails\": false,\n \"IsAlwaysAvailableForInsurance\": false,\n \"IsLockedafterEquip\": false,\n \"IsUnbuyable\": false,\n \"IsUndiscardable\": false,\n \"IsUngivable\": false,\n \"IsUnsaleable\": false,\n \"ItemSound\": \"food_tin_can\",\n \"LootExperience\": 50,\n \"MaxResource\": 1,\n \"MergesWithChildren\": false,\n \"Name\": \"Condensed milk\",\n \"NotShownInSlot\": false,\n \"Prefab\": {\n \"path\": \"assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_loot.bundle\",\n \"rcid\": \"\"\n },\n \"QuestItem\": false,\n \"RagFairCommissionModifier\": 1,\n \"Rarity\": \"Rare\",\n \"RepairCost\": 0,\n \"RepairSpeed\": 0,\n \"SendToClient\": false,\n \"ShortName\": \"Condensed milk\",\n \"SpawnChance\": 9,\n \"StackMaxSize\": 1,\n \"StackObjectsCount\": 1,\n \"StimulatorBuffs\": \"Buffs_food_condensed_milk\",\n \"Unlootable\": false,\n \"UnlootableFromSide\": [],\n \"UnlootableFromSlot\": \"FirstPrimaryWeapon\",\n \"UsePrefab\": {\n \"path\": \"assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_container.bundle\",\n \"rcid\": \"\"\n },\n \"Weight\": 0.4,\n \"Width\": 1,\n \"effects_damage\": [],\n \"effects_health\": {\n \"Energy\": {\n \"value\": 75\n },\n \"Hydration\": {\n \"value\": -65\n }\n },\n \"foodEffectType\": \"afterUse\",\n \"foodUseTime\": 4\n },\n \"_proto\": \"5734770f24597738025ee254\",\n \"_type\": \"Item\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n}" - } - ] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Condensed milk');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Condensed milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Cond. milk\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "English locale", - "item": [ - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Condensed milk');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14&locale=en", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "en" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Condensed milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Condensed milk');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Cond. milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"LOCALE\", \"en\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "French locale", - "item": [ - { - "name": "Get item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item?id=5734773724597737fd047c14&locale={{LOCALE}}", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "{{LOCALE}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Get item hierarchy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].item._id).to.eql(id);\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " var id = pm.request.toJSON().url.query[0].value;\r", - " pm.expect(jsonData[id].locale.Name).to.eql('Conserve de lait concentré');\r", - "});\r", - "\r", - "pm.test('Check we get all the hierarchy', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(Object.keys(jsonData).length).to.eql(4);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/item/hierarchy?id=5734773724597737fd047c14&locale=fr", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "hierarchy" - ], - "query": [ - { - "key": "id", - "value": "5734773724597737fd047c14" - }, - { - "key": "locale", - "value": "fr" - } - ] - } - }, - "response": [ - { - "name": "Get Condensed Milk hierarchy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{SPT_API}}/api/item/5734773724597737fd047c14", - "protocol": "http", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "item", - "5734773724597737fd047c14" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": null, - "cookie": [], - "body": "{\n \"5734773724597737fd047c14\": {\n \"item\": {\n \"_id\": \"5734773724597737fd047c14\",\n \"_name\": \"condensed_milk\",\n \"_parent\": \"5448e8d04bdc2ddf718b4569\"\n },\n \"locale\": {\n \"Description\": \"Condensed milk, also called \\\"Sguschyonka\\\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.\",\n \"Name\": \"Condensed milk\",\n \"ShortName\": \"Cond. milk\"\n }\n },\n \"5448e8d04bdc2ddf718b4569\": {\n \"item\": {\n \"_id\": \"5448e8d04bdc2ddf718b4569\",\n \"_name\": \"Food\",\n \"_parent\": \"543be6674bdc2df1348b4569\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food\",\n \"ShortName\": \"Item\"\n }\n },\n \"543be6674bdc2df1348b4569\": {\n \"item\": {\n \"_id\": \"543be6674bdc2df1348b4569\",\n \"_name\": \"FoodDrink\",\n \"_parent\": \"54009119af1c881c07000029\"\n },\n \"locale\": {\n \"Description\": \"Item\",\n \"Name\": \"Food and drink\",\n \"ShortName\": \"Item\"\n }\n },\n \"54009119af1c881c07000029\": {\n \"item\": {\n \"_id\": \"54009119af1c881c07000029\",\n \"_name\": \"Item\",\n \"_parent\": \"\"\n },\n \"locale\": \"\"\n }\n}" - } - ] - }, - { - "name": "Search item by ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"5734773724597737fd047c14\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by Name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Lait concentré\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search Milk by internal name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"condensed_milk\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - }, - { - "name": "Search item by ShortName", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('Content-Type is application/json', function () {\r", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');\r", - "});\r", - "\r", - "pm.test('Access-Control-Allow-Origin is present', function () {\r", - " pm.expect(pm.response.headers.get('Access-Control-Allow-Origin')).to.eql('*');\r", - "});\r", - "\r", - "pm.test('Found one item', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items.length).to.eql(1);\r", - "});\r", - "\r", - "pm.test('Item id is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].item._id).to.eql('5734773724597737fd047c14');\r", - "});\r", - "\r", - "pm.test('Locale is correct', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData.items[0].locale.Name).to.eql('Conserve de lait concentré');\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"query\": \"Lait conc.\",\r\n \"locale\": \"{{LOCALE}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{SPT_API}}/api/search", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "search" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"LOCALE\", \"fr\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "RefreshAll", - "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": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/refresh", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "refresh" - ] - } - }, - "response": [] - }, - { - "name": "Get all locales", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test('Status code is 200', function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "\r", - "pm.test('At least one locale is present', function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).length.greaterThan(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{SPT_API}}/api/locales/", - "host": [ - "{{SPT_API}}" - ], - "path": [ - "api", - "locales", - "" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "pm.environment.set(\"SPT_API\", \"https://db.sp-tarkov.com\");" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - } - ] -} \ No newline at end of file diff --git a/docs/Walkthrough.md b/docs/Walkthrough.md deleted file mode 100644 index 44d6fce..0000000 --- a/docs/Walkthrough.md +++ /dev/null @@ -1,293 +0,0 @@ -# Walkthrough - -## Summary -* [Overview](#overview) -* [Pipeline definition](#pipeline-definition) -* [Pipeline concurrency](#pipeline-concurrency) -* [Triggers](#triggers) -* [Steps](#steps) - * [Replace hosts and user variables](#replace-hosts-and-user-variables) - * [Install frontend dependencies and build it](#install-frontend-dependencies-and-build-it) - * [Run the frontend](#run-the-frontend) - * [Test frontend](#test-frontend) - * [Check ansible syntax](#check-ansible-syntax) - * [Apply ansible playbook](#apply-ansible-playbook) - * [Playbook definition](#playbook-definition) - * [Delete old spt-items-api](#delete-old-spt-items-api) - * [Copy the project](#copy-the-project) - * [Copy PHP env file](#copy-php-env-file) - * [Get JavaScript chunks name](#get-javascript-chunks-name) - * [Get file names from find output](#get-file-names-from-find-output) - * [Copy app.blade.php file](#copy-appbladephp-file) - * [Download and install composer dependencies](#download-and-install-composer-dependencies) - -## Overview -* The project is split between the frontend and the backend - * the backend is a [submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) located in [api](../api) that points towards [https://dev.sp-tarkov.com/Rev/spt-items-api.git](https://dev.sp-tarkov.com/Rev/spt-items-api.git) - * the frontend is a [submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) located in [frontend](../frontend) that points towards [https://dev.sp-tarkov.com/shirito/item-finder-website-frontend.git](https://dev.sp-tarkov.com/shirito/item-finder-website-frontend.git) -* There are two Ansible pipelines - * A docker pipeline [drone-docker.yml](../../.drone-docker.yml) - * A kubernetes pipeline [drone-kubernetes.yml](../../.drone-kubernetes.yml) -* All ansible playbook files are located in [.ansible](../../.ansible-items) -* The documentation is located in [documentation](../docs) - -## Pipeline definition -```yml -kind: pipeline -type: kubernetes -name: default -``` -The pipeline is defined either as Docker or Kubernetes depending on [.drone-docker.yml](../.drone-docker.yml) or [.drone-kubernetes.yml](../.drone-kubernetes.yml). The name is set as `default`. - -## Pipeline Concurrency -```yml -concurrency: - limit: 1 -``` -The pipeline is set to only one build at a time (every subsequent build with be pending). - -## Triggers -```yml -trigger: - event: - - push -``` -The pipeline is run on every push We want to check that every development on `development` branch is correct and deploy automatically when merged in `master`/`main`. -## Steps -### Replace hosts and user variables -```yml -- name: replace hosts and user variables - image: ubuntu:impish - environment: - SPT_ITEMS_HOSTNAME: - from_secret: spt_items_hostname - DEPLOY_HOSTNAME: - from_secret: deploy_hostname - DEPLOY_USER: - from_secret: deploy_username - DEPLOY_PRIVATE_KEY: - from_secret: deploy_ssh_key - DEPLOY_SSH_KEY_PASSPHRASE: - from_secret: deploy_ssh_key_passphrase - commands: - - sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./frontend/.env.example - - mv ./frontend/.env.example ./frontend/.env - - echo "$DEPLOY_PRIVATE_KEY" > private.key && chmod 600 private.key - - sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible-items/inventory - - sed -i 's/{{ DEPLOY_SSH_KEY_PASSPHRASE }}/'"$DEPLOY_SSH_KEY_PASSPHRASE"'/g' ./.ansible-items/inventory - - sed -i 's/{{ DEPLOY_USER }}/'"$DEPLOY_USER"'/g' ./.ansible-items/inventory -``` -Executed on every push. \ -The following environment variables are injected using Drone secrets: - * `SPT_ITEMS_HOSTNAME` is used by the frontend to call the backend. - * `DEPLOY_HOSTNAME` is used by Ansible to connect to the remote server via SSH. - * `DEPLOY_USER` is used by Ansible to connect to the remote server via SSH. - * `DEPLOY_PRIVATE_KEY` is the SSH key used to connect to the remote server via SSH - * `DEPLOY_SSH_KEY_PASSPHRASE` is the SSH key passphrase -Using `sed` makes temporary changes in the container/pod instead of commiting secrets in the repo in plain text. \ -The changes are never pushed and are discarded when the container/pod is terminated. - -### Install frontend dependencies and build it -```yml -- name: install dependencies and build frontend - image: node:lts-alpine3.14 - commands: - - node -v - - npm -v - - yarn --version - - yarn --cwd ./frontend install - - yarn --cwd ./frontend build --pure-lockfile - - rm -rf ./api/public/static/* - - cp -r ./frontend/build/* ./api/public - - rm ./api/public/index.html - depends_on: - - replace hosts and user variables -``` -Executed on every push. \ -Since the PHP backend serves the ReactJS frontend, the former is built and moved in the latter. -Notes: -* `yarn --cwd ` executes the command in the specified file -* `rm -rf ./api/public/static/*` deletes the static files to make sure no old JavaScript files remain -* `rm ./api/public/invdex.html` ReactJS is bundled with a `index.html`. It is discarded to use [](https://dev.sp-tarkov.com/Rev/spt-items-api/raw/branch/master/resources/views/app.blade.php) instead. - -### Run the frontend -```yaml -- name: frontend - image: nginx:1.21.4-alpine - commands: - - cp -r ./frontend/build/* /usr/share/nginx/html - - cp ./frontend/src/cypress/nginx_config/default.conf /etc/nginx/conf.d/default.conf - - nginx -g "daemon off;" - detach: true - depends_on: - - install dependencies and build frontend -``` -Copies the frontend and the nginx conf in the container to be able to test it. -The frontend is run and `detach` is specified so the End-to-End tests (using cypress) can run on it - -### Test frontend -```yaml -- name: test frontend - image: cypress/browsers:node16.5.0-chrome94-ff93 - commands: - - node -v - - npm -v - - yarn --version - - yarn --cwd ./frontend cy:ci - depends_on: - - install dependencies and build frontend -``` -Run frontend tests using Cypress - -### Check ansible syntax -```yml -- name: check ansible syntax - image: plugins/ansible:3 - settings: - playbook: ./.ansible-items/playbook.yml - inventory: ./.ansible-items/inventory - galaxy: ./.ansible-items/requirements.yml - syntax_check: true - when: - branch: - - development -``` -Executed on every push. \ -Check the Ansible syntax in [playbook.yml](../../.ansible-items/playbook.yml), [inventory](../../.ansible-items/inventory) and [requirements.yml](../../.ansible-items/requirements.yml). The check is executed on every push since we want to detect any error before validating the build using the promotion. - -### Apply ansible playbook -```yml -- name: apply ansible playbook - image: plugins/ansible:3 - settings: - playbook: ./.ansible-items/playbook.yml - inventory: ./.ansible-items/inventory - galaxy: ./.ansible-items/requirements.yml - timeout: 60 - verbose: 2 - environment: - SPT_ITEMS_HOSTNAME: - from_secret: spt_items_hostname - DEPLOY_HOSTNAME: - from_secret: deploy_hostname - DEPLOY_USER: - from_secret: deploy_username - DEPLOY_USER_GROUP: - from_secret: deploy_user_group - SPT_ITEMS_PATH: - from_secret: deploy_path - depends_on: - - test frontend - when: - branch: - - master - - main -``` -Executed only on promotion to production. \ -This step actually deploys to the server. \ -This step is [idempotent](https://en.wikipedia.org/wiki/Idempotence). \ -The following environment variables are injected using Drone secrets: - * `SPT_ITEMS_HOSTNAME` is used by the PHP env file. - * `DEPLOY_HOSTNAME` is used to connect to the remote server via SSH. - * `DEPLOY_USER` is used to connect to the remote server via SSH. - * `DEPLOY_USER_GROUP` is the user group, used to give read/write/execute permissions to the whole group. It must be the same as Nginx's user. - * `SPT_ITEMS_PATH` is the path on the remote server where the files will be copyed to. - -#### Playbook definition -```yml -hosts: sptarkov -``` -Uses the host defined in [inventory](../../.ansible-items/inventory). Remember, the step [Replace hosts and user variables](#replace-hosts-and-user-variables) already replaced the variables at this point. - -#### Delete old spt-items-api -```yml -- name: Delete spt-items-api before adding everything again - file: - state: absent - path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" -``` -Since the copy does not override the folder, this step takes care of it. \ -`SPT_ITEMS_PATH` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)) - -#### Copy the project -```yml -- name: Copy the project - copy: - src: ../api/ - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" -``` -Copies the whole project (frontend and backend) from the [api](../api) folder into the server. - -#### Copy PHP env file -```yml -- name: Copy PHP .env file - template: - src: ./templates/.php-env.j2 - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}/.env" -``` -Uses [Jinja2](https://jinja2docs.readthedocs.io/en/stable/) to resolve the [template for the PHP .env file](../../.ansible-items/templates/.php-env.j2). \ -`SPT_ITEMS_PATH` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)) \ -`SPT_ITEMS_HOSTNAME` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)) - -#### Get JavaScript chunks name -```yml -- name: Get Chunk 2 name - shell: - cmd: find "{{ lookup('env', 'SPT_ITEMS_PATH') }}" -type f -name "*chunk.js" -printf "%f\n" - register: find_output -``` -Prepare a find of all JavaScript chunk files for the [app.blade.php.j2](../../.ansible-items/templates/app.blade.php.j2) template. \ -`SPT_ITEMS_PATH` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)) - -#### Get file names from find output -```yml -- name: Get file names from find output - set_fact: - chunk_list: "{{ find_output['stdout'].split('\n') }}" -``` -Splits the string containing the list of all JavaScript chunk files for the [app.blade.php.j2](../../.ansible-items/templates/app.blade.php.j2) template. - -#### Copy app.blade.php file -```yml -- name: Copy app.blade.php file - template: - src: ./templates/app.blade.php.j2 - dest: "{{ lookup('env', 'SPT_ITEMS_PATH') }}/resources/views/app.blade.php" -``` -Uses [Jinja2](https://jinja2docs.readthedocs.io/en/stable/) to resolve the [template for the PHP app.blade.php file](../../.ansible-items/templates/app.blade.php.j2). \ -`SPT_ITEMS_PATH` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)). - -#### Download and install composer dependencies -```yml -- name: Download and installs all composer libs and dependencies - community.general.composer: - command: install - working_dir: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" -``` - -#### Reset files permissions -```yml -- name: Reset files permissions - file: - path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}" - owner: "{{ lookup('env', 'DEPLOY_USER') }}" - group: "{{ lookup('env', 'DEPLOY_USER_GROUP') }}" - mode: 0774 - recurse: yes -``` -Permissions 0644: - * user: read/write/execute - * group: read/write/execute (for Nginx to execute the php as well as write in the Laravel logs) - * other: read -`SPT_ITEMS_PATH` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook)). - -#### Initialize database -```yml -- name: Initialize database - uri: - url: "https://{{ lookup('env', 'SPT_ITEMS_HOSTNAME') }}/api/refresh" - method: GET - status_code: [200, 204] - timeout: 60 -``` -The call to `/api/refresh` fetches the data from AKI Server repository, `development` branch. \ No newline at end of file