From 0fc61b392bfe07e544a3288e40e5474458302abd Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Tue, 6 Aug 2024 15:07:03 -0400 Subject: [PATCH] DEV test updates --- .../__snapshots__/product.config.test.js.snap | 144 +++++++++++------- src/config/__tests__/product.config.test.js | 4 +- .../__snapshots__/rhsmConstants.test.js.snap | 8 - .../rhsmTransformers.test.js.snap | 24 +-- src/services/rhsm/rhsmTransformers.js | 3 + 5 files changed, 100 insertions(+), 83 deletions(-) diff --git a/src/config/__tests__/__snapshots__/product.config.test.js.snap b/src/config/__tests__/__snapshots__/product.config.test.js.snap index 34c9773b7..2d0123bf9 100644 --- a/src/config/__tests__/__snapshots__/product.config.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.config.test.js.snap @@ -5466,7 +5466,7 @@ exports[`Product specific configurations should apply variations in inventory fi "info": undefined, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Cores", "modifier": "wrap", "width": 10, }, @@ -5476,7 +5476,7 @@ exports[`Product specific configurations should apply variations in inventory fi "info": undefined, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Sockets", "modifier": "wrap", "width": 10, }, @@ -5543,15 +5543,31 @@ exports[`Product specific configurations should apply variations in inventory fi "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Cores"})", "header": [Function], "isWrap": true, - "metric": "total_capacity", + "metric": "Cores", "width": 10, }, { - "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "content": + + , "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isWrap": true, - "metric": "total_capacity", + "metric": "Sockets", "width": 10, }, { @@ -5568,14 +5584,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -5715,14 +5729,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -5774,7 +5786,7 @@ exports[`Product specific configurations should apply variations in inventory fi "isSort": true, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Sockets", "modifier": "wrap", "width": undefined, }, @@ -5821,12 +5833,28 @@ exports[`Product specific configurations should apply variations in inventory fi "width": 10, }, { - "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "content": + + , "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isSort": true, "isWrap": true, - "metric": "total_capacity", + "metric": "Sockets", "width": undefined, }, { @@ -5843,14 +5871,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -5990,14 +6016,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6137,14 +6161,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6225,14 +6247,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6299,7 +6319,7 @@ exports[`Product specific configurations should apply variations in inventory fi "info": undefined, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Cores", "modifier": "wrap", "width": 10, }, @@ -6309,7 +6329,7 @@ exports[`Product specific configurations should apply variations in inventory fi "info": undefined, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Sockets", "modifier": "wrap", "width": 10, }, @@ -6376,15 +6396,31 @@ exports[`Product specific configurations should apply variations in inventory fi "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Cores"})", "header": [Function], "isWrap": true, - "metric": "total_capacity", + "metric": "Cores", "width": 10, }, { - "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "content": + + , "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isWrap": true, - "metric": "total_capacity", + "metric": "Sockets", "width": 10, }, { @@ -6401,14 +6437,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6548,14 +6582,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6607,7 +6639,7 @@ exports[`Product specific configurations should apply variations in inventory fi "isSort": true, "isWrap": true, "label": [Function], - "metric": "total_capacity", + "metric": "Sockets", "modifier": "wrap", "width": undefined, }, @@ -6654,12 +6686,28 @@ exports[`Product specific configurations should apply variations in inventory fi "width": 10, }, { - "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "content": + + , "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isSort": true, "isWrap": true, - "metric": "total_capacity", + "metric": "Sockets", "width": undefined, }, { @@ -6676,14 +6724,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6823,14 +6869,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -6970,14 +7014,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], @@ -7058,14 +7100,12 @@ exports[`Product specific configurations should apply variations in inventory fi "row": { "Cores": 2000, "billing_provider": "dolor sit", - "hasInfiniteCores": true, + "has_infinite_quantity": true, "loremIpsum": "hello world", - "metric_id": "Cores", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", "quantity": 1, "service_level": "hello world", - "total_capacity": 2000, }, }, ], diff --git a/src/config/__tests__/product.config.test.js b/src/config/__tests__/product.config.test.js index bed17b80b..1376853ae 100644 --- a/src/config/__tests__/product.config.test.js +++ b/src/config/__tests__/product.config.test.js @@ -248,10 +248,8 @@ describe('Product specific configurations', () => { [SUBSCRIPTIONS_INVENTORY_TYPES.NEXT_EVENT_DATE]: '2022-01-01T00:00:00.000Z', [SUBSCRIPTIONS_INVENTORY_TYPES.QUANTITY]: 1, [SUBSCRIPTIONS_INVENTORY_TYPES.SERVICE_LEVEL]: 'hello world', - [SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY]: 2000, - [SUBSCRIPTIONS_INVENTORY_TYPES.METRIC_ID]: 'Cores', [RHSM_API_PATH_METRIC_TYPES.CORES]: 2000, - [`hasInfinite${RHSM_API_PATH_METRIC_TYPES.CORES}`]: true, + [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: true, loremIpsum: 'hello world' } ] diff --git a/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap b/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap index abff728f3..9d63c1f0b 100644 --- a/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap +++ b/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap @@ -218,14 +218,12 @@ exports[`RHSM Constants should have specific properties: all exported constants "INVENTORY_ID": "inventory_id", "LAST_SEEN": "last_seen", "MEASUREMENTS": "measurements", - "METRIC_ID": "metric_id", "NEXT_EVENT_DATE": "next_event_date", "NUMBER_OF_GUESTS": "number_of_guests", "PRODUCT_NAME": "product_name", "QUANTITY": "quantity", "SERVICE_LEVEL": "service_level", "SUBSCRIPTION_MANAGER_ID": "subscription_manager_id", - "TOTAL_CAPACITY": "total_capacity", }, "RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES": { "COUNT": "count", @@ -483,14 +481,12 @@ exports[`RHSM Constants should have specific properties: all exported constants "INVENTORY_ID": "inventory_id", "LAST_SEEN": "last_seen", "MEASUREMENTS": "measurements", - "METRIC_ID": "metric_id", "NEXT_EVENT_DATE": "next_event_date", "NUMBER_OF_GUESTS": "number_of_guests", "PRODUCT_NAME": "product_name", "QUANTITY": "quantity", "SERVICE_LEVEL": "service_level", "SUBSCRIPTION_MANAGER_ID": "subscription_manager_id", - "TOTAL_CAPACITY": "total_capacity", }, "RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES": { "COUNT": "count", @@ -749,14 +745,12 @@ exports[`RHSM Constants should have specific properties: all exported constants "INVENTORY_ID": "inventory_id", "LAST_SEEN": "last_seen", "MEASUREMENTS": "measurements", - "METRIC_ID": "metric_id", "NEXT_EVENT_DATE": "next_event_date", "NUMBER_OF_GUESTS": "number_of_guests", "PRODUCT_NAME": "product_name", "QUANTITY": "quantity", "SERVICE_LEVEL": "service_level", "SUBSCRIPTION_MANAGER_ID": "subscription_manager_id", - "TOTAL_CAPACITY": "total_capacity", }, "RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES": { "COUNT": "count", @@ -1019,14 +1013,12 @@ exports[`RHSM Constants should have specific properties: specific constants 1`] "INVENTORY_ID": "inventory_id", "LAST_SEEN": "last_seen", "MEASUREMENTS": "measurements", - "METRIC_ID": "metric_id", "NEXT_EVENT_DATE": "next_event_date", "NUMBER_OF_GUESTS": "number_of_guests", "PRODUCT_NAME": "product_name", "QUANTITY": "quantity", "SERVICE_LEVEL": "service_level", "SUBSCRIPTION_MANAGER_ID": "subscription_manager_id", - "TOTAL_CAPACITY": "total_capacity", }, "RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES": { "COUNT": "count", diff --git a/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap b/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap index 211cf0a8a..da442a2c6 100644 --- a/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap +++ b/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap @@ -413,11 +413,7 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { - "Cores": undefined, - "hasInfiniteCores": undefined, - "has_infinite_quantity": undefined, - "metric_id": "Cores", - "total_capacity": undefined, + "undefined": "Cores", }, ], "meta": { @@ -432,11 +428,7 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { - "Cores": undefined, - "hasInfiniteCores": undefined, - "has_infinite_quantity": undefined, - "metric_id": "Cores", - "total_capacity": undefined, + "undefined": "Cores", }, ], "meta": { @@ -451,18 +443,10 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { - "Cores": undefined, - "hasInfiniteCores": undefined, - "has_infinite_quantity": undefined, - "metric_id": "Cores", - "total_capacity": undefined, + "undefined": "Cores", }, { - "Sockets": undefined, - "hasInfiniteSockets": undefined, - "has_infinite_quantity": undefined, - "metric_id": "Sockets", - "total_capacity": undefined, + "undefined": "Sockets", }, ], "meta": { diff --git a/src/services/rhsm/rhsmTransformers.js b/src/services/rhsm/rhsmTransformers.js index 7a89f53c7..4996a3246 100644 --- a/src/services/rhsm/rhsmTransformers.js +++ b/src/services/rhsm/rhsmTransformers.js @@ -102,6 +102,9 @@ const rhsmInstancesGuests = (response, { params, _id } = {}) => { return updatedResponse; }; +/** + * Note: The "has_infinite_quantity" bool response property applies to ALL measurements! + */ /** * Parse RHSM subscriptions response for caching. * Attempt to align Instances and Subscriptions responses.