From b236fb229e126b2841ccf561befe08f5788b15ad Mon Sep 17 00:00:00 2001 From: Sviatlana Stsiapanava <152482600+sviatlana-stsiapanava@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:03:33 +0500 Subject: [PATCH] Add the test case C440082 (#4192) --- ...gs-incorrectly-formatted-identifiers.cy.js | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-incorrectly-formatted-identifiers.cy.js diff --git a/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-incorrectly-formatted-identifiers.cy.js b/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-incorrectly-formatted-identifiers.cy.js new file mode 100644 index 0000000000..218b5bfef7 --- /dev/null +++ b/cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-holdings-incorrectly-formatted-identifiers.cy.js @@ -0,0 +1,97 @@ +import permissions from '../../../support/dictionary/permissions'; +import BulkEditSearchPane from '../../../support/fragments/bulk-edit/bulk-edit-search-pane'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; +import FileManager from '../../../support/utils/fileManager'; +import getRandomPostfix, { randomFourDigitNumber } from '../../../support/utils/stringTools'; +import InteractorsTools from '../../../support/utils/interactorsTools'; + +let user; +const fileNameInvalidHoldingsUUIDs = `invalidHoldingsUUIDs ${getRandomPostfix()}.csv`; +const fileNameInvalidHoldingsHRIDs = `invalidHoldingsHRIDs ${getRandomPostfix()}.csv`; +const fileNameInvalidInstanceHRIDs = `invalidInstanceHRIDs ${getRandomPostfix()}.csv`; +const fileNameInvalidItemBarcodes = `invalidItemBarcodes ${getRandomPostfix()}.csv`; +const arrayOfFileNames = [ + fileNameInvalidHoldingsUUIDs, + fileNameInvalidHoldingsHRIDs, + fileNameInvalidInstanceHRIDs, + fileNameInvalidItemBarcodes, +]; +const errorMessage = + 'Incorrect number of tokens found in record: expected 1 actual 3 (IncorrectTokenCountException)'; +const getCalloutContent = (fileName) => { + return `${fileName} is formatted incorrectly. Please correct the formatting and upload the file again.`; +}; +const checkResponse = (alias, fileName) => { + cy.wait(alias).then((interception) => { + expect(interception.response.body.linkToTriggeringCsvFile).to.include(fileName); + expect(interception.response.body.errorMessage).to.eq(errorMessage); + }); +}; + +describe('bulk-edit', () => { + describe('in-app approach', () => { + before('create test data', () => { + cy.createTempUser([permissions.bulkEditEdit.gui, permissions.inventoryCRUDHoldings.gui]).then( + (userProperties) => { + user = userProperties; + + arrayOfFileNames.forEach((fileName) => { + FileManager.createFile( + `cypress/fixtures/${fileName}`, + `${randomFourDigitNumber()},${randomFourDigitNumber()},${randomFourDigitNumber()}`, + ); + }); + + cy.login(user.username, user.password, { + path: TopMenu.bulkEditPath, + waiter: BulkEditSearchPane.waitLoading, + }); + }, + ); + }); + + after('delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + + arrayOfFileNames.forEach((fileName) => { + FileManager.deleteFile(`cypress/fixtures/${fileName}`); + }); + }); + + it( + 'C440082 Verify Error while uploading file with incorrectly formatted identifiers - Holdings (firebird)', + { tags: ['criticalPath', 'firebird'] }, + () => { + BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Holdings', 'Holdings UUIDs'); + cy.intercept('GET', '/bulk-operations/*').as('bulkOperationHoldingsUUIDs'); + BulkEditSearchPane.uploadFile(fileNameInvalidHoldingsUUIDs); + InteractorsTools.checkCalloutErrorMessage(getCalloutContent(fileNameInvalidHoldingsUUIDs)); + checkResponse('@bulkOperationHoldingsUUIDs', fileNameInvalidHoldingsUUIDs); + InteractorsTools.dismissCallout(getCalloutContent(fileNameInvalidHoldingsUUIDs)); + + BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Holdings', 'Holdings HRIDs'); + cy.intercept('GET', '/bulk-operations/*').as('bulkOperationHoldingsHRIDs'); + BulkEditSearchPane.uploadFile(fileNameInvalidHoldingsHRIDs); + InteractorsTools.checkCalloutErrorMessage(getCalloutContent(fileNameInvalidHoldingsHRIDs)); + checkResponse('@bulkOperationHoldingsHRIDs', fileNameInvalidHoldingsHRIDs); + InteractorsTools.dismissCallout(getCalloutContent(fileNameInvalidHoldingsHRIDs)); + + BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Holdings', 'Instance HRIDs'); + cy.intercept('GET', '/bulk-operations/*').as('bulkOperationInstanceHRIDs'); + BulkEditSearchPane.uploadFile(fileNameInvalidInstanceHRIDs); + InteractorsTools.checkCalloutErrorMessage(getCalloutContent(fileNameInvalidInstanceHRIDs)); + checkResponse('@bulkOperationInstanceHRIDs', fileNameInvalidInstanceHRIDs); + InteractorsTools.dismissCallout(getCalloutContent(fileNameInvalidInstanceHRIDs)); + + BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Holdings', 'Item barcodes'); + cy.intercept('GET', '/bulk-operations/*').as('bulkOperationItemBarcodes'); + BulkEditSearchPane.uploadFile(fileNameInvalidItemBarcodes); + InteractorsTools.checkCalloutErrorMessage(getCalloutContent(fileNameInvalidItemBarcodes)); + checkResponse('@bulkOperationItemBarcodes', fileNameInvalidItemBarcodes); + InteractorsTools.dismissCallout(getCalloutContent(fileNameInvalidItemBarcodes)); + }, + ); + }); +});