diff --git a/cypress/e2e/data-import/importing-marc-authority-files/uploading-marc-authority-with-2-matches-in-job-profile-not-causing-any-multiple-error.cy.js b/cypress/e2e/data-import/importing-marc-authority-files/uploading-marc-authority-with-2-matches-in-job-profile-not-causing-any-multiple-error.cy.js new file mode 100644 index 0000000000..7a452614e1 --- /dev/null +++ b/cypress/e2e/data-import/importing-marc-authority-files/uploading-marc-authority-with-2-matches-in-job-profile-not-causing-any-multiple-error.cy.js @@ -0,0 +1,257 @@ +import moment from 'moment'; +import { + ACCEPTED_DATA_TYPE_NAMES, + ACTION_NAMES_IN_ACTION_PROFILE, + APPLICATION_NAMES, + DEFAULT_JOB_PROFILE_NAMES, + EXISTING_RECORD_NAMES, + FOLIO_RECORD_TYPE, + JOB_STATUS_NAMES, + RECORD_STATUSES, +} from '../../../support/constants'; +import CapabilitySets from '../../../support/dictionary/capabilitySets'; +import ExportFile from '../../../support/fragments/data-export/exportFile'; +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 JsonScreenView from '../../../support/fragments/data_import/logs/jsonScreenView'; +import Logs from '../../../support/fragments/data_import/logs/logs'; +import MarcAuthorities from '../../../support/fragments/marcAuthority/marcAuthorities'; +import MarcAuthoritiesSearch from '../../../support/fragments/marcAuthority/marcAuthoritiesSearch'; +import MarcAuthority from '../../../support/fragments/marcAuthority/marcAuthority'; +import { + ActionProfiles as SettingsActionProfiles, + FieldMappingProfiles as SettingsFieldMappingProfiles, + JobProfiles as SettingsJobProfiles, + MatchProfiles as SettingsMatchProfiles, +} from '../../../support/fragments/settings/dataImport'; +import NewFieldMappingProfile from '../../../support/fragments/settings/dataImport/fieldMappingProfile/newFieldMappingProfile'; +import NewMatchProfile from '../../../support/fragments/settings/dataImport/matchProfiles/newMatchProfile'; +import SettingsDataImport, { + SETTINGS_TABS, +} from '../../../support/fragments/settings/dataImport/settingsDataImport'; +import TopMenuNavigation from '../../../support/fragments/topMenuNavigation'; +import Users from '../../../support/fragments/users/users'; +import FileManager from '../../../support/utils/fileManager'; +import getRandomPostfix, { randomTwoDigitNumber } from '../../../support/utils/stringTools'; + +describe('Data Import', () => { + describe('Importing MARC Authority files', () => { + const testData = { + createdRecordIDs: [], + marcFile: { + // marc: 'marcAuthFileForC624306.mrc', + // fileName: `C624306 testMarcFile${getRandomPostfix()}.mrc`, + exportedFileName: `C624306 exportedTestMarcFile${getRandomPostfix()}.mrc`, + modifiedFileName: `C624306 modifiedTestMarcFile${getRandomPostfix()}.mrc`, + updatedFileName: `C624306 updatedTestMarcFile${getRandomPostfix()}.mrc`, + }, + todayDate: moment(new Date()).format('YYYYMMDD'), + partOfAuthorityTitle: 'C624306', + calloutMessage: + "is complete. The .csv downloaded contains selected records' UIIDs. To retrieve the .mrc file, please go to the Data export app.", + csvFile: `C624306_Quick_Authority_Export_${getRandomPostfix()}.csv`, + }; + const marcFiles = [ + { + fileName: 'marcAuthFileForC624306.mrc', + fileNameImported: `C624306 testMarcFile${getRandomPostfix()}.mrc`, + jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_AUTHORITY, + }, + { + fileName: 'marcAuthFileForC624306.mrc', + fileNameImported: `C624306 testMarcFile${getRandomPostfix()}.mrc`, + jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_AUTHORITY, + }, + ]; + const mappingProfile = { + name: `C624306 Updating Authority with 2 matches${getRandomPostfix()}`, + typeValue: FOLIO_RECORD_TYPE.MARCAUTHORITY, + }; + const actionProfile = { + typeValue: FOLIO_RECORD_TYPE.MARCAUTHORITY, + name: `C624306 Updating Authority with 2 matches${getRandomPostfix()}`, + action: ACTION_NAMES_IN_ACTION_PROFILE.UPDATE, + }; + const matchProfile010$aTo010$a = { + profileName: `C624306 010$a-to-010$a auth match${getRandomPostfix()}`, + incomingRecordFields: { + field: '010', + in1: '', + in2: '', + subfield: 'a', + }, + existingRecordFields: { + field: '010', + in1: '', + in2: '', + subfield: 'a', + }, + recordType: EXISTING_RECORD_NAMES.MARC_AUTHORITY, + }; + const matchProfile005To005 = { + profileName: `C624306 005-to-005 auth match${getRandomPostfix()}`, + incomingRecordFields: { + field: '005', + }, + existingRecordFields: { + field: '005', + }, + recordType: EXISTING_RECORD_NAMES.MARC_AUTHORITY, + }; + const jobProfile = { + ...NewJobProfile.defaultJobProfile, + profileName: `C624306 Update authority with 2 matches${getRandomPostfix()}`, + acceptedType: ACCEPTED_DATA_TYPE_NAMES.MARC, + }; + + before('Create test data and login', () => { + cy.getAdminToken(); + // make sure there are no duplicate authority records in the system + MarcAuthorities.deleteMarcAuthorityByTitleViaAPI(`${testData.partOfAuthorityTitle}*`); + // DataImport.uploadFileViaApi( + // testData.marcFile.marc, + // testData.marcFile.fileName, + // DEFAULT_JOB_PROFILE_NAMES.CREATE_AUTHORITY, + // ).then((response) => { + // response.forEach((record) => { + // testData.createdRecordIDs.push(record.authority.id); + // }); + // }); + marcFiles.forEach((marcFile) => { + DataImport.uploadFileViaApi( + marcFile.fileName, + marcFile.fileNameImported, + marcFile.jobProfileToRun, + ).then((response) => { + response.forEach((record) => { + testData.createdRecordIDs.push(record.authority.id); + }); + }); + }); + + cy.createTempUser().then((userProperties) => { + testData.user = userProperties; + + cy.assignCapabilitiesToExistingUser( + testData.user.userId, + [], + [ + CapabilitySets.uiDataImportSettingsManage, + CapabilitySets.uiDataImport, + CapabilitySets.uiMarcAuthoritiesAuthorityRecordView, + CapabilitySets.uiDataExportEdit, + ], + ); + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.MARC_AUTHORITY); + MarcAuthorities.waitLoading(); + }); + }); + + after('Delete test data', () => { + FileManager.deleteFile(`cypress/fixtures/${testData.marcFile.modifiedFileName}`); + FileManager.deleteFile(`cypress/fixtures/${testData.marcFile.exportedFileName}`); + cy.getAdminToken(); + SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfile.profileName); + SettingsMatchProfiles.deleteMatchProfileByNameViaApi(matchProfile010$aTo010$a.profileName); + SettingsMatchProfiles.deleteMatchProfileByNameViaApi(matchProfile005To005.profileName); + SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name); + SettingsFieldMappingProfiles.deleteMappingProfileByNameViaApi(mappingProfile.name); + Users.deleteViaApi(testData.user.userId); + testData.createdRecordIDs.forEach((id) => { + MarcAuthority.deleteViaAPI(id); + }); + }); + + it( + 'C624306 Updating MARC Authority with 2 matches in job profile not causing any multiple error (folijet)', + { tags: ['criticalPath', 'folijet', 'C624306'] }, + () => { + MarcAuthoritiesSearch.searchBy('Keyword', testData.partOfAuthorityTitle); + MarcAuthorities.selectAllRecords(); + MarcAuthorities.exportSelected(); + cy.wait(1000); + MarcAuthorities.checkCallout(testData.calloutMessage); + ExportFile.downloadCSVFile(testData.csvFile, 'QuickAuthorityExport*'); + MarcAuthorities.verifyAllCheckboxesAreUnchecked(); + + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_EXPORT); + ExportFile.uploadFile(testData.csvFile); + ExportFile.exportWithDefaultJobProfile( + testData.csvFile, + 'Default authority', + 'Authorities', + ); + ExportFile.downloadExportedMarcFile(testData.marcFile.exportedFileName); + FileManager.deleteFolder(Cypress.config('downloadsFolder')); + FileManager.deleteFile(`cypress/fixtures/${testData.csvFile}`); + + DataImport.editMarcFile( + testData.marcFile.exportedFileName, + testData.marcFile.modifiedFileName, + [testData.todayDate], + [testData.todayDate], + [`${testData.todayDate}${randomTwoDigitNumber()}`], + [`${testData.todayDate}${randomTwoDigitNumber()}`], + ); + cy.pause(); + // create Field mapping profile + NewFieldMappingProfile.createMappingProfileForUpdateMarcAuthViaApi(mappingProfile); + // create Action profile and link it to Field mapping profile + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS, APPLICATION_NAMES.DATA_IMPORT); + SettingsDataImport.selectSettingsTab(SETTINGS_TABS.ACTION_PROFILES); + SettingsActionProfiles.create(actionProfile, mappingProfile.name); + // create Match profile + NewMatchProfile.createMatchProfileWithIncomingAndExistingRecordsViaApi( + matchProfile010$aTo010$a, + ); + // create Match profile + NewMatchProfile.createMatchProfileWithIncomingAndExistingRecordsViaApi( + matchProfile005To005, + ); + + // create Job profile + SettingsDataImport.selectSettingsTab(SETTINGS_TABS.JOB_PROFILES); + JobProfiles.openNewJobProfileForm(); + NewJobProfile.fillJobProfile(jobProfile); + NewJobProfile.linkMatchProfile(matchProfile010$aTo010$a.profileName); + NewJobProfile.linkMatchAndActionProfilesForSubMatches( + matchProfile005To005.profileName, + actionProfile.name, + ); + // wait for the action profile to be linked + cy.wait(1000); + NewJobProfile.saveAndClose(); + + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_IMPORT); + DataImport.verifyUploadState(); + DataImport.uploadFileAndRetry( + testData.marcFile.modifiedFileName, + testData.marcFile.updatedFileName, + ); + JobProfiles.waitLoadingList(); + JobProfiles.search(jobProfile.profileName); + JobProfiles.runImportFile(); + Logs.waitFileIsImported(testData.marcFile.updatedFileName); + Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED); + Logs.openFileDetails(testData.marcFile.updatedFileName); + [ + FileDetails.columnNameInResultList.srsMarc, + FileDetails.columnNameInResultList.authority, + ].forEach((columnName) => { + FileDetails.checkStatusInColumn(RECORD_STATUSES.NO_ACTION, columnName); + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13].forEach((rowNumber) => { + FileDetails.checkStatusInColumn(RECORD_STATUSES.UPDATED, columnName, rowNumber); + }); + }); + FileDetails.openJsonScreenByRowAndStatus(RECORD_STATUSES.NO_ACTION); + JsonScreenView.verifyJsonScreenIsOpened(); + JsonScreenView.openMarcSrsTab(); + JsonScreenView.verifyContentInTab('No record'); + }, + ); + }); +}); diff --git a/cypress/fixtures/marcAuthFileForC624306.mrc b/cypress/fixtures/marcAuthFileForC624306.mrc new file mode 100644 index 0000000000..f1a72276d2 --- /dev/null +++ b/cypress/fixtures/marcAuthFileForC624306.mrc @@ -0,0 +1 @@ +00326cz a2200121n 4500001003700000003000300037008004100040010001700081040002500098100003600123005001700159667002800176ab14176e-d1a3-48f4-8f1d-f7eff03d744euk241030n| azannaabn |n aaa c an 2034010025 aukbengerdacukduk aC624306 Garcia, Noahd1999-202420241030171550.2 aNACO test record update00331cz a2200121n 4500001003700000003000400037008004100041010001700082040002800099100003700127005001700164667002800181a53f43bb-cf34-4441-9c5c-d814356a72f7dlc241030n| bzannaabn |n aaa c an 2034010046 adlcbengerdacdlcddlc aC624306 Miller, Lindad1901-192620241030171550.6 aNACO test record update00335cz a2200121n 4500001003700000003000400037008004100041010001700082040002800099100004100127005001700168667002800185c71bd281-4730-434c-a5b9-965391d61732agc241030n| azannaabn |n aaa c an 2034010050 aagcbengerdacagcdagc aC624306 Garcia, Elizabethd1901-192620241030171550.3 aNACO test record update00340cz a2200121n 4500001003700000003000500037008004100042010001700083040003100100100004200131005001700173667002800190c5f1c46b-0e58-4406-a1f5-cabe37e66f09dnlm241030n| azannaabn |n aaa c an 2034010053 adnlmbengerdacdnlmddnlm aC624306 Johnson, Elizabethd1999-202420241030171551.3 aNACO test record update \ No newline at end of file diff --git a/cypress/support/dictionary/capabilitySets.js b/cypress/support/dictionary/capabilitySets.js index b19169fa23..b028557468 100644 --- a/cypress/support/dictionary/capabilitySets.js +++ b/cypress/support/dictionary/capabilitySets.js @@ -52,6 +52,11 @@ export default { resource: 'UI-Inventory Settings Subject-Sources', action: CAPABILITY_ACTIONS.VIEW, }, + uiDataImportSettingsManage: { + type: CAPABILITY_TYPES.SETTINGS, + resource: 'UI-Data-Import Settings', + action: CAPABILITY_ACTIONS.MANAGE, + }, // Data capability sets capabilities: { @@ -149,6 +154,31 @@ export default { resource: 'UI-Inventory Instance Staff-Suppressed-Records', action: CAPABILITY_ACTIONS.VIEW, }, + uiDataExportEdit: { + type: CAPABILITY_TYPES.DATA, + resource: 'UI-Data-Export', + action: CAPABILITY_ACTIONS.EDIT, + }, + uiInventory: { + type: CAPABILITY_TYPES.DATA, + resource: 'UI-Inventory', + action: CAPABILITY_ACTIONS.MANAGE, + }, + uiDataImport: { + type: CAPABILITY_TYPES.DATA, + resource: 'UI-Data-Import', + action: CAPABILITY_ACTIONS.MANAGE, + }, + uiConsortiaDataImportCentralRecordUpdate: { + type: CAPABILITY_TYPES.DATA, + resource: 'Consortia Data-Import Central-Record-Update', + action: CAPABILITY_ACTIONS.MANAGE, + }, + uiMarcAuthoritiesAuthorityRecordView: { + type: CAPABILITY_TYPES.DATA, + resource: 'UI-Marc-Authorities Authority-Record', + action: CAPABILITY_ACTIONS.VIEW, + }, // Procedural capability sets uiUsersResetPassword: { diff --git a/cypress/support/fragments/data_import/logs/fileDetails.js b/cypress/support/fragments/data_import/logs/fileDetails.js index 6833505b8a..986d96b2b7 100644 --- a/cypress/support/fragments/data_import/logs/fileDetails.js +++ b/cypress/support/fragments/data_import/logs/fileDetails.js @@ -375,6 +375,23 @@ export default { ); }, + openJsonScreenByRowAndStatus: (importStatus, rowNumber = 0, columnNumber = 2) => { + cy.do( + resultsList + .find(MultiColumnListRow({ index: rowNumber })) + .find(MultiColumnListCell({ columnIndex: columnNumber, content: importStatus })) + .perform((element) => { + const rowInner = element.parentElement.getAttribute('data-row-inner'); + cy.get('#search-results-list') + .find(`div[data-row-inner="${rowInner}"]`) + .find('a') + .first() + .invoke('removeAttr', 'target') + .click(); + }), + ); + }, + filterRecordsWithError: (index) => { cy.wait(2000); cy.do(