Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAT-10271-C411791 #3099

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import NewMatchProfile from '../../../../support/fragments/settings/dataImport/m
describe('Data Import', () => {
describe('Importing MARC Bib files', () => {
const testData = {
sharedInstanceId: [],
instanceIds: [],
marcFile: {
marc: 'marcBibFileForC405531.mrc',
fileName: `C405531 testMarcFile${getRandomPostfix()}.mrc`,
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Data Import', () => {
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(testData.marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
testData.sharedInstanceId.push(link.split('/')[5]);
testData.instanceIds.push(link.split('/')[5]);
});

cy.createTempUser([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import InventoryInstance from '../../../../support/fragments/inventory/inventory
describe('Data Import', () => {
describe('Importing MARC Bib files', () => {
const testData = {
sharedInstanceId: [],
instanceIds: [],
marcFile: {
marc: 'marcBibFileForC405532.mrc',
fileName: `C405532 testMarcFile${getRandomPostfix()}.mrc`,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Data Import', () => {
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(testData.marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
testData.sharedInstanceId.push(link.split('/')[5]);
testData.instanceIds.push(link.split('/')[5]);
});
cy.logout();

Expand Down Expand Up @@ -177,7 +177,7 @@ describe('Data Import', () => {
cy.resetTenant();
cy.getAdminToken();
Users.deleteViaApi(testData.user.userId);
InventoryInstance.deleteInstanceViaApi(testData.sharedInstanceId[0]);
InventoryInstance.deleteInstanceViaApi(testData.instanceIds[0]);
SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfileName);
SettingsMatchProfiles.deleteMatchProfileByNameViaApi(matchProfile.profileName);
SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name);
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Data Import', () => {
ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.central);
cy.visit(TopMenu.inventoryPath);
InventorySearchAndFilter.verifyPanesExist();
InventoryInstances.searchByTitle(testData.sharedInstanceId[0]);
InventoryInstances.searchByTitle(testData.instanceIds[0]);
InventoryInstance.waitInstanceRecordViewOpened(testData.instanceTitle);
InventoryInstance.checkContributor(testData.contributorName, testData.contributorType);
InventoryInstance.verifyContributorAbsent(testData.absentContributorName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
import {
EXISTING_RECORDS_NAMES,
FOLIO_RECORD_TYPE,
JOB_STATUS_NAMES,
} from '../../../../support/constants';
import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations';
import Permissions from '../../../../support/dictionary/permissions';
import NewJobProfile from '../../../../support/fragments/data_import/job_profiles/newJobProfile';
import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance';
import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances';
import InventorySearchAndFilter from '../../../../support/fragments/inventory/inventorySearchAndFilter';
import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager';
import TopMenu from '../../../../support/fragments/topMenu';
import Users from '../../../../support/fragments/users/users';
import getRandomPostfix from '../../../../support/utils/stringTools';
import ExportFile from '../../../../support/fragments/data-export/exportFile';
import NewActionProfile from '../../../../support/fragments/data_import/action_profiles/newActionProfile';
import DataImport from '../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../support/fragments/data_import/logs/logs';
import NewFieldMappingProfile from '../../../../support/fragments/data_import/mapping_profiles/newFieldMappingProfile';
import FileManager from '../../../../support/utils/fileManager';
import InventoryViewSource from '../../../../support/fragments/inventory/inventoryViewSource';
import NewMatchProfile from '../../../../support/fragments/settings/dataImport/matchProfiles/newMatchProfile';
import ServicePoints from '../../../../support/fragments/settings/tenant/servicePoints/servicePoints';
import Locations from '../../../../support/fragments/settings/tenant/location-setup/locations';
import InventoryHoldings from '../../../../support/fragments/inventory/holdings/inventoryHoldings';
import {
JobProfiles as SettingsJobProfiles,
MatchProfiles as SettingsMatchProfiles,
ActionProfiles as SettingsActionProfiles,
FieldMappingProfiles as SettingsFieldMappingProfiles,
} from '../../../../support/fragments/settings/dataImport';
import NewLocation from '../../../../support/fragments/settings/tenant/locations/newLocation';

describe('Data Import', () => {
describe('Importing MARC Bib files', () => {
const testData = {
instanceIds: [],
marcFile: {
marc: 'marcBibFileForC411791.mrc',
fileName: `C411791 testMarcFile${getRandomPostfix()}.mrc`,
jobProfileToRun: 'Default - Create instance and SRS MARC Bib',
exportedFileName: `C411791 exportedTestMarcFile${getRandomPostfix()}.mrc`,
modifiedMarcFile: `C411791 modifiedTestMarcFile${getRandomPostfix()}.mrc`,
},
instanceTitle: 'C411791 Instance Shared Central',
field500Content: '$a Proceedings Updated.',
};
const mappingProfile = {
name: `C411791 Update MARC Bib records by matching 999 ff $s subfield value${getRandomPostfix()}`,
typeValue: FOLIO_RECORD_TYPE.MARCBIBLIOGRAPHIC,
};
const actionProfile = {
typeValue: FOLIO_RECORD_TYPE.MARCBIBLIOGRAPHIC,
name: `C411791 Update MARC Bib records by matching 999 ff $s subfield value${getRandomPostfix()}`,
action: 'UPDATE',
folioRecordType: 'MARC_BIBLIOGRAPHIC',
};
const matchProfile = {
profileName: `C411791 Update MARC Bib records by matching 999 ff $s subfield value${getRandomPostfix()}`,
incomingRecordFields: {
field: '999',
in1: 'f',
in2: 'f',
subfield: 's',
},
existingRecordFields: {
field: '999',
in1: 'f',
in2: 'f',
subfield: 's',
},
recordType: EXISTING_RECORDS_NAMES.MARC_BIBLIOGRAPHIC,
};
const jobProfileName = `C411791 Update MARC Bib records by matching 999 ff $s subfield value${getRandomPostfix()}`;

before('Create test data', () => {
cy.getAdminToken();
cy.loginAsAdmin({
path: TopMenu.dataImportPath,
waiter: DataImport.waitLoading,
});
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(testData.marcFile.marc, testData.marcFile.fileName);
JobProfiles.waitLoadingList();
JobProfiles.search(testData.marcFile.jobProfileToRun);
JobProfiles.runImportFile();
JobProfiles.waitFileIsImported(testData.marcFile.fileName);
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(testData.marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
testData.instanceIds.push(link.split('/')[5]);
});

cy.createTempUser([
Permissions.inventoryAll.gui,
Permissions.uiQuickMarcQuickMarcBibliographicEditorAll.gui,
])
.then((userProperties) => {
testData.user = userProperties;
})
.then(() => {
cy.assignAffiliationToUser(Affiliations.College, testData.user.userId);
cy.setTenant(Affiliations.College);
cy.assignPermissionsToExistingUser(testData.user.userId, [
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Permissions.uiQuickMarcQuickMarcBibliographicEditorAll.gui,
Permissions.dataExportEnableApp.gui,
]);
NewFieldMappingProfile.createMappingProfileForUpdateMarcBibViaApi(mappingProfile).then(
(mappingProfileResponse) => {
NewActionProfile.createActionProfileViaApiMarc(
actionProfile,
mappingProfileResponse.body.id,
).then((actionProfileResponse) => {
NewMatchProfile.createMatchProfileWithIncomingAndExistingRecordsViaApi(
matchProfile,
).then((matchProfileResponse) => {
NewJobProfile.createJobProfileWithLinkedMatchAndActionProfilesViaApi(
jobProfileName,
matchProfileResponse.body.id,
actionProfileResponse.body.id,
);
});
});
},
);

const collegeLocationData = Locations.getDefaultLocation({
servicePointId: ServicePoints.getDefaultServicePoint().id,
}).location;
Locations.createViaApi(collegeLocationData).then((location) => {
testData.collegeLocation = location;

cy.getInstance({
limit: 1,
expandAll: true,
query: `"title"=="${testData.instanceTitle}"`,
}).then((instance) => {
InventoryHoldings.createHoldingRecordViaApi({
instanceId: instance.id,
permanentLocationId: testData.collegeLocation.id,
});
});
});
cy.resetTenant();

cy.login(testData.user.username, testData.user.password, {
path: TopMenu.inventoryPath,
waiter: InventoryInstances.waitContentLoading,
});
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.central);
ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college);
});
});

after('Delete test data', () => {
cy.resetTenant();
cy.getAdminToken();
Users.deleteViaApi(testData.user.userId);
InventoryInstance.deleteInstanceViaApi(testData.instanceIds[0]);
cy.resetTenant();
cy.setTenant(Affiliations.College);
SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfileName);
SettingsMatchProfiles.deleteMatchProfileByNameViaApi(matchProfile.profileName);
SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name);
SettingsFieldMappingProfiles.deleteMappingProfileByNameViaApi(mappingProfile.name);
cy.getInstance({
limit: 1,
expandAll: true,
query: `"title"=="${testData.instanceTitle}"`,
}).then((instance) => {
cy.deleteHoldingRecordViaApi(instance.holdings[0].id);
InventoryInstance.deleteInstanceViaApi(instance.id);
});
NewLocation.deleteViaApiIncludingInstitutionCampusLibrary(
testData.collegeLocation.institutionId,
testData.collegeLocation.campusId,
testData.collegeLocation.libraryId,
testData.collegeLocation.id,
);
// delete created files in fixtures
FileManager.deleteFile(`cypress/fixtures/${testData.marcFile.exportedFileName}`);
FileManager.deleteFile(`cypress/fixtures/${testData.marcFile.modifiedMarcFile}`);
});

it(
'C411791 User without import permissions in Central tenant cannot update Shared "MARC Bib" in member tenant via Data import (consortia) (folijet)',
{ tags: ['criticalPathECS', 'folijet'] },
() => {
InventoryInstances.searchByTitle(testData.instanceTitle);
InventorySearchAndFilter.closeInstanceDetailPane();
InventorySearchAndFilter.selectResultCheckboxes(1);
InventorySearchAndFilter.verifySelectedRecords(1);
InventorySearchAndFilter.exportInstanceAsMarc();

// download exported marc file
cy.setTenant(Affiliations.College).then(() => {
// use cy.getToken function to get toket for current tenant
cy.getCollegeAdminToken();
cy.visit(TopMenu.dataExportPath);
cy.wait(2000);
ExportFile.getExportedFileNameViaApi().then((name) => {
testData.marcFile.exportedFileName = name;

ExportFile.downloadExportedMarcFile(testData.marcFile.exportedFileName);
// change exported file
DataImport.editMarcFile(
testData.marcFile.exportedFileName,
testData.marcFile.modifiedMarcFile,
['Proceedings'],
['Proceedings Updated'],
);
// upload the exported and edited marc file
cy.visit(TopMenu.dataImportPath);
// TODO delete function after fix https://issues.folio.org/browse/MODDATAIMP-691
DataImport.verifyUploadState();
DataImport.uploadExportedFile(testData.marcFile.modifiedMarcFile);
JobProfiles.waitFileIsUploaded();
JobProfiles.search(jobProfileName);
JobProfiles.runImportFile();
JobProfiles.waitFileIsImported(testData.marcFile.modifiedMarcFile);
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);

cy.visit(TopMenu.inventoryPath);
InventoryInstances.searchByTitle(testData.instanceTitle);
InventoryInstance.viewSource();
InventoryViewSource.notContains(testData.field500Content);
});
});
},
);
});
});
1 change: 1 addition & 0 deletions cypress/fixtures/marcBibFileForC411791.mrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00983nam a2200313 i 4500001001000000003000400010005001700014008004100031020002900072035002300101040003100124043001500155045001500170050002300185082001200208245003600220260003800256300002100294440007700315500001700392504004100409610004900450650005100499650004000550700002700590700002300617903000900640035002000649in5997758ICU20070123135800.0060710s2005 it 100 0 ita d a8834853903 :c15.00 EUR. a(ItFiC)it 05080533 aItFiCbengcItFiCdUtOrBLW ae-itae-vc ax0x4ax4x- 4aKKH3494b.R33 200514a34222100aC411791 Instance Shared Central aTorino :bG. Giappichelli,c2005. a128 p. ;c24 cm. 0aCollana della Facoltà di giurisprudenza.pSezione ricerca / LUMSA ;v6 aProceedings. aIncludes bibliographical references.20aRadio VaticanavCongresses.t"Vatican"utest 0aRadioxLaw and legislationzItalyvCongresses. 0aRadio in religionxCatholic Church.1 aDalla Torre, Giuseppe.1 aMirabelli, Cesare. aMARS a(OCoLC)61201287
Loading