From f8911113a4c06b1fa417221be18c94c5df231d4c Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Tue, 7 Feb 2023 18:52:20 -0500 Subject: [PATCH] fix(config): align product filter tests (#1049) --- .../product.openshiftContainer.test.js.snap | 231 ++++++++- .../__snapshots__/product.rhacs.test.js.snap | 4 +- .../__snapshots__/product.rhel.test.js.snap | 483 ++++++++++++------ .../__snapshots__/product.rhods.test.js.snap | 4 +- .../__snapshots__/product.rhosak.test.js.snap | 4 +- .../product.satellite.test.js.snap | 156 ++++++ .../product.openshiftContainer.test.js | 51 +- src/config/__tests__/product.rhacs.test.js | 2 +- src/config/__tests__/product.rhel.test.js | 68 ++- src/config/__tests__/product.rhods.test.js | 2 +- src/config/__tests__/product.rhosak.test.js | 2 +- .../__tests__/product.satellite.test.js | 21 + 12 files changed, 824 insertions(+), 204 deletions(-) diff --git a/src/config/__tests__/__snapshots__/product.openshiftContainer.test.js.snap b/src/config/__tests__/__snapshots__/product.openshiftContainer.test.js.snap index 01084703a..71b351c7a 100644 --- a/src/config/__tests__/__snapshots__/product.openshiftContainer.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.openshiftContainer.test.js.snap @@ -211,15 +211,69 @@ exports[`Product OpenShift Container config should apply guest inventory configu } `; +exports[`Product OpenShift Container config should apply guest inventory configuration: filtered, missing inventory id 1`] = ` +{ + "cells": [ + { + "title": "lorem", + }, + { + "title": "", + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header, {"context":"guestsDisplayName"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "displayName": { + "title": "t(curiosity-inventory.header, {"context":"displayName"})", + "value": "lorem", + }, + "inventoryId": { + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "value": "", + }, + "lastSeen": { + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + "loremIpsum": { + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", + "value": "hello world", + }, + "subscriptionManagerId": { + "title": "t(curiosity-inventory.header, {"context":"subscriptionManagerId"})", + "value": "lorem subscription id", + }, + }, +} +`; + exports[`Product OpenShift Container config should apply hosts inventory configuration: filtered 1`] = ` { "cells": [ { - "title": - lorem - - t(curiosity-inventory.label, {"context":"numberOfGuests","count":3}, [object Object]) - , + "title": "lorem", }, { "title": 100, @@ -268,7 +322,7 @@ exports[`Product OpenShift Container config should apply hosts inventory configu }, "inventory_id": { "title": "t(curiosity-inventory.header_inventory_id, {"context":"OpenShift Container Platform"})", - "value": "lorem inventory id", + "value": "", }, "last_seen": { "title": "t(curiosity-inventory.header_last_seen, {"context":"OpenShift Container Platform"})", @@ -290,6 +344,92 @@ exports[`Product OpenShift Container config should apply hosts inventory configu } `; +exports[`Product OpenShift Container config should apply hosts inventory configuration: filtered, authorized 1`] = ` +{ + "cells": [ + { + "title": + + + t(curiosity-inventory.label, {"context":"numberOfGuests","count":3}, [object Object]) + , + }, + { + "title": 100, + }, + { + "title": 20, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"cores"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "cores": { + "title": "t(curiosity-inventory.header, {"context":"cores"})", + "value": 20, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem", + }, + "inventory_id": { + "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", + "value": "XXXX-XXXX-XXXXX-XXXXX", + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + "loremIpsum": { + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", + "value": "hello world", + }, + "number_of_guests": { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "value": 3, + }, + "sockets": { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "value": 100, + }, + }, +} +`; + exports[`Product OpenShift Container config should apply hosts inventory configuration: filtered, fallback display 1`] = ` { "cells": [ @@ -363,6 +503,85 @@ exports[`Product OpenShift Container config should apply hosts inventory configu } `; +exports[`Product OpenShift Container config should apply hosts inventory configuration: filtered, infinite 1`] = ` +{ + "cells": [ + { + "title": "lorem", + }, + { + "title": 100, + }, + { + "title": 20, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"cores"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "cores": { + "title": "t(curiosity-inventory.header, {"context":"cores"})", + "value": 20, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem", + }, + "has_infinite_quantity": { + "title": "t(curiosity-inventory.header_has_infinite, {"context":"quantity"})", + "value": false, + }, + "inventory_id": { + "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", + "value": "", + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + "loremIpsum": { + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", + "value": "hello world", + }, + "number_of_guests": { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "value": 3, + }, + "sockets": { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "value": 100, + }, + }, +} +`; + exports[`Product OpenShift Container config should apply subscriptions inventory configuration: filtered 1`] = ` { "cells": [ diff --git a/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap b/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap index 08799d4f8..32075dcca 100644 --- a/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Product RHACS config should apply an instances inventory configuration under hosts: filtered 1`] = ` +exports[`Product RHACS config should apply an inventory configuration: filtered 1`] = ` { "cells": [ { @@ -59,7 +59,7 @@ exports[`Product RHACS config should apply an instances inventory configuration } `; -exports[`Product RHACS config should apply an instances inventory configuration under hosts: filtered, authorized 1`] = ` +exports[`Product RHACS config should apply an inventory configuration: filtered, authorized 1`] = ` { "cells": [ { diff --git a/src/config/__tests__/__snapshots__/product.rhel.test.js.snap b/src/config/__tests__/__snapshots__/product.rhel.test.js.snap index 8fa98992d..0cd4d5541 100644 --- a/src/config/__tests__/__snapshots__/product.rhel.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhel.test.js.snap @@ -1,5 +1,318 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Product RHEL config should apply an inventory configuration: filtered 1`] = ` +{ + "cells": [ + { + "title": "lorem ipsum", + }, + { + "title": "--", + }, + { + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"category"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "Sockets": { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "value": 200, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem ipsum", + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + }, +} +`; + +exports[`Product RHEL config should apply an inventory configuration: filtered, authorized 1`] = ` +{ + "cells": [ + { + "title": , + }, + { + "title": "--", + }, + { + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"category"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "Sockets": { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "value": 200, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem ipsum", + }, + "inventory_id": { + "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", + "value": "XXXX-XXXX-XXXXX-XXXXX", + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + }, +} +`; + +exports[`Product RHEL config should apply an inventory configuration: filtered, fallback display 1`] = ` +{ + "cells": [ + { + "title": "lorem ipsum", + }, + { + "title": "--", + }, + { + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, + }, + { + "title": "", + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"category"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "Sockets": { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "value": 200, + }, + "cloud_provider": { + "title": "t(curiosity-inventory.header_cloud, {"context":"provider"})", + "value": "dolor sit", + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem ipsum", + }, + "inventory_id": { + "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", + "value": null, + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": null, + }, + }, +} +`; + +exports[`Product RHEL config should apply an inventory configuration: filtered, infinite 1`] = ` +{ + "cells": [ + { + "title": "lorem ipsum", + }, + { + "title": "--", + }, + { + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"category"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "Sockets": { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "value": 200, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem ipsum", + }, + "has_infinite_quantity": { + "title": "t(curiosity-inventory.header_has_infinite, {"context":"quantity"})", + "value": false, + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + }, +} +`; + exports[`Product RHEL config should apply graph configuration: filters 1`] = ` { "groupedFiltersSettings": { @@ -230,24 +543,14 @@ exports[`Product RHEL config should apply guest inventory configuration: filtere } `; -exports[`Product RHEL config should apply hosts inventory configuration: filtered 1`] = ` +exports[`Product RHEL config should apply guest inventory configuration: filtered, missing inventory id 1`] = ` { "cells": [ { "title": "lorem", }, { - "title": 3, - }, - { - "title": - t(curiosity-inventory.label, {"context":"category"}) - - - , - }, - { - "title": "--", + "title": "", }, { "title": - t(curiosity-inventory.label, {"context":"category"}) - - - , - }, - { - "title": "--", - }, - { - "title": "", - }, - ], - "columnHeaders": [ - { - "title": "t(curiosity-inventory.header_display, {"context":"name"})", - "transforms": [], - }, - { - "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", - "transforms": [ - [Function], - ], - }, - { - "title": "t(curiosity-inventory.header, {"context":"category"})", - "transforms": [ - [Function], - ], - }, - { - "title": "t(curiosity-inventory.header, {"context":"Sockets"})", - "transforms": [ - [Function], - ], - }, - { - "title": "t(curiosity-inventory.header_last, {"context":"seen"})", - "transforms": [ - [Function], - ], - }, - ], - "data": { - "cloud_provider": { - "title": "t(curiosity-inventory.header_cloud, {"context":"provider"})", - "value": "dolor sit", - }, - "cores": { - "title": "t(curiosity-inventory.header, {"context":"cores"})", - "value": 12, - }, - "display_name": { - "title": "t(curiosity-inventory.header_display, {"context":"name"})", - "value": "lorem", - }, - "hardware_type": { - "title": "t(curiosity-inventory.header_hardware, {"context":"type"})", - "value": "ipsum", - }, - "inventory_id": { - "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", - "value": null, - }, - "last_seen": { - "title": "t(curiosity-inventory.header_last, {"context":"seen"})", - "value": null, - }, - "loremIpsum": { - "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", - "value": "hello world", - }, - "measurement_type": { - "title": "t(curiosity-inventory.header_measurement, {"context":"type"})", - "value": null, - }, - "number_of_guests": { - "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", - "value": 3, - }, - "sockets": { - "title": "t(curiosity-inventory.header, {"context":"sockets"})", - "value": 10, + "subscriptionManagerId": { + "title": "t(curiosity-inventory.header, {"context":"subscriptionManagerId"})", + "value": "lorem subscription id", }, }, } diff --git a/src/config/__tests__/__snapshots__/product.rhods.test.js.snap b/src/config/__tests__/__snapshots__/product.rhods.test.js.snap index 6be9dc0b4..cc3b83367 100644 --- a/src/config/__tests__/__snapshots__/product.rhods.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhods.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Product RHODS config should apply an instances inventory configuration under hosts: filtered 1`] = ` +exports[`Product RHODS config should apply an inventory configuration: filtered 1`] = ` { "cells": [ { @@ -59,7 +59,7 @@ exports[`Product RHODS config should apply an instances inventory configuration } `; -exports[`Product RHODS config should apply an instances inventory configuration under hosts: filtered, authorized 1`] = ` +exports[`Product RHODS config should apply an inventory configuration: filtered, authorized 1`] = ` { "cells": [ { diff --git a/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap b/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap index 16018b348..c71e33d07 100644 --- a/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Product RHOSAK config should apply an instances inventory configuration under hosts: filtered 1`] = ` +exports[`Product RHOSAK config should apply an inventory configuration: filtered 1`] = ` { "cells": [ { @@ -105,7 +105,7 @@ exports[`Product RHOSAK config should apply an instances inventory configuration } `; -exports[`Product RHOSAK config should apply an instances inventory configuration under hosts: filtered, authorized 1`] = ` +exports[`Product RHOSAK config should apply an inventory configuration: filtered, authorized 1`] = ` { "cells": [ { diff --git a/src/config/__tests__/__snapshots__/product.satellite.test.js.snap b/src/config/__tests__/__snapshots__/product.satellite.test.js.snap index 879afc76a..1be47e95b 100644 --- a/src/config/__tests__/__snapshots__/product.satellite.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.satellite.test.js.snap @@ -200,6 +200,64 @@ exports[`Product Satellite config should apply guest inventory configuration: fi } `; +exports[`Product Satellite config should apply guest inventory configuration: filtered, missing inventory id 1`] = ` +{ + "cells": [ + { + "title": "lorem", + }, + { + "title": "", + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header, {"context":"guestsDisplayName"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "displayName": { + "title": "t(curiosity-inventory.header, {"context":"displayName"})", + "value": "lorem", + }, + "inventoryId": { + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "value": "", + }, + "lastSeen": { + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + "loremIpsum": { + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", + "value": "hello world", + }, + "subscriptionManagerId": { + "title": "t(curiosity-inventory.header, {"context":"subscriptionManagerId"})", + "value": "lorem subscription id", + }, + }, +} +`; + exports[`Product Satellite config should apply hosts inventory configuration: filtered 1`] = ` { "cells": [ @@ -291,6 +349,104 @@ exports[`Product Satellite config should apply hosts inventory configuration: fi } `; +exports[`Product Satellite config should apply hosts inventory configuration: filtered, authorized 1`] = ` +{ + "cells": [ + { + "title": + + + t(curiosity-inventory.label, {"context":"numberOfGuests","count":3}, [object Object]) + , + }, + { + "title": + t(curiosity-inventory.measurementType, {"context":null}) + + + , + }, + { + "title": 10, + }, + { + "title": , + }, + ], + "columnHeaders": [ + { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "transforms": [], + }, + { + "title": "t(curiosity-inventory.header_measurement, {"context":"type"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "transforms": [ + [Function], + ], + }, + ], + "data": { + "cores": { + "title": "t(curiosity-inventory.header, {"context":"cores"})", + "value": 12, + }, + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem", + }, + "hardware_type": { + "title": "t(curiosity-inventory.header_hardware, {"context":"type"})", + "value": "ipsum", + }, + "inventory_id": { + "title": "t(curiosity-inventory.header_inventory, {"context":"id"})", + "value": "XXXX-XXXX-XXXXX-XXXXX", + }, + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": "2022-01-01T00:00:00.000Z", + }, + "loremIpsum": { + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", + "value": "hello world", + }, + "measurement_type": { + "title": "t(curiosity-inventory.header_measurement, {"context":"type"})", + "value": null, + }, + "number_of_guests": { + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", + "value": 3, + }, + "sockets": { + "title": "t(curiosity-inventory.header, {"context":"sockets"})", + "value": 10, + }, + }, +} +`; + exports[`Product Satellite config should apply hosts inventory configuration: filtered, fallback display 1`] = ` { "cells": [ diff --git a/src/config/__tests__/product.openshiftContainer.test.js b/src/config/__tests__/product.openshiftContainer.test.js index 02118baae..2571ff457 100644 --- a/src/config/__tests__/product.openshiftContainer.test.js +++ b/src/config/__tests__/product.openshiftContainer.test.js @@ -21,7 +21,7 @@ describe('Product OpenShift Container config', () => { const inventoryData = { [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem', - [INVENTORY_TYPES.INVENTORY_ID]: 'lorem inventory id', + [INVENTORY_TYPES.INVENTORY_ID]: undefined, [INVENTORY_TYPES.NUMBER_OF_GUESTS]: 3, [INVENTORY_TYPES.CORES]: 20, [INVENTORY_TYPES.SOCKETS]: 100, @@ -37,23 +37,42 @@ describe('Product OpenShift Container config', () => { expect(filteredInventoryData).toMatchSnapshot('filtered'); - const fallbackInventoryData = { - ...inventoryData, - [INVENTORY_TYPES.INVENTORY_ID]: null, - [INVENTORY_TYPES.NUMBER_OF_GUESTS]: null, - [INVENTORY_TYPES.CORES]: null, - [INVENTORY_TYPES.SOCKETS]: null, - [INVENTORY_TYPES.LAST_SEEN]: null - }; - const fallbackFilteredInventoryData = parseRowCellsListData({ filters: initialFilters, - cellData: fallbackInventoryData, + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INVENTORY_ID]: null, + [INVENTORY_TYPES.NUMBER_OF_GUESTS]: null, + [INVENTORY_TYPES.CORES]: null, + [INVENTORY_TYPES.SOCKETS]: null, + [INVENTORY_TYPES.LAST_SEEN]: null + }, productId }); expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display'); + const filteredInventoryDataAuthorized = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INVENTORY_ID]: 'XXXX-XXXX-XXXXX-XXXXX' + }, + session: { authorized: { inventory: true } } + }); + + expect(filteredInventoryDataAuthorized).toMatchSnapshot('filtered, authorized'); + + const filteredInventoryDataInfinite = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: false + } + }); + + expect(filteredInventoryDataInfinite).toMatchSnapshot('filtered, infinite'); + expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true); }); @@ -110,6 +129,16 @@ describe('Product OpenShift Container config', () => { expect(filteredGuestsData).toMatchSnapshot('filtered'); + const filteredGuestsDataMissing = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...guestsData, + inventoryId: undefined + } + }); + + expect(filteredGuestsDataMissing).toMatchSnapshot('filtered, missing inventory id'); + const filteredGuestsDataAuthorized = parseRowCellsListData({ filters: initialFilters, cellData: guestsData, diff --git a/src/config/__tests__/product.rhacs.test.js b/src/config/__tests__/product.rhacs.test.js index a21f68d73..47d8b21fe 100644 --- a/src/config/__tests__/product.rhacs.test.js +++ b/src/config/__tests__/product.rhacs.test.js @@ -52,7 +52,7 @@ describe('Product RHACS config', () => { /** * FixMe: this test needs to be updated as part of the refactor towards instances vs hosts */ - it('should apply an instances inventory configuration under hosts', () => { + it('should apply an inventory configuration', () => { const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery } = config; const inventoryData = { diff --git a/src/config/__tests__/product.rhel.test.js b/src/config/__tests__/product.rhel.test.js index a9098734d..e79c62ba8 100644 --- a/src/config/__tests__/product.rhel.test.js +++ b/src/config/__tests__/product.rhel.test.js @@ -2,9 +2,10 @@ import { config } from '../product.rhel'; import { generateChartSettings } from '../../components/graphCard/graphCardHelpers'; import { parseRowCellsListData } from '../../components/inventoryCard/inventoryCardHelpers'; import { + RHSM_API_PATH_METRIC_TYPES, RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES as SORT_DIRECTION_TYPES, RHSM_API_QUERY_SET_TYPES, - RHSM_API_RESPONSE_HOSTS_DATA_TYPES as INVENTORY_TYPES, + RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES as SUBSCRIPTIONS_INVENTORY_TYPES } from '../../services/rhsm/rhsmConstants'; @@ -16,44 +17,55 @@ describe('Product RHEL config', () => { expect(initialGraphSettings).toMatchSnapshot('settings'); }); - it('should apply hosts inventory configuration', () => { - const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery, productId } = config; + it('should apply an inventory configuration', () => { + const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery } = config; const inventoryData = { - [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem', - [INVENTORY_TYPES.INVENTORY_ID]: 'lorem inventory id', - [INVENTORY_TYPES.HARDWARE_TYPE]: 'ipsum', - [INVENTORY_TYPES.MEASUREMENT_TYPE]: null, - [INVENTORY_TYPES.NUMBER_OF_GUESTS]: 3, - [INVENTORY_TYPES.SOCKETS]: 10, - [INVENTORY_TYPES.CORES]: 12, - [INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z', - loremIpsum: 'hello world' + [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem ipsum', + [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: 200, + [INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z' }; const filteredInventoryData = parseRowCellsListData({ filters: initialFilters, - cellData: inventoryData, - productId + cellData: inventoryData }); expect(filteredInventoryData).toMatchSnapshot('filtered'); - const fallbackInventoryData = { - ...inventoryData, - [INVENTORY_TYPES.INVENTORY_ID]: null, - [INVENTORY_TYPES.LAST_SEEN]: null, - [INVENTORY_TYPES.CLOUD_PROVIDER]: 'dolor sit' - }; - const fallbackFilteredInventoryData = parseRowCellsListData({ filters: initialFilters, - cellData: fallbackInventoryData, - productId + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INVENTORY_ID]: null, + [INVENTORY_TYPES.LAST_SEEN]: null, + [INVENTORY_TYPES.CLOUD_PROVIDER]: 'dolor sit' + } }); expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display'); + const filteredInventoryDataAuthorized = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INVENTORY_ID]: 'XXXX-XXXX-XXXXX-XXXXX' + }, + session: { authorized: { inventory: true } } + }); + + expect(filteredInventoryDataAuthorized).toMatchSnapshot('filtered, authorized'); + + const filteredInventoryDataInfinite = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: false + } + }); + + expect(filteredInventoryDataInfinite).toMatchSnapshot('filtered, infinite'); + expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true); }); @@ -110,6 +122,16 @@ describe('Product RHEL config', () => { expect(filteredGuestsData).toMatchSnapshot('filtered'); + const filteredGuestsDataMissing = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...guestsData, + inventoryId: undefined + } + }); + + expect(filteredGuestsDataMissing).toMatchSnapshot('filtered, missing inventory id'); + const filteredGuestsDataAuthorized = parseRowCellsListData({ filters: initialFilters, cellData: guestsData, diff --git a/src/config/__tests__/product.rhods.test.js b/src/config/__tests__/product.rhods.test.js index 47bf93e06..f19c454fe 100644 --- a/src/config/__tests__/product.rhods.test.js +++ b/src/config/__tests__/product.rhods.test.js @@ -52,7 +52,7 @@ describe('Product RHODS config', () => { /** * FixMe: this test needs to be updated as part of the refactor towards instances vs hosts */ - it('should apply an instances inventory configuration under hosts', () => { + it('should apply an inventory configuration', () => { const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery } = config; const inventoryData = { diff --git a/src/config/__tests__/product.rhosak.test.js b/src/config/__tests__/product.rhosak.test.js index 1c6a79d29..44104e931 100644 --- a/src/config/__tests__/product.rhosak.test.js +++ b/src/config/__tests__/product.rhosak.test.js @@ -52,7 +52,7 @@ describe('Product RHOSAK config', () => { /** * FixMe: this test needs to be updated as part of the refactor towards instances vs hosts */ - it('should apply an instances inventory configuration under hosts', () => { + it('should apply an inventory configuration', () => { const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery } = config; const inventoryData = { diff --git a/src/config/__tests__/product.satellite.test.js b/src/config/__tests__/product.satellite.test.js index 7096ecbad..8a1d1e3bc 100644 --- a/src/config/__tests__/product.satellite.test.js +++ b/src/config/__tests__/product.satellite.test.js @@ -53,6 +53,17 @@ describe('Product Satellite config', () => { expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display'); + const filteredInventoryDataAuthorized = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INVENTORY_ID]: 'XXXX-XXXX-XXXXX-XXXXX' + }, + session: { authorized: { inventory: true } } + }); + + expect(filteredInventoryDataAuthorized).toMatchSnapshot('filtered, authorized'); + expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true); }); @@ -74,6 +85,16 @@ describe('Product Satellite config', () => { expect(filteredGuestsData).toMatchSnapshot('filtered'); + const filteredGuestsDataMissing = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...guestsData, + inventoryId: undefined + } + }); + + expect(filteredGuestsDataMissing).toMatchSnapshot('filtered, missing inventory id'); + const filteredGuestsDataAuthorized = parseRowCellsListData({ filters: initialFilters, cellData: guestsData,