diff --git a/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-with-source-marc.cy.js b/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-with-source-marc.cy.js new file mode 100644 index 0000000000..0cc7616362 --- /dev/null +++ b/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-with-source-marc.cy.js @@ -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(); + }, + ); + }); +}); diff --git a/cypress/support/api/inventory.js b/cypress/support/api/inventory.js index f175dd945a..c8f6aa469b 100644 --- a/cypress/support/api/inventory.js +++ b/cypress/support/api/inventory.js @@ -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'); + }); + }); }, ); diff --git a/cypress/support/constants.js b/cypress/support/constants.js index 53ace2350a..a79d08d516 100644 --- a/cypress/support/constants.js +++ b/cypress/support/constants.js @@ -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 = { diff --git a/cypress/support/fragments/bulk-edit/bulk-edit-actions.js b/cypress/support/fragments/bulk-edit/bulk-edit-actions.js index 7dd7392515..912d43080a 100644 --- a/cypress/support/fragments/bulk-edit/bulk-edit-actions.js +++ b/cypress/support/fragments/bulk-edit/bulk-edit-actions.js @@ -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(), ]); }, @@ -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() { diff --git a/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js b/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js index bb34818b85..840003973f 100644 --- a/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js +++ b/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js @@ -490,6 +490,28 @@ export default { }); }, + verifyExactChangesUnderColumnsByIdentifierInResultsAccordion(identifier, columnName, value) { + cy.then(() => resultsAccordion.find(MultiColumnListCell(identifier)).row()).then((index) => { + cy.expect( + resultsAccordion + .find(MultiColumnListRow({ indexRow: `row-${index}` })) + .find(MultiColumnListCell({ column: columnName, content: value })) + .exists(), + ); + }); + }, + + verifyExactChangesUnderColumnsByIdentifierInChangesAccordion(identifier, columnName, value) { + cy.then(() => changesAccordion.find(MultiColumnListCell(identifier)).row()).then((index) => { + cy.expect( + changesAccordion + .find(MultiColumnListRow({ indexRow: `row-${index}` })) + .find(MultiColumnListCell({ column: columnName, content: value })) + .exists(), + ); + }); + }, + verifyNonMatchedResults(...values) { cy.expect([ errorsAccordion.find(MultiColumnListHeader('Record identifier')).exists(), @@ -740,6 +762,14 @@ export default { cy.expect(bulkEditPane.find(HTML(`${value} records match`)).exists()); }, + verifyPaneRecordsChangedCount(value) { + cy.expect(bulkEditPane.find(HTML(`${value} records changed`)).exists()); + }, + + verifyFileNameHeadLine(fileName) { + cy.expect(bulkEditPane.find(HTML(`Filename: ${fileName}`)).exists()); + }, + verifyPaneTitleFileName(fileName) { cy.expect(Pane(`Bulk edit ${fileName}`).exists()); },