Skip to content

Commit

Permalink
Update tests with classification identifier types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherzod-Kenjaev committed Dec 27, 2024
1 parent b13847d commit 493bdc7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {
Expand All @@ -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;

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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', () => {
Expand All @@ -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 = {
Expand All @@ -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;

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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', () => {
Expand All @@ -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 = {
Expand All @@ -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;

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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()}`,
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 493bdc7

Please sign in to comment.