I want to verify that user is able to see Modifier and Modifier Options visibility in SectionsCategoriesItems API endpoint response if Modifier is visible and options are invisible.
If modifierOptions are invisible then it will return like “modifieroptions”: [].
Below is my response:
{
"sessionToken": "f6v2VsO41ogKAAAABQAAAAAAAAAkYmEwNTRhNzctYWIyZC00ZTZkLWJmZTctMzQ0ZjYyMWQyZjFmAQAAAANBQ0cCAAAAA0FDUAYAAAACMTcFAAAAA2VuZwAAAAA.YBEaRJxT24DL0nT_Hmse6vXL9DXwOdDLytIDWdB6PiA",
"responsesIncluded": "getSectionsCategoriesItems",
"responses": [
{
"getSectionsCategoriesItems": {
"content": {
"sections": [
{
"id": 731559,
"code": "b9c6b0e2-0ea2-4ac5-b22d-4e07a151cbd9",
"referenceCode": null,
"name": "Flight/Weather Section",
"internalName": "Flight/Weather Section",
"gridFormat": "",
"headerTitle": "<p>Flight/Weather Section</p>\n",
"headerBody": "<p>Flight/Weather Section</p>\n",
"relatedItemsTitle": null,
"iconCode": "i-f-weather-1",
"type": "CustomContent",
"customAction": "",
"url": null,
"displayOrder": 0,
"infoModules": [
"Flights",
"Weather"
],
"categories": [],
"imageUrl": null,
"teasers": [],
"analyticsTag": null,
"hideFromWebValet": false,
"hideFromNativeApps": false,
"visibleToRooms": null,
"isEncryptedUrl": false,
"isVisibleToAllRooms": true,
"availabilityPeriods": [],
"availabilitySummary": {},
"sectionOutlets": [],
"widgetReferenceCode": null
}
],
"categoryItems": [
{
"code": "b9310f4c-5e33-4460-8d82-0acce29fac2a",
"price": 20,
"imageUrl": null,
"directContentParameter": null,
"type": "Product",
"name": "Product Item with Item Modifiers",
"shortDescription": null,
"longDescription": null,
"categoryCode": "58104a1b-d19c-41a2-a77d-6f2688bfd709",
"itemCode": "2e2da95e-ecb3-4b2e-b659-6c4ed9209c20",
"printEnabled": false,
"emailSharingEnable": false,
"qrCodeEnabled": false,
"promo": false,
"directContentType": null,
"availabilityPeriod": null,
"attributes": [],
"availabilityPeriods": [],
"availabilitySummary": {},
"relatedCategoryItemCodes": null,
"modifiers": [
{
"name": "Visible Multi Select Item Modifier with Invisible Options",
"code": "1b1211ab-d6b1-489f-a3ff-5cf417f82d52",
"posItemCode": null,
"parentModifierOptionCode": null,
"type": "multiselect",
"isRequired": false,
"sortOrder": 2,
"maximumQuantity": null,
"modifierOptions": []
},
{
"name": "Multi Select Item Modifier",
"code": "753dc005-13ac-4831-a228-7c4b542eab84",
"posItemCode": null,
"parentModifierOptionCode": null,
"type": "multiselect",
"isRequired": false,
"sortOrder": 3,
"maximumQuantity": null,
"modifierOptions": [
{
"value": "Option 1",
"code": "dd4bb4e8-ecd4-4504-85a7-bef127d91369",
"price": 0,
"modifierOptionCode": "753dc005-13ac-4831-a228-7c4b542eab84",
"subModifiers": [],
"timeValue": 0,
"name": "Option 1",
"posItemCode": null,
"optionType": "Text"
},
{
"value": "Option 2",
"code": "b821b52d-e453-464b-bfc2-5146ff092321",
"price": 0,
"modifierOptionCode": "753dc005-13ac-4831-a228-7c4b542eab84",
"subModifiers": [],
"timeValue": 0,
"name": "Option 2",
"posItemCode": null,
"optionType": "Text"
}
]
}
],
"analyticsTag": null,
"templateTag": null,
"buttons": [],
"itemImages": [],
"posItemCode": null,
"isInStock": true,
"spaItemCode": null,
"sosItemCode": null,
"sortOrder": 1
},
{
"code": "d920aa96-5c04-4d77-aee3-70a6294ad3f6",
"price": 100,
"imageUrl": null,
"directContentParameter": null,
"type": "Service",
"name": "Service Request Item with SOS Item Code",
"shortDescription": "<p>Service Request Item with SOS Item Code</p>\r\n",
"longDescription": "<p>Service Request Item with SOS Item Code</p>\r\n",
"categoryCode": "5ec9fb71-dbf5-4dcd-9f04-17fb5d881e21",
"itemCode": "1d27389b-6bfe-4589-a3cd-ecbe6718e834",
"printEnabled": false,
"emailSharingEnable": false,
"qrCodeEnabled": false,
"promo": false,
"directContentType": null,
"availabilityPeriod": null,
"attributes": [],
"availabilityPeriods": [],
"availabilitySummary": {},
"relatedCategoryItemCodes": null,
"modifiers": [],
"analyticsTag": null,
"templateTag": null,
"buttons": [],
"itemImages": [],
"posItemCode": null,
"isInStock": null,
"spaItemCode": null,
"sosItemCode": "TestSOSItemCode",
"sortOrder": 1
},
{
"code": "1f52146b-99cb-44f0-a401-a933084fa16c",
"price": 10,
"imageUrl": "https://irisv4neuqaasstore.blob.core.windows.net/fileresources/public/iris/ACG/0a84a110008ca13a1073e7e430fbb0910e239ab3dbbc454993943ad586daf04a.jpg",
"directContentParameter": null,
"type": "Product",
"name": "Breakfast",
"shortDescription": "<p>Breakfast</p>\r\n",
"longDescription": "<p>Breakfast</p>\r\n",
"categoryCode": "76864660-ea10-4120-b7ba-fcc52cb8bc5f",
"itemCode": "63ca267a-5075-41f4-937e-a9bca7ff2803",
"printEnabled": false,
"emailSharingEnable": false,
"qrCodeEnabled": false,
"promo": false,
"directContentType": null,
"availabilityPeriod": null,
"attributes": [
{
"name": "Multi Select Type Item Attribute",
"values": [
"Option 2",
"Option 1"
]
}
],
"availabilityPeriods": [],
"availabilitySummary": {},
"relatedCategoryItemCodes": null,
"modifiers": [
{
"name": "Multi Select Item Modifier",
"code": "753dc005-13ac-4831-a228-7c4b542eab84",
"posItemCode": null,
"parentModifierOptionCode": null,
"type": "multiselect",
"isRequired": true,
"sortOrder": 0,
"maximumQuantity": null,
"modifierOptions": [
{
"value": "Option 1",
"code": "dd4bb4e8-ecd4-4504-85a7-bef127d91369",
"price": 0,
"modifierOptionCode": "753dc005-13ac-4831-a228-7c4b542eab84",
"subModifiers": [],
"timeValue": 0,
"name": "Option 1",
"posItemCode": null,
"optionType": "Text"
},
{
"value": "Option 2",
"code": "b821b52d-e453-464b-bfc2-5146ff092321",
"price": 0,
"modifierOptionCode": "753dc005-13ac-4831-a228-7c4b542eab84",
"subModifiers": [],
"timeValue": 0,
"name": "Option 2",
"posItemCode": null,
"optionType": "Text"
}
]
},
{
"name": "Multi Select Item Modifier with Maximum Quantity",
"code": "e8191c90-e3b8-4f82-8010-28d7035eedc4",
"posItemCode": null,
"parentModifierOptionCode": null,
"type": "multiselect",
"isRequired": false,
"sortOrder": 1,
"maximumQuantity": 10,
"modifierOptions": [
{
"value": "Option 1",
"code": "05955a98-624e-498e-9889-2fd55ce07349",
"price": 0,
"modifierOptionCode": "e8191c90-e3b8-4f82-8010-28d7035eedc4",
"subModifiers": [],
"timeValue": 0,
"name": "Option 1",
"posItemCode": null,
"optionType": "Text"
},
{
"value": "Option 2",
"code": "c69ff093-51df-42ae-99f6-8ea54cc65b5a",
"price": 0,
"modifierOptionCode": "e8191c90-e3b8-4f82-8010-28d7035eedc4",
"subModifiers": [],
"timeValue": 0,
"name": "Option 2",
"posItemCode": null,
"optionType": "Text"
},
{
"value": "Option 3",
"code": "b35a2c94-ddd1-482d-a5ed-2f39d3a51a29",
"price": 0,
"modifierOptionCode": "e8191c90-e3b8-4f82-8010-28d7035eedc4",
"subModifiers": [],
"timeValue": 0,
"name": "Option 3",
"posItemCode": null,
"optionType": "Text"
}
]
}
],
"analyticsTag": null,
"templateTag": null,
"buttons": [],
"itemImages": [
{
"url": "https://irisv4neuqaasstore.blob.core.windows.net/fileresources/public/iris/ACG/0a84a110008ca13a1073e7e430fbb0910e239ab3dbbc454993943ad586daf04a.jpg",
"isPopup": false,
"isBackground": false
}
],
"posItemCode": null,
"isInStock": true,
"spaItemCode": null,
"sosItemCode": null,
"sortOrder": 1
}
]
},
"succeeded": true
}
}
],
"status": "Success"
}
For testing this scenario I have written below script in “Tests”:
pm.test('Status code is 200', function () {
pm.response.to.have.status(200);
});
var jsonData = JSON.parse(responseBody)
var i
categoryItems = _.get(jsonData, 'responses[0].getSectionsCategoriesItems.content.categoryItems');
modifiers = _.get(jsonData, 'responses[0].getSectionsCategoriesItems.content.categoryItems[0].modifiers');
modifierOptions = _.get(jsonData, 'responses[0].getSectionsCategoriesItems.content.categoryItems[0].modifiers[0].modifierOptions');
var result;
for (i = 0; i < categoryItems.length; i++) {
for (j = 0; j < modifiers.length; j++) {
if ((modifiers[j] !== null) && (modifierOptions.length === null)) {
var categoryItemName = _.get(categoryItems, `${i}.name`);
var modifierName = _.get(modifiers, `${j}.name`);
console.log(categoryItemName + " which has " + modifierName);
result = true
} else
result = false;
}
}
if (result === true)
console.log("Test
case Passed")
else
console.log("Test
case Failed")
I am getting “Test Failed” result on the console.
Appreciate your assistance ASAP.
Thanks in advance!