From eeb1bfd257d9f938faef6f15d9879c145ee56bd1 Mon Sep 17 00:00:00 2001 From: Tetiana Paranich <89065577+TetianaParanich@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:31:04 +0200 Subject: [PATCH 1/2] Fat 17760 (#4575) * fixed tests * fixed linter issue * fixed tests * added waits --- ...central-via-DI-and-confirm-in-member.cy.js | 1 + ...DI-and-confirm-in-central-and-member.cy.js | 1 + ...s-for-shared-marc-instance-on-member.cy.js | 1 - ...g-on-newly-created-035-does-not-work.cy.js | 2 +- .../test-remove-field-mapping-option.cy.js | 1 + ...e-holdings-via-static-value-submatch.cy.js | 3 -- ...e-change-from-load-more-to-paginated.cy.js | 2 +- ...iles-import-and-view-logs-permission.cy.js | 4 --- .../import-by-oclc-source-folio.cy.js | 4 ++- ...epeatable-profiles-after-duplicating.cy.js | 4 ++- .../data_import/job_profiles/jobProfiles.js | 2 +- .../fragments/inventory/inventoryInstance.js | 1 + .../fieldMappingProfiles.js | 5 +++- cypress/support/utils/arrays.js | 30 ++++++++++++------- 14 files changed, 36 insertions(+), 25 deletions(-) diff --git a/cypress/e2e/consortia/data-import/importing-marcBib-files/adding-deleting-fields-and-subfields-when-updating-shared-marcBib-in-central-via-DI-and-confirm-in-member.cy.js b/cypress/e2e/consortia/data-import/importing-marcBib-files/adding-deleting-fields-and-subfields-when-updating-shared-marcBib-in-central-via-DI-and-confirm-in-member.cy.js index f4c745e443..15b3fa76be 100644 --- a/cypress/e2e/consortia/data-import/importing-marcBib-files/adding-deleting-fields-and-subfields-when-updating-shared-marcBib-in-central-via-DI-and-confirm-in-member.cy.js +++ b/cypress/e2e/consortia/data-import/importing-marcBib-files/adding-deleting-fields-and-subfields-when-updating-shared-marcBib-in-central-via-DI-and-confirm-in-member.cy.js @@ -183,6 +183,7 @@ describe('Data Import', () => { // download exported marc file TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_EXPORT); + ExportFile.waitLandingPageOpened(); cy.wait(5000); ExportFile.downloadExportedMarcFileWithRecordHrid( expectedRecordHrid, diff --git a/cypress/e2e/consortia/data-import/importing-marcBib-files/update-shared-marcBib-in-member-via-DI-and-confirm-in-central-and-member.cy.js b/cypress/e2e/consortia/data-import/importing-marcBib-files/update-shared-marcBib-in-member-via-DI-and-confirm-in-central-and-member.cy.js index 0fa845d1b4..6415e3fa7d 100644 --- a/cypress/e2e/consortia/data-import/importing-marcBib-files/update-shared-marcBib-in-member-via-DI-and-confirm-in-central-and-member.cy.js +++ b/cypress/e2e/consortia/data-import/importing-marcBib-files/update-shared-marcBib-in-member-via-DI-and-confirm-in-central-and-member.cy.js @@ -187,6 +187,7 @@ describe('Data Import', () => { cy.setTenant(Affiliations.College).then(() => { TopMenuNavigation.navigateToApp(APPLICATION_NAMES.DATA_EXPORT); ExportFile.waitLandingPageOpened(); + cy.wait(5000); ExportFile.downloadExportedMarcFileWithRecordHrid( expectedRecordHrid, testData.marcFile.exportedFileName, diff --git a/cypress/e2e/consortia/inventory/instance/limited-edit-permissions-for-shared-marc-instance-on-member.cy.js b/cypress/e2e/consortia/inventory/instance/limited-edit-permissions-for-shared-marc-instance-on-member.cy.js index 49c12051a8..59dfadd523 100644 --- a/cypress/e2e/consortia/inventory/instance/limited-edit-permissions-for-shared-marc-instance-on-member.cy.js +++ b/cypress/e2e/consortia/inventory/instance/limited-edit-permissions-for-shared-marc-instance-on-member.cy.js @@ -67,7 +67,6 @@ describe('Inventory', () => { InventorySearchAndFilter.byShared('Yes'); cy.wait(1500); InventorySearchAndFilter.searchInstanceByTitle(testData.instanceId); - cy.wait('@/authn/refresh', { timeout: 5000 }); InventorySearchAndFilter.verifyInstanceDetailsView(); InstanceRecordView.verifyInstanceSource(testData.instanceSource); InstanceRecordView.verifyEditInstanceButtonAbsent(); diff --git a/cypress/e2e/data-import/importing-marc-bib-files/matching-on-newly-created-035-does-not-work.cy.js b/cypress/e2e/data-import/importing-marc-bib-files/matching-on-newly-created-035-does-not-work.cy.js index 89bdb611b0..01cef62829 100644 --- a/cypress/e2e/data-import/importing-marc-bib-files/matching-on-newly-created-035-does-not-work.cy.js +++ b/cypress/e2e/data-import/importing-marc-bib-files/matching-on-newly-created-035-does-not-work.cy.js @@ -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; diff --git a/cypress/e2e/data-import/importing-marc-bib-files/test-remove-field-mapping-option.cy.js b/cypress/e2e/data-import/importing-marc-bib-files/test-remove-field-mapping-option.cy.js index 9a52bbd5f6..6d460d6cc9 100644 --- a/cypress/e2e/data-import/importing-marc-bib-files/test-remove-field-mapping-option.cy.js +++ b/cypress/e2e/data-import/importing-marc-bib-files/test-remove-field-mapping-option.cy.js @@ -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('-'); diff --git a/cypress/e2e/data-import/importing-marc-bib-files/update-holdings-via-static-value-submatch.cy.js b/cypress/e2e/data-import/importing-marc-bib-files/update-holdings-via-static-value-submatch.cy.js index 1c66a37762..42793b2b1b 100644 --- a/cypress/e2e/data-import/importing-marc-bib-files/update-holdings-via-static-value-submatch.cy.js +++ b/cypress/e2e/data-import/importing-marc-bib-files/update-holdings-via-static-value-submatch.cy.js @@ -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, ); diff --git a/cypress/e2e/data-import/log-details/view-all-page-change-from-load-more-to-paginated.cy.js b/cypress/e2e/data-import/log-details/view-all-page-change-from-load-more-to-paginated.cy.js index 0f26ff6e3a..3cf91a4dd3 100644 --- a/cypress/e2e/data-import/log-details/view-all-page-change-from-load-more-to-paginated.cy.js +++ b/cypress/e2e/data-import/log-details/view-all-page-change-from-load-more-to-paginated.cy.js @@ -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( diff --git a/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js b/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js index 6808e58749..ecb56e7eeb 100644 --- a/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js +++ b/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js @@ -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, @@ -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.'; @@ -135,7 +133,6 @@ describe('Data Import', () => { SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfile.profileName); SettingsActionProfiles.deleteActionProfileByNameViaApi(actionProfile.name); SettingsFieldMappingProfiles.deleteMappingProfileByNameViaApi(mappingProfile.name); - InventoryInstance.deleteInstanceViaApi(instanceId); }); }); @@ -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(); diff --git a/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js b/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js index 2873099caa..67fa408718 100644 --- a/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js +++ b/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js @@ -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); @@ -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, diff --git a/cypress/e2e/settings/data-import/no-duplicates-profiles-appears-in-job-profile-with-repeatable-profiles-after-duplicating.cy.js b/cypress/e2e/settings/data-import/no-duplicates-profiles-appears-in-job-profile-with-repeatable-profiles-after-duplicating.cy.js index 30231465dc..0a2258f4d7 100644 --- a/cypress/e2e/settings/data-import/no-duplicates-profiles-appears-in-job-profile-with-repeatable-profiles-after-duplicating.cy.js +++ b/cypress/e2e/settings/data-import/no-duplicates-profiles-appears-in-job-profile-with-repeatable-profiles-after-duplicating.cy.js @@ -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); }, diff --git a/cypress/support/fragments/data_import/job_profiles/jobProfiles.js b/cypress/support/fragments/data_import/job_profiles/jobProfiles.js index 7da43a6a12..a717312ec5 100644 --- a/cypress/support/fragments/data_import/job_profiles/jobProfiles.js +++ b/cypress/support/fragments/data_import/job_profiles/jobProfiles.js @@ -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()); diff --git a/cypress/support/fragments/inventory/inventoryInstance.js b/cypress/support/fragments/inventory/inventoryInstance.js index d126a27178..746eda2eae 100644 --- a/cypress/support/fragments/inventory/inventoryInstance.js +++ b/cypress/support/fragments/inventory/inventoryInstance.js @@ -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) { diff --git a/cypress/support/fragments/settings/dataImport/fieldMappingProfile/fieldMappingProfiles.js b/cypress/support/fragments/settings/dataImport/fieldMappingProfile/fieldMappingProfiles.js index 6fbffbbe22..cba01464b9 100644 --- a/cypress/support/fragments/settings/dataImport/fieldMappingProfile/fieldMappingProfiles.js +++ b/cypress/support/fragments/settings/dataImport/fieldMappingProfile/fieldMappingProfiles.js @@ -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() { diff --git a/cypress/support/utils/arrays.js b/cypress/support/utils/arrays.js index 088aa6b4ae..1a9aee236c 100644 --- a/cypress/support/utils/arrays.js +++ b/cypress/support/utils/arrays.js @@ -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; }, }; From 939421e2e6c4b374ea91906ff1974c0f495f70af Mon Sep 17 00:00:00 2001 From: sviatlana-stsiapanava Date: Mon, 23 Dec 2024 14:49:13 +0500 Subject: [PATCH 2/2] Update the button name --- cypress/support/fragments/lists/lists.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/fragments/lists/lists.js b/cypress/support/fragments/lists/lists.js index 393acb6ce9..925b0e56c5 100644 --- a/cypress/support/fragments/lists/lists.js +++ b/cypress/support/fragments/lists/lists.js @@ -36,7 +36,7 @@ const editList = Button('Edit list'); const duplicateList = Button('Duplicate list'); const deleteList = Button('Delete list'); const exportList = Button('Export all columns (CSV)'); -const exportListVisibleColumns = Button('Export visible columns (CSV)'); +const exportListVisibleColumns = Button('Export selected columns (CSV)'); const testQuery = Button('Test query'); const runQueryAndSave = Button('Run query & save'); const filterPane = Pane('Filter');