Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TetianaParanich committed Dec 21, 2024
1 parent 2d3cbb3 commit 5eb16f3
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ describe('Inventory', () => {
'C402335 (CONSORTIA) Verify limited Edit permissions for Shared MARC instance on Member tenant (consortia) (folijet)',
{ tags: ['criticalPathECS', 'folijet', 'C402335'] },
() => {
cy.intercept('POST', '/authn/refresh').as('/authn/refresh');
InventorySearchAndFilter.verifySearchAndFilterPane();
InventorySearchAndFilter.bySource(testData.instanceSource);
cy.wait(1500);
InventorySearchAndFilter.byShared('Yes');
cy.wait(1500);
InventorySearchAndFilter.searchInstanceByTitle(testData.instanceId);
cy.wait('@/authn/refresh', { timeout: 5000 });
InventorySearchAndFilter.verifyInstanceDetailsView();
InstanceRecordView.verifyInstanceSource(testData.instanceSource);
InstanceRecordView.verifyEditInstanceButtonAbsent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Data Import', () => {
Permissions.moduleDataImportEnabled.gui,
Permissions.settingsDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Permissions.uiInventorySingleRecordImport,
Permissions.uiInventorySingleRecordImport.gui,
Permissions.uiQuickMarcQuickMarcBibliographicEditorView.gui,
]).then((userProperties) => {
user = userProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ describe('Data Import', () => {
FileDetails.checkItemQuantityInSummaryTable(quantityOfItems, 1);

TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY);
ItemRecordView.closeDetailView();
InventorySearchAndFilter.searchInstanceByHRID(initialInstanceHrId);
InventoryInstance.openHoldingView();
HoldingsRecordView.checkTemporaryLocation('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ describe('Data Import', () => {
FileDetails.checkHoldingsQuantityInSummaryTable(quantityOfItems, 1);

TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY);
InventorySearchAndFilter.selectYesfilterStaffSuppress();
InventorySearchAndFilter.searchInstanceByHRID(instanceHrid);
InstanceRecordView.openHoldingView();
HoldingsRecordView.checkFormerHoldingsId(
holdingsMappingProfileForUpdate.formerHoldingsId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Data Import', () => {
]).then((userProperties) => {
user = userProperties;

for (let i = 0; i < 27; i++) {
for (let i = 0; i < 2; i++) {
const fileName = `C353589 autotestFileName${getRandomPostfix()}.mrc`;

DataImport.uploadFileViaApi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import NewJobProfile from '../../../support/fragments/data_import/job_profiles/n
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 InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
import OrderLines from '../../../support/fragments/orders/orderLines';
import {
ActionProfiles as SettingsActionProfiles,
Expand All @@ -36,7 +35,6 @@ import getRandomPostfix from '../../../support/utils/stringTools';
describe('Data Import', () => {
describe('Permissions', () => {
let user;
let instanceId;
const filePath = 'marcBibFileForC377023.mrc';
const marcFileName = `C377023 autotestFileName${getRandomPostfix()}.mrc`;
const title = 'ROALD DAHL : TELLER OF THE UNEXPECTED : A BIOGRAPHY.';
Expand Down Expand Up @@ -135,7 +133,6 @@ describe('Data Import', () => {
SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfile.profileName);
SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name);
SettingsFieldMappingProfiles.deleteMappingProfileByNameViaApi(mappingProfile.name);
InventoryInstance.deleteInstanceViaApi(instanceId);
});
});

Expand All @@ -151,7 +148,6 @@ describe('Data Import', () => {
JsonScreenView.openOrderTab();
JsonScreenView.verifyContentInTab(message);
TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_IMPORT);
FileDetails.close();
Logs.openFileDetails(marcFileName);
FileDetails.openOrder(RECORD_STATUSES.CREATED);
OrderLines.waitLoading();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe('Inventory', () => {
`Record ${oclcRecordData.oclc} updated. Results may take a few moments to become visible in Inventory`,
);
cy.wait(15000);
cy.reload();
InventoryInstance.waitInstanceRecordViewOpened(oclcRecordData.title);
InventoryInstance.verifyLastUpdatedDate();
InstanceRecordView.verifyInstanceSource(INSTANCE_SOURCE_NAMES.MARC);
Expand All @@ -91,9 +90,12 @@ describe('Inventory', () => {
date: oclcRecordData.publicationDate,
});
InventoryInstance.verifyInstancePhysicalcyDescription(oclcRecordData.physicalDescription);
InventoryInstance.openIdentifiersAccordion();
InventoryInstance.verifyResourceIdentifier('ISBN', oclcRecordData.isbn1, 6);
InventoryInstance.verifyResourceIdentifier('ISBN', oclcRecordData.isbn2, 7);
InventoryInstance.openSubjectAccordion();
InventoryInstance.verifyInstanceSubject(0, 0, oclcRecordData.subject);
InventoryInstance.openInstanceNotesAccordion();
InventoryInstance.checkInstanceNotes(
oclcRecordData.notes.noteType,
oclcRecordData.notes.noteContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,13 @@ describe('Data Import', () => {
cy.wait(2000);
JobProfileView.duplicate();
NewJobProfile.fillProfileName(jobProfileNameForChanging);
cy.wait(7000);
cy.wait(3000);
NewJobProfile.unlinkProfile(1);
cy.wait(3000);
NewJobProfile.saveAndClose();
JobProfileView.verifyCalloutMessage(calloutMessage);
JobProfileView.verifyJobProfileOpened();
cy.wait(7000);
JobProfileView.verifyJobProfileName(jobProfileNameForChanging);
JobProfileView.verifyLinkedProfiles(linkedProfileNames, linkedProfileNames.length);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {

selectJobProfile: () => {
// need to wait until file upload
cy.wait(1000);
cy.wait(1500);
cy.expect(paneResults.find(MultiColumnListRow({ index: 0 })).exists());
cy.do(paneResults.find(MultiColumnListRow({ index: 0 })).click());
cy.expect(waitSelector.exists());
Expand Down
1 change: 1 addition & 0 deletions cypress/support/fragments/inventory/inventoryInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export default {
},

openSubjectAccordion: () => cy.do(subjectAccordion.clickHeader()),
openIdentifiersAccordion: () => cy.do(identifiersAccordion.clickHeader()),
openInstanceNotesAccordion: () => cy.do(Button({ id: 'accordion-toggle-button-instance-details-notes' }).click()),
checkAuthorityAppIconInSection: (sectionId, value, isPresent) => {
if (isPresent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ export default {
cells.push(cellValue);
});
})
.then(() => cy.expect(ArrayUtils.checkIsSortedAlphabetically({ array: cells })).to.equal(true));
.then(() => {
const isSorted = ArrayUtils.checkIsSortedAlphabetically({ array: cells });
cy.expect(isSorted).to.equal(true);
});
},
...ResultsPane,
clickCreateNewFieldMappingProfile() {
Expand Down
30 changes: 19 additions & 11 deletions cypress/support/utils/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,27 @@ export default {
},

checkIsSortedAlphabetically({ array = [], accuracy = 1 } = {}) {
const result = array.reduce((acc, it) => {
if (acc.length) {
const prev = acc[acc.length - 1].value;
const current = it.toLowerCase();

return [...acc, { value: current, order: prev.localeCompare(current) }];
} else {
return [{ value: it.toLowerCase(), order: 0 }];
if (array.length === 0) return true;

let outOfOrderCount = 0;

for (let i = 1; i < array.length; i++) {
// Normalize strings for comparison: replace hyphens with spaces and trim
const prev = array[i - 1].trim().toLowerCase().replace(/-/g, ' ').replace(/\s+/g, ' ');
const current = array[i].trim().toLowerCase().replace(/-/g, ' ').replace(/\s+/g, ' ');

// Compare adjacent elements
if (prev.localeCompare(current) > 0) {
outOfOrderCount++;

// Early exit if the accuracy threshold is exceeded
if ((outOfOrderCount * 100) / array.length >= accuracy) {
return false;
}
}
}, []);
}

const invalidOrder = result.filter(({ order }) => order > 0);
return (invalidOrder.length * 100) / array.length < accuracy;
return true;
},
};

Expand Down

0 comments on commit 5eb16f3

Please sign in to comment.