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-17281-C554639 #4632

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
@@ -0,0 +1,152 @@
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);
OrderLines.checkDonorIsAbsent('88888');
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions cypress/fixtures/marcBibFileForC554639.mrc
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
18 changes: 18 additions & 0 deletions cypress/support/fragments/orders/orderLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -2700,4 +2700,22 @@ 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] }),
);
}
},

checkDonorIsAbsent(donor) {
cy.expect(
Section({ id: 'donorsInformation' })
.find(MultiColumnListCell({ content: donor }))
.absent(),
);
},
};
7 changes: 7 additions & 0 deletions cypress/support/fragments/organizations/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -367,6 +402,7 @@ export default {
addVendorReferenceNumber,
addFundDistriction,
addLocation,
addDonor,
addVendor,
addMaterialSupplier,
addAccessProvider,
Expand Down Expand Up @@ -730,6 +766,7 @@ export default {
if (profile.accessProvider) {
cy.do(TextField('Access provider').fillIn(`"${profile.accessProvider}"`));
}
addDonor(profile);
},

fillTextFieldInAccordion: (accordionName, fieldName, value) => {
Expand Down
Loading