|
| 1 | +import { DEFAULT_JOB_PROFILE_NAMES } from '../../../support/constants'; |
| 2 | +import { Permissions } from '../../../support/dictionary'; |
| 3 | +import DataImport from '../../../support/fragments/data_import/dataImport'; |
| 4 | +import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView'; |
| 5 | +import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; |
| 6 | +import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; |
| 7 | +import TopMenu from '../../../support/fragments/topMenu'; |
| 8 | +import Users from '../../../support/fragments/users/users'; |
| 9 | +import { randomFourDigitNumber } from '../../../support/utils/stringTools'; |
| 10 | + |
| 11 | +describe('Data Import', () => { |
| 12 | + describe('Importing MARC Bib files', () => { |
| 13 | + const testData = { |
| 14 | + marcFile: { |
| 15 | + marc: 'marcBibFileForC380724.mrc', |
| 16 | + fileName: `testMarcFileC380724.${randomFourDigitNumber()}.mrc`, |
| 17 | + jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS, |
| 18 | + }, |
| 19 | + record1Classifications: [ |
| 20 | + { classificationIdentifierType: 'LC', classification: 'Z3807.M24 G38 0724' }, |
| 21 | + { classificationIdentifierType: 'LC', classification: 'TA3807.C24' }, |
| 22 | + { classificationIdentifierType: 'NLM', classification: 'W1 NE3807 v.24' }, |
| 23 | + { classificationIdentifierType: 'NLM', classification: 'QU 38 S724' }, |
| 24 | + { classificationIdentifierType: 'Dewey', classification: '380.724 HEA' }, |
| 25 | + { classificationIdentifierType: 'Dewey', classification: '380.7240' }, |
| 26 | + { classificationIdentifierType: 'GDC', classification: 'A 3.8/0:724' }, |
| 27 | + { classificationIdentifierType: 'GDC', classification: 'A 3.8/7:240' }, |
| 28 | + { classificationIdentifierType: 'GDC', classification: 'A 3.8:' }, |
| 29 | + { classificationIdentifierType: 'LC', classification: 'TA3807.C2' }, |
| 30 | + { classificationIdentifierType: 'LC', classification: 'Z3807.M24 G07 2438' }, |
| 31 | + ], |
| 32 | + record2Classifications: [ |
| 33 | + { classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000a' }, |
| 34 | + { classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000b' }, |
| 35 | + { classificationIdentifierType: 'NLM', classification: 'W1 ME3807 v.24 3807' }, |
| 36 | + { classificationIdentifierType: 'NLM', classification: 'QH 38.07 C724 3807' }, |
| 37 | + { classificationIdentifierType: 'UDC', classification: '380.724 B07' }, |
| 38 | + { classificationIdentifierType: 'UDC', classification: '307.248 B38' }, |
| 39 | + { classificationIdentifierType: 'Dewey', classification: '380.724 HEA' }, |
| 40 | + { classificationIdentifierType: 'Dewey', classification: '307.248 HEA' }, |
| 41 | + { classificationIdentifierType: 'GDC', classification: 'D 38.07:M 24' }, |
| 42 | + { classificationIdentifierType: 'GDC', classification: 'Y 3.AT 7:24 M 38/' }, |
| 43 | + { classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000c' }, |
| 44 | + { classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000d' }, |
| 45 | + ], |
| 46 | + }; |
| 47 | + |
| 48 | + let instanceId1; |
| 49 | + let instanceId2; |
| 50 | + let user; |
| 51 | + |
| 52 | + before('Create user and import test data', () => { |
| 53 | + cy.getAdminToken(); |
| 54 | + DataImport.uploadFileViaApi( |
| 55 | + testData.marcFile.marc, |
| 56 | + testData.marcFile.fileName, |
| 57 | + testData.marcFile.jobProfileToRun, |
| 58 | + ).then((response) => { |
| 59 | + instanceId1 = response[0].instance.id; |
| 60 | + instanceId2 = response[1].instance.id; |
| 61 | + }); |
| 62 | + |
| 63 | + cy.createTempUser([Permissions.inventoryAll.gui]).then((userProperties) => { |
| 64 | + user = userProperties; |
| 65 | + |
| 66 | + cy.login(user.username, user.password, { |
| 67 | + path: TopMenu.inventoryPath, |
| 68 | + waiter: InventoryInstances.waitContentLoading, |
| 69 | + }); |
| 70 | + }); |
| 71 | + }); |
| 72 | + |
| 73 | + after('Delete test data', () => { |
| 74 | + cy.getAdminToken(); |
| 75 | + InventoryInstance.deleteInstanceViaApi(instanceId1); |
| 76 | + InventoryInstance.deleteInstanceViaApi(instanceId2); |
| 77 | + Users.deleteViaApi(user.userId); |
| 78 | + }); |
| 79 | + |
| 80 | + it( |
| 81 | + 'C380724 Check the default mapping of Classification from the MARC record to the Inventory Instance Classification fields: Case 2 (folijet)', |
| 82 | + { tags: ['extendedPath', 'folijet', 'C380724'] }, |
| 83 | + () => { |
| 84 | + // Steps 1-4: Import done via API; open first record |
| 85 | + InventoryInstances.searchByTitle(instanceId1); |
| 86 | + InventoryInstances.selectInstanceById(instanceId1); |
| 87 | + InstanceRecordView.waitLoading(); |
| 88 | + |
| 89 | + // Steps 5-9: Verify record 1 classifications (050, 060, 082, 086, 090 with repeatable subfields) |
| 90 | + testData.record1Classifications.forEach( |
| 91 | + ({ classificationIdentifierType, classification }) => { |
| 92 | + InstanceRecordView.verifyClassification(classificationIdentifierType, classification); |
| 93 | + }, |
| 94 | + ); |
| 95 | + |
| 96 | + // Steps 10-16: Open second record; verify classifications (repeatable MARC fields) |
| 97 | + InventoryInstances.searchByTitle(instanceId2); |
| 98 | + InventoryInstances.selectInstanceById(instanceId2); |
| 99 | + InstanceRecordView.waitLoading(); |
| 100 | + testData.record2Classifications.forEach( |
| 101 | + ({ classificationIdentifierType, classification }) => { |
| 102 | + InstanceRecordView.verifyClassification(classificationIdentifierType, classification); |
| 103 | + }, |
| 104 | + ); |
| 105 | + }, |
| 106 | + ); |
| 107 | + }); |
| 108 | +}); |
0 commit comments