diff --git a/cypress/e2e/consortia/bulk-edit/in-app/bulk-edit-in-app-verify-preview-of-record-matched-valid-instance-identifier.cy.js b/cypress/e2e/consortia/bulk-edit/in-app/bulk-edit-in-app-verify-preview-of-record-matched-valid-instance-identifier.cy.js new file mode 100644 index 0000000000..6a59a0d7d0 --- /dev/null +++ b/cypress/e2e/consortia/bulk-edit/in-app/bulk-edit-in-app-verify-preview-of-record-matched-valid-instance-identifier.cy.js @@ -0,0 +1,202 @@ +import permissions from '../../../../support/dictionary/permissions'; +import BulkEditSearchPane from '../../../../support/fragments/bulk-edit/bulk-edit-search-pane'; +import BulkEditActions from '../../../../support/fragments/bulk-edit/bulk-edit-actions'; +import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances'; +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 ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager'; +import { tenantNames } from '../../../../support/dictionary/affiliations'; +import { BULK_EDIT_TABLE_COLUMN_HEADERS } from '../../../../support/constants'; +import BulkEditFiles from '../../../../support/fragments/bulk-edit/bulk-edit-files'; +import ExportFile from '../../../../support/fragments/data-export/exportFile'; + +let user; +let instanceTypeId; +const firstInstance = { + title: `C476785 first instance-${getRandomPostfix()}`, +}; +const secondInstance = { + title: `C476785 second instance-${getRandomPostfix()}`, +}; +const recordIdentifier = 'Instance HRIDs'; +const errorText = 'Duplicate entry'; +const firstInstanceUUIDsFileName = `instanceUUIDs-${getRandomPostfix()}.csv`; +const secondInstanceHRIDsFileName = `instanceHRIDs-${getRandomPostfix()}.csv`; +const firstMatchedRecordsFileName = `*-Matched-Records-${firstInstanceUUIDsFileName}`; +const secondMatchedRecordsFileName = `*-Matched-Records-${secondInstanceHRIDsFileName}`; +const errorsFromMatchingFileName = `*-Matching-Records-Errors-${secondInstanceHRIDsFileName}`; + +describe('Bulk-edit', () => { + describe('In-app approach', () => { + describe('Consortia', () => { + before('create test data', () => { + cy.clearLocalStorage(); + + cy.getAdminToken(); + cy.createTempUser([ + permissions.bulkEditView.gui, + permissions.uiInventoryViewInstances.gui, + ]).then((userProperties) => { + user = userProperties; + + cy.getInstanceTypes({ limit: 1 }) + .then((instanceTypes) => { + instanceTypeId = instanceTypes[0].id; + }) + .then(() => { + InventoryInstances.createFolioInstanceViaApi({ + instance: { + instanceTypeId, + title: firstInstance.title, + }, + }); + }) + .then((instanceData) => { + firstInstance.uuid = instanceData.instanceId; + }) + .then(() => { + cy.getInstanceById(firstInstance.uuid).then((res) => { + firstInstance.hrid = res.hrid; + }); + }) + .then(() => { + InventoryInstances.createFolioInstanceViaApi({ + instance: { + instanceTypeId, + title: secondInstance.title, + }, + }); + }) + .then((instanceData) => { + secondInstance.uuid = instanceData.instanceId; + }) + .then(() => { + cy.getInstanceById(secondInstance.uuid).then((res) => { + secondInstance.hrid = res.hrid; + }); + }) + .then(() => { + FileManager.createFile( + `cypress/fixtures/${firstInstanceUUIDsFileName}`, + firstInstance.uuid, + ); + FileManager.createFile( + `cypress/fixtures/${secondInstanceHRIDsFileName}`, + `${secondInstance.hrid}\r\n${secondInstance.hrid}`, + ); + }); + + cy.login(user.username, user.password, { + path: TopMenu.bulkEditPath, + waiter: BulkEditSearchPane.waitLoading, + }); + ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.central); + }); + }); + + after('delete test data', () => { + cy.getAdminToken(); + InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(firstInstance.uuid); + InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(secondInstance.uuid); + Users.deleteViaApi(user.userId); + FileManager.deleteFile(`cypress/fixtures/${firstInstanceUUIDsFileName}`); + FileManager.deleteFile(`cypress/fixtures/${secondInstanceHRIDsFileName}`); + FileManager.deleteFileFromDownloadsByMask( + firstMatchedRecordsFileName, + secondMatchedRecordsFileName, + errorsFromMatchingFileName, + ); + }); + + it( + 'C476785 Identifier - Verify "Preview of record matched" when uploading valid Instance identifiers in Central tenant (consortia) (firebird)', + { tags: ['smokeECS', 'firebird'] }, + () => { + BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Instance', 'Instance UUIDs'); + BulkEditSearchPane.uploadFile(firstInstanceUUIDsFileName); + BulkEditSearchPane.waitFileUploading(); + BulkEditSearchPane.verifyPaneTitleFileName(firstInstanceUUIDsFileName); + BulkEditSearchPane.verifyPaneRecordsCount('1'); + BulkEditSearchPane.verifyFileNameHeadLine(firstInstanceUUIDsFileName); + BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion( + firstInstance.hrid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID, + firstInstance.hrid, + ); + BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion( + firstInstance.hrid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.RESOURCE_TITLE, + firstInstance.title, + ); + BulkEditSearchPane.verifyPreviousPaginationButtonDisabled(); + BulkEditSearchPane.verifyNextPaginationButtonDisabled(); + BulkEditSearchPane.verifyActionsAfterConductedCSVUploading(false); + BulkEditSearchPane.verifySearchColumnNameTextFieldExists(); + BulkEditSearchPane.verifyCheckedCheckboxesPresentInTheTable(); + BulkEditActions.openActions(); + BulkEditActions.downloadMatchedResults(); + BulkEditFiles.verifyValueInRowByUUID( + firstMatchedRecordsFileName, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID, + firstInstance.uuid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.RESOURCE_TITLE, + firstInstance.title, + ); + BulkEditFiles.verifyValueInRowByUUID( + firstMatchedRecordsFileName, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID, + firstInstance.uuid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID, + firstInstance.hrid, + ); + + BulkEditSearchPane.selectRecordIdentifier(recordIdentifier); + BulkEditSearchPane.verifyAfterChoosingIdentifier(recordIdentifier); + cy.wait(2000); + BulkEditSearchPane.uploadFile(secondInstanceHRIDsFileName); + BulkEditSearchPane.waitFileUploading(); + BulkEditSearchPane.verifyPaneTitleFileName(secondInstanceHRIDsFileName); + BulkEditSearchPane.verifyPaneRecordsCount('1'); + BulkEditSearchPane.verifyFileNameHeadLine(secondInstanceHRIDsFileName); + BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion( + secondInstance.hrid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID, + secondInstance.hrid, + ); + BulkEditSearchPane.verifyExactChangesUnderColumnsByIdentifierInResultsAccordion( + secondInstance.hrid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.RESOURCE_TITLE, + secondInstance.title, + ); + BulkEditSearchPane.verifyPreviousPaginationButtonDisabled(); + BulkEditSearchPane.verifyNextPaginationButtonDisabled(); + BulkEditSearchPane.verifyErrorLabel(secondInstanceHRIDsFileName, 1, 1); + BulkEditSearchPane.verifyReasonForError(errorText); + BulkEditSearchPane.verifyNonMatchedResults(secondInstance.hrid, `${errorText} `); + BulkEditActions.downloadMatchedResults(); + BulkEditFiles.verifyValueInRowByUUID( + secondMatchedRecordsFileName, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID, + secondInstance.uuid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.RESOURCE_TITLE, + secondInstance.title, + ); + BulkEditFiles.verifyValueInRowByUUID( + secondMatchedRecordsFileName, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_UUID, + secondInstance.uuid, + BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_INSTANCES.INSTANCE_HRID, + secondInstance.hrid, + ); + BulkEditActions.downloadErrors(); + ExportFile.verifyFileIncludes(errorsFromMatchingFileName, [ + secondInstance.hrid, + errorText, + ]); + }, + ); + }); + }); +}); 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 840003973f..91210f5d56 100644 --- a/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js +++ b/cypress/support/fragments/bulk-edit/bulk-edit-search-pane.js @@ -40,6 +40,8 @@ const confirmChanges = Button('Confirm changes'); const buildQueryButton = Button('Build query'); const searchColumnNameTextfield = TextField({ placeholder: 'Search column name' }); const areYouSureForm = Modal('Are you sure?'); +const previousPaginationButton = Button('Previous'); +const nextPaginationButton = Button('Next'); export const userIdentifiers = ['User UUIDs', 'User Barcodes', 'External IDs', 'Usernames']; @@ -299,6 +301,7 @@ export default { selectRecordIdentifier(value) { cy.do(recordIdentifierDropdown.choose(value)); + cy.wait(1000); }, clickToBulkEditMainButton() { @@ -585,6 +588,10 @@ export default { } }, + verifySearchColumnNameTextFieldExists() { + cy.expect(DropdownMenu().find(searchColumnNameTextfield).exists()); + }, + verifyUsersActionShowColumns() { cy.expect([ DropdownMenu().find(Checkbox('Username')).has({ checked: true }), @@ -887,4 +894,12 @@ export default { verifyBulkEditsAccordionExists() { cy.expect(bulkEditsAccordion.exists()); }, + + verifyPreviousPaginationButtonDisabled(isDisabled = true) { + cy.expect(previousPaginationButton.has({ disabled: isDisabled })); + }, + + verifyNextPaginationButtonDisabled(isDisabled = true) { + cy.expect(nextPaginationButton.has({ disabled: isDisabled })); + }, };