From fe93027adcb5536a4956b29148935c3a146d9fa5 Mon Sep 17 00:00:00 2001 From: Tetiana_Paranich Date: Tue, 14 Jan 2025 19:07:55 +0200 Subject: [PATCH] added test --- ...mation-using-not-existing-donor-code.cy.js | 151 ++++++++++++++++++ ...-create-for-multiple-target-profiles.cy.js | 2 +- ...rt-create-for-single-target-profiles.cy.js | 2 +- cypress/fixtures/marcBibFileForC554639.mrc | 1 + cypress/support/constants.js | 1 + .../support/fragments/orders/orderLines.js | 10 ++ .../fragments/organizations/organizations.js | 7 + .../newFieldMappingProfile.js | 41 ++++- 8 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 cypress/e2e/data-import/importing-marc-bib-files/importing-order-with-donor-information-using-not-existing-donor-code.cy.js create mode 100644 cypress/fixtures/marcBibFileForC554639.mrc diff --git a/cypress/e2e/data-import/importing-marc-bib-files/importing-order-with-donor-information-using-not-existing-donor-code.cy.js b/cypress/e2e/data-import/importing-marc-bib-files/importing-order-with-donor-information-using-not-existing-donor-code.cy.js new file mode 100644 index 0000000000..cda16b47a1 --- /dev/null +++ b/cypress/e2e/data-import/importing-marc-bib-files/importing-order-with-donor-information-using-not-existing-donor-code.cy.js @@ -0,0 +1,151 @@ +import { + ACQUISITION_METHOD_NAMES, + APPLICATION_NAMES, + FOLIO_RECORD_TYPE, + JOB_STATUS_NAMES, + ORDER_FORMAT_NAMES_IN_PROFILE, + ORDER_STATUSES, + RECORD_STATUSES, + VENDOR_NAMES, +} from '../../../support/constants'; +import { Permissions } from '../../../support/dictionary'; +import ActionProfiles from '../../../support/fragments/data_import/action_profiles/actionProfiles'; +import DataImport from '../../../support/fragments/data_import/dataImport'; +import JobProfiles from '../../../support/fragments/data_import/job_profiles/jobProfiles'; +import NewJobProfile from '../../../support/fragments/data_import/job_profiles/newJobProfile'; +import FileDetails from '../../../support/fragments/data_import/logs/fileDetails'; +import Logs from '../../../support/fragments/data_import/logs/logs'; +import OrderLines from '../../../support/fragments/orders/orderLines'; +import { NewOrganization, Organizations } from '../../../support/fragments/organizations'; +import { + ActionProfiles as SettingsActionProfiles, + FieldMappingProfiles as SettingsFieldMappingProfiles, + JobProfiles as SettingsJobProfiles, +} from '../../../support/fragments/settings/dataImport'; +import FieldMappingProfiles from '../../../support/fragments/settings/dataImport/fieldMappingProfile/fieldMappingProfiles'; +import SettingsDataImport, { + SETTINGS_TABS, +} from '../../../support/fragments/settings/dataImport/settingsDataImport'; +import TopMenuNavigation from '../../../support/fragments/topMenuNavigation'; +import Users from '../../../support/fragments/users/users'; +import getRandomPostfix from '../../../support/utils/stringTools'; + +describe('Data Import', () => { + describe('Importing MARC Bib files', () => { + let user; + const filePath = 'marcBibFileForC554639.mrc'; + const marcFileName = `554639 autotestFileName${getRandomPostfix()}.mrc`; + const organization = NewOrganization.getDefaultOrganization({ + isDonor: true, + isVendor: false, + }); + const donorNames = [organization.name, 'Amazon.com']; + const mappingProfile = { + name: `C554639 Import order with donor field ${getRandomPostfix()}`, + typeValue: FOLIO_RECORD_TYPE.ORDER, + orderStatus: ORDER_STATUSES.OPEN, + approved: true, + vendor: VENDOR_NAMES.GOBI, + title: '245$a', + acquisitionMethod: ACQUISITION_METHOD_NAMES.PURCHASE_AT_VENDOR_SYSTEM, + orderFormat: ORDER_FORMAT_NAMES_IN_PROFILE.PHYSICAL_RESOURCE, + receivingWorkflow: 'Synchronized', + physicalUnitPrice: '"20"', + quantityPhysical: '"1"', + currency: 'USD', + donor: [ + { value: '865$a', existingStatus: false }, + { value: organization.name, existingStatus: true }, + { value: '"88888"', existingStatus: false }, + ], + }; + const actionProfile = { + name: `C554639 Import order with donor field ${getRandomPostfix()}`, + typeValue: FOLIO_RECORD_TYPE.ORDER, + }; + const jobProfile = { + ...NewJobProfile.defaultJobProfile, + profileName: `C554639 Import order with donor field ${getRandomPostfix()}`, + }; + + before('Create user and login', () => { + cy.getAdminToken(); + Organizations.createOrganizationViaApi(organization); + Organizations.getOrganizationViaApi({ query: `name="${VENDOR_NAMES.AMAZON}"` }).then( + (body) => { + body.isDonor = true; + Organizations.addDonorInfoViaApi(body.id, body); + }, + ); + + cy.createTempUser([ + Permissions.settingsDataImportEnabled.gui, + Permissions.moduleDataImportEnabled.gui, + Permissions.inventoryAll.gui, + Permissions.uiOrdersView.gui, + ]).then((userProperties) => { + user = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS, APPLICATION_NAMES.DATA_IMPORT); + SettingsDataImport.selectSettingsTab(SETTINGS_TABS.FIELD_MAPPING_PROFILES); + }); + }); + + after('Delete test data', () => { + cy.getAdminToken().then(() => { + Users.deleteViaApi(user.userId); + SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfile.profileName); + SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name); + SettingsFieldMappingProfiles.deleteMappingProfileByNameViaApi(mappingProfile.name); + Organizations.deleteOrganizationViaApi(organization.id); + }); + }); + + it( + 'C554639 Importing order with donor information using not existing donor code (folijet)', + { tags: ['criticalPath', 'folijet', 'C554639'] }, + () => { + // create mapping profile + FieldMappingProfiles.createOrderMappingProfile(mappingProfile); + FieldMappingProfiles.checkMappingProfilePresented(mappingProfile.name); + + // create action profile + SettingsDataImport.selectSettingsTab(SETTINGS_TABS.ACTION_PROFILES); + ActionProfiles.create(actionProfile, mappingProfile.name); + ActionProfiles.checkActionProfilePresented(actionProfile.name); + + // create job profile + SettingsDataImport.selectSettingsTab(SETTINGS_TABS.JOB_PROFILES); + JobProfiles.createJobProfile(jobProfile); + NewJobProfile.linkActionProfile(actionProfile); + NewJobProfile.saveAndClose(); + JobProfiles.checkJobProfilePresented(jobProfile.profileName); + + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_IMPORT); + DataImport.verifyUploadState(); + DataImport.uploadFile(filePath, marcFileName); + JobProfiles.waitFileIsUploaded(); + JobProfiles.search(jobProfile.profileName); + JobProfiles.runImportFile(); + Logs.waitFileIsImported(marcFileName); + Logs.checkJobStatus(marcFileName, JOB_STATUS_NAMES.COMPLETED); + Logs.openFileDetails(marcFileName); + [ + FileDetails.columnNameInResultList.instance, + FileDetails.columnNameInResultList.holdings, + FileDetails.columnNameInResultList.item, + ].forEach((columnName) => { + FileDetails.checkStatusInColumn(RECORD_STATUSES.DASH, columnName); + }); + FileDetails.checkStatusInColumn( + RECORD_STATUSES.CREATED, + FileDetails.columnNameInResultList.order, + ); + FileDetails.openOrder(RECORD_STATUSES.CREATED); + OrderLines.verifyPOLDetailsIsOpened(); + OrderLines.checkDonorInformation(donorNames); + }, + ); + }); +}); diff --git a/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-multiple-target-profiles.cy.js b/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-multiple-target-profiles.cy.js index f66ba99dcd..3043398419 100644 --- a/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-multiple-target-profiles.cy.js +++ b/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-multiple-target-profiles.cy.js @@ -109,7 +109,7 @@ describe('Inventory', () => { InstanceRecordView.verifyCalloutMessage(calloutMessage); // need to wait because after the import the data in the instance is displayed for a long time // https://issues.folio.org/browse/MODCPCT-73 - cy.wait(10000); + cy.wait(15000); InstanceRecordView.verifyInstanceIsOpened(instanceTitle); InstanceRecordView.getAssignedHRID().then((initialInstanceHrId) => { instanceHRID = initialInstanceHrId; diff --git a/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-single-target-profiles.cy.js b/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-single-target-profiles.cy.js index 14fae07dc4..aeab51a6c2 100644 --- a/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-single-target-profiles.cy.js +++ b/cypress/e2e/inventory/single-record-import/modal-window-for-isri-import-create-for-single-target-profiles.cy.js @@ -60,7 +60,7 @@ describe('Inventory', () => { InstanceRecordView.verifyCalloutMessage(calloutMessage); // need to wait because after the import the data in the instance is displayed for a long time // https://issues.folio.org/browse/MODCPCT-73 - cy.wait(10000); + cy.wait(15000); InstanceRecordView.verifyInstanceIsOpened(instanceTitle); InstanceRecordView.getAssignedHRID().then((initialInstanceHrId) => { instanceHRID = initialInstanceHrId; diff --git a/cypress/fixtures/marcBibFileForC554639.mrc b/cypress/fixtures/marcBibFileForC554639.mrc new file mode 100644 index 0000000000..667d739d82 --- /dev/null +++ b/cypress/fixtures/marcBibFileForC554639.mrc @@ -0,0 +1 @@ +00575cam a22002173 4500001001300000003000600013005001700019008004100036020001500077020001800092035002100110040002900131050002600160082001500186100002300201245001600224260005400240336002600294337002800320865000900348ocn898051021OCoLC20141218085132.5141211s2014 xx 000 0 eng d a1622880730 a9781622880737 a(OCoLC)898051021 aYDXCPbengcYDXCPdOCLCQ 4aPS3611.E764bQ85 201404a813/.62231 aKeriotis, Dimitri.10aQuiet time. aCollege Station :bTexas A & M Univ Press,c2014. atextbtxt2rdacontent aunmediatedbn2rdamedia aAMAZ \ No newline at end of file diff --git a/cypress/support/constants.js b/cypress/support/constants.js index bcf725b290..9b4418f029 100644 --- a/cypress/support/constants.js +++ b/cypress/support/constants.js @@ -345,6 +345,7 @@ export const VENDOR_NAMES = { GOBI: 'GOBI Library Solutions', HARRASSOWITZ: 'Otto Harrassowitz GmbH & Co. KG', EBSCO: 'EBSCO SUBSCRIPTION SERVICES', + AMAZON: 'Amazon.com', }; export const HOLDINGS_TYPE_NAMES = { diff --git a/cypress/support/fragments/orders/orderLines.js b/cypress/support/fragments/orders/orderLines.js index 5033aa1bc1..5616f07e31 100644 --- a/cypress/support/fragments/orders/orderLines.js +++ b/cypress/support/fragments/orders/orderLines.js @@ -2700,4 +2700,14 @@ export default { cy.get('input[type="checkbox"]').should('have.prop', 'checked', status); }); }, + + checkDonorInformation(donors) { + for (let i = 0; i < donors.length; i++) { + cy.expect([ + Section({ id: 'donorsInformation' }) + .find(MultiColumnListCell({ row: i, column: 'Name' })) + .has({ content: donors[i] }), + ]); + } + }, }; diff --git a/cypress/support/fragments/organizations/organizations.js b/cypress/support/fragments/organizations/organizations.js index 87b935be85..c5a8910645 100644 --- a/cypress/support/fragments/organizations/organizations.js +++ b/cypress/support/fragments/organizations/organizations.js @@ -491,6 +491,13 @@ export default { isDefaultSearchParamsRequired: false, }), + addDonorInfoViaApi: (organizationId, requestData) => cy.okapiRequest({ + method: 'PUT', + path: `organizations/organizations/${organizationId}`, + isDefaultSearchParamsRequired: false, + body: requestData, + }), + getOrganizationViaApi: (searchParams) => cy .okapiRequest({ path: 'organizations/organizations', diff --git a/cypress/support/fragments/settings/dataImport/fieldMappingProfile/newFieldMappingProfile.js b/cypress/support/fragments/settings/dataImport/fieldMappingProfile/newFieldMappingProfile.js index b5129d846a..3e52420cce 100644 --- a/cypress/support/fragments/settings/dataImport/fieldMappingProfile/newFieldMappingProfile.js +++ b/cypress/support/fragments/settings/dataImport/fieldMappingProfile/newFieldMappingProfile.js @@ -34,8 +34,10 @@ import getRandomPostfix from '../../../../utils/stringTools'; const saveButton = Button('Save as profile & Close'); const searchButton = Button('Search'); +const addDonorButton = Button('Add donor'); const organizationLookUpButton = Button('Organization look-up'); const organizationModal = Modal('Select Organization'); +const addDonorsModal = Modal('Add donors'); const staffSuppressSelect = Select('Staff suppress'); const suppressFromDiscoverySelect = Select('Suppress from discovery'); const previouslyHeldSelect = Select('Previously held'); @@ -233,15 +235,48 @@ const addLocation = (profile) => { } }; +const addDonor = (profile) => { + if (profile.donor) { + for (let i = 0; i < profile.donor.length; i++) { + if (profile.donor[i].existingStatus === true) { + cy.do(addDonorButton.click()); + cy.expect(Button('Donor look-up').exists()); + cy.do( + Button({ + id: `profile.mappingDetails.mappingFields[44].subfields.${i}.fields.0.value-plugin`, + }).click(), + ); + cy.expect(addDonorsModal.exists()); + cy.do( + addDonorsModal + .find(TextField({ id: 'input-record-search' })) + .fillIn(profile.donor[i].value), + ); + cy.wait(1000); + cy.do(addDonorsModal.find(searchButton).click()); + cy.expect(addDonorsModal.find(HTML(including('1 record found'))).exists()); + cy.do(MultiColumnListCell(profile.donor[i].value).click({ row: 0, columnIndex: 0 })); + } else { + cy.do([ + addDonorButton.click(), + TextField({ + name: `profile.mappingDetails.mappingFields[44].subfields.${i}.fields.0.value`, + }).fillIn(profile.donor[i].value), + ]); + } + } + } +}; + const addVendor = (profile) => { cy.wait(1000); cy.do([ orderInformationAccordion.find(organizationLookUpButton).click(), organizationModal.find(searchField).fillIn(profile.vendor), organizationModal.find(searchButton).click(), - organizationModal.find(HTML(including('1 record found'))).exists(), - MultiColumnListCell(profile.vendor).click({ row: 0, columnIndex: 0 }), ]); + cy.expect(organizationModal.find(HTML(including('1 record found'))).exists()); + cy.do(MultiColumnListCell(profile.vendor).click({ row: 0, columnIndex: 0 })); }; const addMaterialSupplier = (profile) => { @@ -367,6 +402,7 @@ export default { addVendorReferenceNumber, addFundDistriction, addLocation, + addDonor, addVendor, addMaterialSupplier, addAccessProvider, @@ -730,6 +766,7 @@ export default { if (profile.accessProvider) { cy.do(TextField('Access provider').fillIn(`"${profile.accessProvider}"`)); } + addDonor(profile); }, fillTextFieldInAccordion: (accordionName, fieldName, value) => {