Skip to content

Commit

Permalink
Add the test case C435917 (#4203)
Browse files Browse the repository at this point in the history
Co-authored-by: Ostap Voitsekhovskyi <[email protected]>
  • Loading branch information
sviatlana-stsiapanava and ostapwd authored Sep 17, 2024
1 parent 746ca86 commit 7a76326
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
import {
APPLICATION_NAMES,
LOAN_TYPE_NAMES,
BULK_EDIT_TABLE_COLUMN_HEADERS,
LOCATION_NAMES,
} from '../../../support/constants';
import permissions from '../../../support/dictionary/permissions';
import BulkEditActions from '../../../support/fragments/bulk-edit/bulk-edit-actions';
import BulkEditSearchPane from '../../../support/fragments/bulk-edit/bulk-edit-search-pane';
import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView';
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
import InventorySearchAndFilter from '../../../support/fragments/inventory/inventorySearchAndFilter';
import QickMarcEditor from '../../../support/fragments/quickMarcEditor';
import TopMenu from '../../../support/fragments/topMenu';
import Users from '../../../support/fragments/users/users';
import FileManager from '../../../support/utils/fileManager';
import getRandomPostfix from '../../../support/utils/stringTools';
import BulkEditFiles from '../../../support/fragments/bulk-edit/bulk-edit-files';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import HoldingsRecordView from '../../../support/fragments/inventory/holdingsRecordView';
import ItemRecordView from '../../../support/fragments/inventory/item/itemRecordView';

let user;
let location;
let materialTypeId;
let loanTypeId;
const instanceFolio = {
instanceTitle: `C435917 folio instance-${getRandomPostfix()}`,
};
const instanceMarc = {
instanceTitle: `C435917 first marc instance-${getRandomPostfix()}`,
};
const instanceMarcWithItem = {
instanceTitle: `C435917 second marc instance-${getRandomPostfix()}`,
itemBarcode: getRandomPostfix(),
};
const actionsToSelect = {
setTrue: 'Set true',
};
const leader = QickMarcEditor.defaultValidLdr;
const getMarcBibFields = (intsanceTitle) => {
return [
{
tag: '008',
content: QickMarcEditor.defaultValid008Values,
},
{
tag: '245',
content: `$a ${intsanceTitle}`,
indicators: ['1', '1'],
},
];
};
const validInstanceUUIDsFileName = `validInstanceUUIDs_${getRandomPostfix()}.csv`;
const matchedRecordsFileName = `*-Matched-Records-${validInstanceUUIDsFileName}`;
const previewFileName = `*-Updates-Preview-${validInstanceUUIDsFileName}`;
const changedRecordsFileName = `*-Changed-Records-${validInstanceUUIDsFileName}`;

describe('bulk-edit', () => {
describe('in-app approach', () => {
before('create test data', () => {
cy.clearLocalStorage();
cy.createTempUser([
permissions.bulkEditLogsView.gui,
permissions.bulkEditEdit.gui,
permissions.bulkEditView.gui,
permissions.inventoryAll.gui,
]).then((userProperties) => {
user = userProperties;

cy.getAdminToken();
cy.getInstanceTypes({ limit: 1 })
.then((instanceTypes) => {
instanceFolio.instanceTypeId = instanceTypes[0].id;

cy.getLocations({ query: `name="${LOCATION_NAMES.MAIN_LIBRARY_UI}"` }).then((res) => {
location = res;
});
cy.getMaterialTypes({ limit: 1 }).then((res) => {
materialTypeId = res.id;
});
cy.getLoanTypes({ query: `name="${LOAN_TYPE_NAMES.CAN_CIRCULATE}"` }).then((res) => {
loanTypeId = res[0].id;
});

// create FOLIO instance without Holdings
InventoryInstances.createFolioInstanceViaApi({
instance: {
instanceTypeId: instanceFolio.instanceTypeId,
title: instanceFolio.instanceTitle,
},
}).then((instanceData) => {
instanceFolio.uuid = instanceData.instanceId;

cy.getInstanceById(instanceData.instanceId).then((folioInstanceData) => {
instanceFolio.hrid = folioInstanceData.hrid;
});
});
})
.then(() => {
// create MARC instance with Holding and without Items
cy.createMarcBibliographicViaAPI(
leader,
getMarcBibFields(instanceMarc.instanceTitle),
).then((instanceId) => {
instanceMarc.uuid = instanceId;

cy.getInstanceById(instanceId).then((instanceData) => {
instanceMarc.hrid = instanceData.hrid;

cy.createSimpleMarcHoldingsViaAPI(
instanceData.id,
instanceData.hrid,
location.code,
);
});
});
})
.then(() => {
// create MARC instance with Holding and Item
cy.createMarcBibliographicViaAPI(
leader,
getMarcBibFields(instanceMarcWithItem.instanceTitle),
).then((instanceId) => {
instanceMarcWithItem.uuid = instanceId;

cy.getInstanceById(instanceId).then((instanceData) => {
instanceMarcWithItem.hrid = instanceData.hrid;

cy.createSimpleMarcHoldingsViaAPI(
instanceData.id,
instanceData.hrid,
location.code,
).then((holdingId) => {
cy.createItem({
holdingsRecordId: holdingId,
materialType: { id: materialTypeId },
permanentLoanType: { id: loanTypeId },
status: { name: 'Available' },
barcode: instanceMarcWithItem.itemBarcode,
});
});
});
});
})
.then(() => {
FileManager.createFile(
`cypress/fixtures/${validInstanceUUIDsFileName}`,
`${instanceFolio.uuid}\n${instanceMarc.uuid}\n${instanceMarcWithItem.uuid}`,
);
});

cy.login(user.username, user.password, {
path: TopMenu.bulkEditPath,
waiter: BulkEditSearchPane.waitLoading,
});
});
});

after('delete test data', () => {
cy.getAdminToken();
Users.deleteViaApi(user.userId);
[instanceFolio.uuid, instanceMarc.uuid, instanceMarcWithItem.uuid].forEach((instanceId) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(instanceId);
});
FileManager.deleteFile(`cypress/fixtures/${validInstanceUUIDsFileName}`);
FileManager.deleteFileFromDownloadsByMask(
matchedRecordsFileName,
previewFileName,
changedRecordsFileName,
);
});

it(
'C435917 Verify Holdings with source MARC are NOT modified by the "Suppress from discovery" option (firebird)',
{ tags: ['criticalPath', 'firebird'] },
() => {
BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Instances', 'Instance UUIDs');
BulkEditSearchPane.uploadFile(validInstanceUUIDsFileName);
BulkEditSearchPane.waitFileUploading();
BulkEditSearchPane.verifyPaneTitleFileName(validInstanceUUIDsFileName);
BulkEditSearchPane.verifyPaneRecordsCount('3');
BulkEditSearchPane.verifyFileNameHeadLine(validInstanceUUIDsFileName);
BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion(
instanceFolio.hrid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID,
instanceFolio.hrid,
);
BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion(
instanceMarc.hrid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID,
instanceMarc.hrid,
);
BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion(
instanceMarcWithItem.hrid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID,
instanceMarcWithItem.hrid,
);
BulkEditActions.openActions();
BulkEditSearchPane.changeShowColumnCheckboxIfNotYet(
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.STAFF_SUPPRESS,
);
BulkEditSearchPane.verifyResultColumnTitles(
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
);
BulkEditSearchPane.verifyResultColumnTitles(
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.STAFF_SUPPRESS,
);
BulkEditActions.openActions();
BulkEditActions.downloadMatchedResults();

const createdRecordsUUIDs = [
instanceFolio.uuid,
instanceMarc.uuid,
instanceMarcWithItem.uuid,
];

createdRecordsUUIDs.forEach((uuid) => {
BulkEditFiles.verifyValueInRowByUUID(
matchedRecordsFileName,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID,
uuid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID,
uuid,
);
});

BulkEditActions.openStartBulkEditInstanceForm();
BulkEditSearchPane.verifyBulkEditsAccordionExists();
BulkEditActions.verifyOptionsDropdown();
BulkEditActions.verifyRowIcons();
BulkEditActions.selectOption('Suppress from discovery');
BulkEditActions.selectSecondAction(actionsToSelect.setTrue);
BulkEditActions.verifySecondActionSelected(actionsToSelect.setTrue);
BulkEditActions.applyToHoldingsItemsRecordsCheckboxExists(true);
BulkEditSearchPane.isConfirmButtonDisabled(false);
BulkEditActions.confirmChanges();
BulkEditActions.verifyMessageBannerInAreYouSureForm(3);

const createdRecordsHRIDs = [
instanceFolio.hrid,
instanceMarc.hrid,
instanceMarcWithItem.hrid,
];

createdRecordsHRIDs.forEach((hrid) => {
BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifier(
hrid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
'true',
);
});

BulkEditActions.verifyKeepEditingButtonDisabled(false);
BulkEditActions.verifyDownloadPreviewButtonDisabled(false);
BulkEditActions.isCommitButtonDisabled(false);
BulkEditActions.downloadPreview();

createdRecordsUUIDs.forEach((uuid) => {
BulkEditFiles.verifyValueInRowByUUID(
previewFileName,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID,
uuid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
'true',
);
});

BulkEditActions.commitChanges();
BulkEditSearchPane.waitFileUploading();
BulkEditActions.verifySuccessBanner(3);
BulkEditSearchPane.verifyPaneRecordsChangedCount(3);
BulkEditSearchPane.verifyPaneTitleFileName(validInstanceUUIDsFileName);
BulkEditSearchPane.verifyFileNameHeadLine(validInstanceUUIDsFileName);

createdRecordsHRIDs.forEach((hrid) => {
BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInChangesAccordion(
hrid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
'true',
);
});

BulkEditActions.openActions();
BulkEditActions.downloadChangedCSV();

createdRecordsUUIDs.forEach((uuid) => {
BulkEditFiles.verifyValueInRowByUUID(
changedRecordsFileName,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID,
uuid,
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.SUPPRESS_FROM_DISCOVERY,
'true',
);
});

TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY);
InventorySearchAndFilter.searchInstanceByHRID(instanceFolio.hrid);
InventoryInstances.selectInstance();
InventoryInstance.verifyInstanceTitle(instanceFolio.instanceTitle);
InstanceRecordView.verifyMarkAsSuppressedFromDiscovery();

InventorySearchAndFilter.searchInstanceByHRID(instanceMarc.hrid);
InventoryInstances.selectInstance();
InventoryInstance.verifyInstanceTitle(instanceMarc.instanceTitle);
InstanceRecordView.verifyMarkAsSuppressedFromDiscovery();
InventorySearchAndFilter.selectViewHoldings();
HoldingsRecordView.waitLoading();
cy.wait(1000);
HoldingsRecordView.checkMarkAsSuppressedFromDiscoveryAbsent();
HoldingsRecordView.close();

InventorySearchAndFilter.searchInstanceByHRID(instanceMarcWithItem.hrid);
InventoryInstances.selectInstance();
InventoryInstance.verifyInstanceTitle(instanceMarcWithItem.instanceTitle);
InstanceRecordView.verifyMarkAsSuppressedFromDiscovery();
InventorySearchAndFilter.selectViewHoldings();
HoldingsRecordView.waitLoading();
cy.wait(1000);
HoldingsRecordView.checkMarkAsSuppressedFromDiscoveryAbsent();
HoldingsRecordView.close();
InventoryInstance.openHoldingsAccordion(LOCATION_NAMES.MAIN_LIBRARY_UI);
InventoryInstance.openItemByBarcode(instanceMarcWithItem.itemBarcode);
cy.wait(1000);
ItemRecordView.suppressedAsDiscoveryIsAbsent();
},
);
});
});
24 changes: 23 additions & 1 deletion cypress/support/api/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,29 @@ Cypress.Commands.add(
marcFormat: 'HOLDINGS',
suppressDiscovery: false,
},
}).then(({ body }) => cy.expect(body.status === 'IN_PROGRESS'));
}).then(({ body }) => {
cy.expect(body.status === 'IN_PROGRESS');

recurse(
() => {
return cy.okapiRequest({
method: 'GET',
path: `records-editor/records/status?qmRecordId=${body.qmRecordId}`,
isDefaultSearchParamsRequired: false,
});
},
(response) => response.body.status === 'CREATED',
{
limit: 10,
timeout: 80000,
delay: 5000,
},
).then((response) => {
cy.wrap(response.body.externalId).as('createdMarcHoldingId');

return cy.get('@createdMarcHoldingId');
});
});
},
);

Expand Down
7 changes: 7 additions & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,13 @@ export const BULK_EDIT_TABLE_COLUMN_HEADERS = {
RECEIPT_STATUS: 'Receipt status',
TAGS: 'Tags',
},
INVENTORY_INSTANCES: {
INSTANCE_UUID: 'Instance UUID',
INSTANCE_HRID: 'Instance HRID',
SUPPRESS_FROM_DISCOVERY: 'Suppress from discovery',
STAFF_SUPPRESS: 'Staff suppress',
RESOURCE_TITLE: 'Resource title',
},
};

export const HOLDING_NOTE_TYPES = {
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/fragments/bulk-edit/bulk-edit-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default {
areYouSureForm.find(HTML(including(`${count} records will be changed`))).exists(),
areYouSureForm.find(keepEditingBtn).exists(),
areYouSureForm.find(downloadPreviewBtn).exists(),
areYouSureForm.find(Button('Commit changes')).exists(),
areYouSureForm.find(commitChanges).exists(),
areYouSureForm.find(MultiColumnListCell(cellContent)).exists(),
]);
},
Expand Down Expand Up @@ -985,7 +985,7 @@ export default {

commitChanges() {
cy.wait(2000);
cy.do([Modal().find(Button('Commit changes')).click()]);
cy.do([Modal().find(commitChanges).click()]);
},

clickNext() {
Expand Down
Loading

0 comments on commit 7a76326

Please sign in to comment.