|
| 1 | +import { |
| 2 | + APPLICATION_NAMES, |
| 3 | + DEFAULT_JOB_PROFILE_NAMES, |
| 4 | + EDIT_RESOURCE_HEADINGS, |
| 5 | +} from '../../../support/constants'; |
| 6 | +import CapabilitySets from '../../../support/dictionary/capabilitySets'; |
| 7 | +import getRandomPostfix from '../../../support/utils/stringTools'; |
| 8 | +import FileManager from '../../../support/utils/fileManager'; |
| 9 | + |
| 10 | +import DataImport from '../../../support/fragments/data_import/dataImport'; |
| 11 | +import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; |
| 12 | +import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; |
| 13 | +import InstanceRecordEdit from '../../../support/fragments/inventory/instanceRecordEdit'; |
| 14 | +import InventorySearchAndFilter from '../../../support/fragments/inventory/inventorySearchAndFilter'; |
| 15 | +import TopMenu from '../../../support/fragments/topMenu'; |
| 16 | +import TopMenuNavigation from '../../../support/fragments/topMenuNavigation'; |
| 17 | +import Users from '../../../support/fragments/users/users'; |
| 18 | + |
| 19 | +import EditResource from '../../../support/fragments/linked-data/editResource'; |
| 20 | +import InstanceProfileModal from '../../../support/fragments/linked-data/instanceProfileModal'; |
| 21 | +import Marigold from '../../../support/fragments/linked-data/marigold'; |
| 22 | +import PreviewResource from '../../../support/fragments/linked-data/previewResource'; |
| 23 | +import SearchAndFilter from '../../../support/fragments/linked-data/searchAndFilter'; |
| 24 | +import ViewMarc from '../../../support/fragments/linked-data/viewMarc'; |
| 25 | +import Work from '../../../support/fragments/linked-data/work'; |
| 26 | +import WorkProfileModal from '../../../support/fragments/linked-data/workProfileModal'; |
| 27 | + |
| 28 | +import { |
| 29 | + MARIGOLD_CAPABILITIES, |
| 30 | + MARIGOLD_CAPABILITY_SETS, |
| 31 | +} from '../../../support/dictionary/marigoldCapabilities'; |
| 32 | + |
| 33 | +let user; |
| 34 | + |
| 35 | +describe('Citation: check language MARC codes', () => { |
| 36 | + const testData = { |
| 37 | + workId: null, |
| 38 | + instanceId: null, |
| 39 | + marcFilePath: 'marcFileForC499692.mrc', |
| 40 | + modifiedMarcFile: `C499692 editedMarcFile${getRandomPostfix()}.mrc`, |
| 41 | + marcFileName: `C499692 marcFile${getRandomPostfix()}.mrc`, |
| 42 | + uniqueInventoryTitle: `Language code inventory ${getRandomPostfix()}`, |
| 43 | + uniqueMarigoldWorkTitle: `Lanuage code Marigold ${getRandomPostfix()}`, |
| 44 | + uniqueMarigoldInstanceTitle: `Lanuage code Marigold ${getRandomPostfix()}`, |
| 45 | + }; |
| 46 | + |
| 47 | + const resourceData = { |
| 48 | + inventoryTitle: testData.uniqueInventoryTitle, |
| 49 | + marigoldWorkTitle: testData.uniqueMarigoldWorkTitle, |
| 50 | + marigoldInstanceTitle: testData.uniqueMarigoldInstanceTitle, |
| 51 | + language: 'English', |
| 52 | + languageCode: 'eng', |
| 53 | + languageRel: 'Primary source language', |
| 54 | + languageLink: 'http://id.loc.gov/vocabulary/languages/eng', |
| 55 | + languageSelect: 'English (eng)', |
| 56 | + marcLanguageCode: '$a eng', |
| 57 | + marc008LangPosition: 36, |
| 58 | + languagesSubset: [ |
| 59 | + 'Akkadian (akk)', |
| 60 | + 'Bemba (bem)', |
| 61 | + 'Croatian (hrv)', |
| 62 | + 'Kanuri (kau)', |
| 63 | + 'Nepali (nep)', |
| 64 | + 'Uighur (uig)', |
| 65 | + 'Zaza (zza)', |
| 66 | + ], |
| 67 | + languageRelationships: [ |
| 68 | + 'Primary source language', |
| 69 | + 'Summary or abstract', |
| 70 | + 'Sung or spoken text', |
| 71 | + 'Librettos', |
| 72 | + 'Table of contents', |
| 73 | + 'Accompanying material other than librettos and transcripts', |
| 74 | + 'Original language', |
| 75 | + 'Intertitles', |
| 76 | + 'Subtitles', |
| 77 | + 'Intermediate translation', |
| 78 | + 'Original accompanying materials other than librettos', |
| 79 | + 'Original libretto', |
| 80 | + 'Captions', |
| 81 | + 'Accessible audio', |
| 82 | + 'Accessible visual language (non-textual)', |
| 83 | + 'Accompanying transcripts for audiovisual material', |
| 84 | + ], |
| 85 | + }; |
| 86 | + |
| 87 | + const fieldData = { |
| 88 | + languageSection: 'Language code', |
| 89 | + languageField: 'Language', |
| 90 | + languageRelField: 'Language relationship', |
| 91 | + workTitle: 'Preferred Title for Work', |
| 92 | + instanceTitle: 'Main Title', |
| 93 | + ldSource: 'LINKED_DATA', |
| 94 | + }; |
| 95 | + |
| 96 | + before('Create test data', () => { |
| 97 | + DataImport.editMarcFile( |
| 98 | + testData.marcFilePath, |
| 99 | + testData.modifiedMarcFile, |
| 100 | + ['Placeholder Title Language Code'], |
| 101 | + [testData.uniqueInventoryTitle], |
| 102 | + ); |
| 103 | + cy.getAdminToken(); |
| 104 | + |
| 105 | + cy.createTempUser([]).then((userProperties) => { |
| 106 | + user = userProperties; |
| 107 | + cy.assignCapabilitiesToExistingUser( |
| 108 | + user.userId, |
| 109 | + MARIGOLD_CAPABILITIES, |
| 110 | + [ |
| 111 | + ...MARIGOLD_CAPABILITY_SETS, |
| 112 | + CapabilitySets.uiInventoryInstanceView, |
| 113 | + CapabilitySets.uiInventoryInstanceEdit, |
| 114 | + ], |
| 115 | + ); |
| 116 | + }); |
| 117 | + |
| 118 | + DataImport.uploadFileViaApi( |
| 119 | + testData.modifiedMarcFile, |
| 120 | + testData.marcFileName, |
| 121 | + DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS, |
| 122 | + ); |
| 123 | + }); |
| 124 | + |
| 125 | + after('Delete test data', () => { |
| 126 | + FileManager.deleteFile(`cypress/fixtures/${testData.modifiedMarcFile}`); |
| 127 | + cy.getAdminToken(); |
| 128 | + InventoryInstances.deleteFullInstancesByTitleViaApi(resourceData.inventoryTitle); |
| 129 | + InventoryInstances.deleteFullInstancesByTitleViaApi(resourceData.marigoldInstanceTitle); |
| 130 | + Work.getInstancesByTitle(resourceData.inventoryTitle).then((instances) => { |
| 131 | + const filteredInstances = instances.filter( |
| 132 | + (element) => element.titles[0].value === resourceData.inventoryTitle, |
| 133 | + ); |
| 134 | + Work.deleteById(filteredInstances[0].id); |
| 135 | + }); |
| 136 | + Work.getIdByTitle(resourceData.inventoryTitle).then((id) => Work.deleteById(id)); |
| 137 | + if (testData.instanceId) Work.deleteInstanceViaApi(testData.instanceId); |
| 138 | + if (testData.workId) Work.deleteById(testData.workId); |
| 139 | + Users.deleteViaApi(user.userId); |
| 140 | + }); |
| 141 | + |
| 142 | + beforeEach(() => { |
| 143 | + cy.login(user.username, user.password, { |
| 144 | + path: TopMenu.inventoryPath, |
| 145 | + waiter: InventoryInstances.waitContentLoading, |
| 146 | + authRefresh: true, |
| 147 | + }); |
| 148 | + }); |
| 149 | + |
| 150 | + it( |
| 151 | + 'C499692 Marigold - Language Code Work / Inventory / View MARC (citation)', |
| 152 | + { tags: ['criticalPath', 'citation', 'C499692', 'marigold'] }, |
| 153 | + () => { |
| 154 | + // Edit instance from Inventory |
| 155 | + InventoryInstances.searchByTitle(resourceData.inventoryTitle); |
| 156 | + InventoryInstance.editInstanceInMG(); |
| 157 | + PreviewResource.waitLoading(); |
| 158 | + PreviewResource.clickContinue(); |
| 159 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_INSTANCE); |
| 160 | + EditResource.clickEditWork(); |
| 161 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_WORK); |
| 162 | + |
| 163 | + // Check work language fields |
| 164 | + EditResource.checkLabelOnSimpleField(resourceData.languageSelect, fieldData.languageField); |
| 165 | + EditResource.checkDropdownTextValue(resourceData.languageRel, fieldData.languageRelField); |
| 166 | + EditResource.checkSimpleFieldDropdownContainsOptions(fieldData.languageField, resourceData.languagesSubset); |
| 167 | + EditResource.checkDropdownContainsOptions(fieldData.languageRelField, resourceData.languageRelationships); |
| 168 | + |
| 169 | + // Review MARC |
| 170 | + EditResource.editInstanceFormViaActions(); |
| 171 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_INSTANCE); |
| 172 | + EditResource.viewMarc(); |
| 173 | + ViewMarc.waitLoading(); |
| 174 | + ViewMarc.checkMarcFieldContainsDataAtPosition('008', resourceData.marc008LangPosition, resourceData.languageCode); |
| 175 | + ViewMarc.checkMarcFieldIndicators('041', ' '); |
| 176 | + ViewMarc.checkMarcFieldContainsData('041', resourceData.marcLanguageCode); |
| 177 | + |
| 178 | + // Create new work and instance |
| 179 | + ViewMarc.closeMarcView(); |
| 180 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_INSTANCE); |
| 181 | + EditResource.clickCloseResourceButton(); |
| 182 | + Marigold.waitLoading(); |
| 183 | + Marigold.openNewResourceForm(); |
| 184 | + WorkProfileModal.waitLoading(); |
| 185 | + WorkProfileModal.selectDefaultOption(); |
| 186 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.NEW_WORK); |
| 187 | + EditResource.setValueForTheField(testData.uniqueMarigoldWorkTitle, fieldData.workTitle); |
| 188 | + EditResource.setValueForSectionSimpleField(resourceData.languageSelect, fieldData.languageField); |
| 189 | + // Primary source language is already the default language relationship selection |
| 190 | + EditResource.saveAndKeepEditingWithId(({ resourceId }) => { |
| 191 | + testData.workId = resourceId; |
| 192 | + }); |
| 193 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_WORK); |
| 194 | + EditResource.openNewInstanceFormViaNewInstanceButton(); |
| 195 | + InstanceProfileModal.waitLoading(); |
| 196 | + InstanceProfileModal.selectDefaultOption(); |
| 197 | + EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.NEW_INSTANCE); |
| 198 | + EditResource.setValueForTheField(testData.uniqueMarigoldInstanceTitle, fieldData.instanceTitle); |
| 199 | + EditResource.saveAndKeepEditingWithId(({ resourceId }) => { |
| 200 | + testData.instanceId = resourceId; |
| 201 | + }); |
| 202 | + EditResource.clickCloseResourceButton(); |
| 203 | + |
| 204 | + Marigold.waitLoading(); |
| 205 | + SearchAndFilter.searchResourceByTitle(resourceData.marigoldWorkTitle); |
| 206 | + SearchAndFilter.verifySearchResultField(resourceData.languageCode); |
| 207 | + SearchAndFilter.openSearchResultPreviewByTitle(resourceData.marigoldWorkTitle); |
| 208 | + SearchAndFilter.waitPreviewLoading(); |
| 209 | + EditResource.checkPreviewSectionContainsLink(fieldData.languageSection, fieldData.languageField, resourceData.language, resourceData.languageLink); |
| 210 | + |
| 211 | + // Review in inventory |
| 212 | + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY); |
| 213 | + InventorySearchAndFilter.bySource(fieldData.ldSource); |
| 214 | + InventoryInstances.searchByTitle(resourceData.marigoldInstanceTitle); |
| 215 | + InventoryInstance.editInstance(); |
| 216 | + InstanceRecordEdit.waitLoading(); |
| 217 | + InstanceRecordEdit.verifyLanguage(resourceData.language); |
| 218 | + }, |
| 219 | + ); |
| 220 | +}); |
0 commit comments