From 493bdc7e5e76682f666537b192561d81b2b896a1 Mon Sep 17 00:00:00 2001 From: Sherzod Kenjaev Date: Fri, 27 Dec 2024 21:02:24 +0500 Subject: [PATCH] Update tests with classification identifier types --- ...ation-all-option-is-case-insensitive.cy.js | 23 ++++++++++++++++++ ...ification-option-is-case-insensitive.cy.js | 24 ++++++++++++++++++- ...ification-option-is-case-insensitive.cy.js | 24 ++++++++++++++++++- ...type-using-classification-all-option.cy.js | 23 ++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/inventory/classification-browse/browse-classification-using-classification-all-option-is-case-insensitive.cy.js b/cypress/e2e/inventory/classification-browse/browse-classification-using-classification-all-option-is-case-insensitive.cy.js index c637c16903..98d1e70b9e 100644 --- a/cypress/e2e/inventory/classification-browse/browse-classification-using-classification-all-option-is-case-insensitive.cy.js +++ b/cypress/e2e/inventory/classification-browse/browse-classification-using-classification-all-option-is-case-insensitive.cy.js @@ -4,6 +4,9 @@ import DataImport from '../../../support/fragments/data_import/dataImport'; import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; import InventorySearchAndFilter from '../../../support/fragments/inventory/inventorySearchAndFilter'; +import ClassificationBrowse, { + defaultClassificationBrowseIdsAlgorithms, +} from '../../../support/fragments/settings/inventory/instances/classificationBrowse'; import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; import getRandomPostfix from '../../../support/utils/stringTools'; @@ -18,6 +21,8 @@ describe('Inventory', () => { 'C468255 Search by Classification (case insensitive check) Instance 3 - LC UPPER case', 'C468255 Search by Classification (case insensitive check) Instance 4 - LC lower case', ], + classificationBrowseId: defaultClassificationBrowseIdsAlgorithms[0].id, + classificationBrowseAlgorithm: defaultClassificationBrowseIdsAlgorithms[0].algorithm, }; const marcFile = { @@ -34,6 +39,18 @@ describe('Inventory', () => { // make sure there are no duplicate records in the system InventoryInstances.deleteInstanceByTitleViaApi('C468255*'); + // remove all identifier types from target classification browse, if any + ClassificationBrowse.getIdentifierTypesForCertainBrowseAPI( + testData.classificationBrowseId, + ).then((types) => { + testData.originalTypes = types; + }); + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + [], + ); + cy.createTempUser([Permissions.moduleDataImportEnabled.gui]).then((userProperties) => { testData.preconditionUserId = userProperties.userId; @@ -64,6 +81,12 @@ describe('Inventory', () => { after(() => { cy.getAdminToken(); + // restore the original identifier types for target classification browse + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + testData.originalTypes, + ); createdRecordIDs.forEach((id) => { InventoryInstance.deleteInstanceViaApi(id); }); diff --git a/cypress/e2e/inventory/classification-browse/browse-classification-using-dewey-decimal-classification-option-is-case-insensitive.cy.js b/cypress/e2e/inventory/classification-browse/browse-classification-using-dewey-decimal-classification-option-is-case-insensitive.cy.js index a0863c4e03..8763ae72f1 100644 --- a/cypress/e2e/inventory/classification-browse/browse-classification-using-dewey-decimal-classification-option-is-case-insensitive.cy.js +++ b/cypress/e2e/inventory/classification-browse/browse-classification-using-dewey-decimal-classification-option-is-case-insensitive.cy.js @@ -1,4 +1,4 @@ -import { DEFAULT_JOB_PROFILE_NAMES } from '../../../support/constants'; +import { DEFAULT_JOB_PROFILE_NAMES, CLASSIFICATION_IDENTIFIER_TYPES } from '../../../support/constants'; import Permissions from '../../../support/dictionary/permissions'; import DataImport from '../../../support/fragments/data_import/dataImport'; import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; @@ -7,6 +7,9 @@ import InventorySearchAndFilter from '../../../support/fragments/inventory/inven import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; import getRandomPostfix from '../../../support/utils/stringTools'; +import ClassificationBrowse, { + defaultClassificationBrowseIdsAlgorithms, +} from '../../../support/fragments/settings/inventory/instances/classificationBrowse'; describe('Inventory', () => { describe('Instance classification browse', () => { @@ -18,6 +21,8 @@ describe('Inventory', () => { 'C468258 Search by Classification (case insensitive check) Instance 1 - Dewey UPPER case', 'C468258 Search by Classification (case insensitive check) Instance 2 - Dewey lower case', ], + classificationBrowseId: defaultClassificationBrowseIdsAlgorithms[1].id, + classificationBrowseAlgorithm: defaultClassificationBrowseIdsAlgorithms[1].algorithm, }; const marcFile = { @@ -34,6 +39,17 @@ describe('Inventory', () => { // make sure there are no duplicate records in the system InventoryInstances.deleteInstanceByTitleViaApi('C468258*'); + ClassificationBrowse.getIdentifierTypesForCertainBrowseAPI( + testData.classificationBrowseId, + ).then((types) => { + testData.originalTypes = types; + }); + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + [CLASSIFICATION_IDENTIFIER_TYPES.DEWEY], + ); + cy.createTempUser([Permissions.moduleDataImportEnabled.gui]).then((userProperties) => { testData.preconditionUserId = userProperties.userId; @@ -64,6 +80,12 @@ describe('Inventory', () => { after(() => { cy.getAdminToken(); + // restore the original identifier types for target classification browse + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + testData.originalTypes, + ); createdRecordIDs.forEach((id) => { InventoryInstance.deleteInstanceViaApi(id); }); diff --git a/cypress/e2e/inventory/classification-browse/browse-classification-using-lib-of-congress-classification-option-is-case-insensitive.cy.js b/cypress/e2e/inventory/classification-browse/browse-classification-using-lib-of-congress-classification-option-is-case-insensitive.cy.js index 96c41d8577..a6e6cc82f7 100644 --- a/cypress/e2e/inventory/classification-browse/browse-classification-using-lib-of-congress-classification-option-is-case-insensitive.cy.js +++ b/cypress/e2e/inventory/classification-browse/browse-classification-using-lib-of-congress-classification-option-is-case-insensitive.cy.js @@ -1,4 +1,4 @@ -import { DEFAULT_JOB_PROFILE_NAMES } from '../../../support/constants'; +import { DEFAULT_JOB_PROFILE_NAMES, CLASSIFICATION_IDENTIFIER_TYPES } from '../../../support/constants'; import Permissions from '../../../support/dictionary/permissions'; import DataImport from '../../../support/fragments/data_import/dataImport'; import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; @@ -7,6 +7,9 @@ import InventorySearchAndFilter from '../../../support/fragments/inventory/inven import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; import getRandomPostfix from '../../../support/utils/stringTools'; +import ClassificationBrowse, { + defaultClassificationBrowseIdsAlgorithms, +} from '../../../support/fragments/settings/inventory/instances/classificationBrowse'; describe('Inventory', () => { describe('Instance classification browse', () => { @@ -18,6 +21,8 @@ describe('Inventory', () => { 'C468256 Search by Classification (case insensitive check) Instance 3 - LC UPPER case', 'C468256 Search by Classification (case insensitive check) Instance 4 - LC lower case', ], + classificationBrowseId: defaultClassificationBrowseIdsAlgorithms[2].id, + classificationBrowseAlgorithm: defaultClassificationBrowseIdsAlgorithms[2].algorithm, }; const marcFile = { @@ -34,6 +39,17 @@ describe('Inventory', () => { // make sure there are no duplicate records in the system InventoryInstances.deleteInstanceByTitleViaApi('C468256*'); + ClassificationBrowse.getIdentifierTypesForCertainBrowseAPI( + testData.classificationBrowseId, + ).then((types) => { + testData.originalTypes = types; + }); + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + [CLASSIFICATION_IDENTIFIER_TYPES.LC], + ); + cy.createTempUser([Permissions.moduleDataImportEnabled.gui]).then((userProperties) => { testData.preconditionUserId = userProperties.userId; @@ -64,6 +80,12 @@ describe('Inventory', () => { after(() => { cy.getAdminToken(); + // restore the original identifier types for target classification browse + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + testData.originalTypes, + ); createdRecordIDs.forEach((id) => { InventoryInstance.deleteInstanceViaApi(id); }); diff --git a/cypress/e2e/inventory/classification-browse/browse-classification-which-has-each-classification-type-using-classification-all-option.cy.js b/cypress/e2e/inventory/classification-browse/browse-classification-which-has-each-classification-type-using-classification-all-option.cy.js index 53d6d26026..440632ba2a 100644 --- a/cypress/e2e/inventory/classification-browse/browse-classification-which-has-each-classification-type-using-classification-all-option.cy.js +++ b/cypress/e2e/inventory/classification-browse/browse-classification-which-has-each-classification-type-using-classification-all-option.cy.js @@ -7,6 +7,9 @@ import getRandomPostfix from '../../../support/utils/stringTools'; import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; import { CLASSIFICATION_IDENTIFIER_TYPES } from '../../../support/constants'; +import ClassificationBrowse, { + defaultClassificationBrowseIdsAlgorithms, +} from '../../../support/fragments/settings/inventory/instances/classificationBrowse'; describe('Inventory', () => { describe('Instance classification browse', () => { @@ -26,6 +29,8 @@ describe('Inventory', () => { ], classificationOption: 'Classification (all)', instanceTitle: 'C468178 Browse by Classification Instance (has each classification type)', + classificationBrowseId: defaultClassificationBrowseIdsAlgorithms[0].id, + classificationBrowseAlgorithm: defaultClassificationBrowseIdsAlgorithms[0].algorithm, }; const localClassificationIdentifierType = { name: `C468178 Classification identifier type ${getRandomPostfix()}`, @@ -39,6 +44,18 @@ describe('Inventory', () => { // make sure there are no duplicate records in the system InventoryInstances.deleteInstanceByTitleViaApi('C468178*'); + // remove all identifier types from target classification browse, if any + ClassificationBrowse.getIdentifierTypesForCertainBrowseAPI( + testData.classificationBrowseId, + ).then((types) => { + testData.originalTypes = types; + }); + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + [], + ); + cy.createTempUser([Permissions.uiInventoryViewInstances.gui]).then( (createdUserProperties) => { user = createdUserProperties; @@ -124,6 +141,12 @@ describe('Inventory', () => { after('Delete user, test data', () => { cy.getAdminToken(); + // restore the original identifier types for target classification browse + ClassificationBrowse.updateIdentifierTypesAPI( + testData.classificationBrowseId, + testData.classificationBrowseAlgorithm, + testData.originalTypes, + ); ClassificationIdentifierTypes.deleteViaApi(classificationIdentifierTypeId); InventoryInstance.deleteInstanceViaApi(testData.instanceId); Users.deleteViaApi(user.userId);