|
| 1 | +import { |
| 2 | + DEFAULT_JOB_PROFILE_NAMES, |
| 3 | + MARC_AUTHORITY_SEARCH_OPTIONS, |
| 4 | + REFERENCES_FILTER_CHECKBOXES, |
| 5 | +} from '../../../../support/constants'; |
| 6 | +import { Permissions } from '../../../../support/dictionary'; |
| 7 | +import DataImport from '../../../../support/fragments/data_import/dataImport'; |
| 8 | +import MarcAuthorityBrowse from '../../../../support/fragments/marcAuthority/MarcAuthorityBrowse'; |
| 9 | +import MarcAuthorities from '../../../../support/fragments/marcAuthority/marcAuthorities'; |
| 10 | +import MarcAuthoritiesSearch from '../../../../support/fragments/marcAuthority/marcAuthoritiesSearch'; |
| 11 | +import MarcAuthority from '../../../../support/fragments/marcAuthority/marcAuthority'; |
| 12 | +import TopMenu from '../../../../support/fragments/topMenu'; |
| 13 | +import Users from '../../../../support/fragments/users/users'; |
| 14 | +import getRandomPostfix from '../../../../support/utils/stringTools'; |
| 15 | + |
| 16 | +describe('MARC', () => { |
| 17 | + describe('MARC Authority', () => { |
| 18 | + describe('Browse - Authority records', () => { |
| 19 | + const testData = { |
| 20 | + advancedSearchOption: MARC_AUTHORITY_SEARCH_OPTIONS.ADVANCED_SEARCH, |
| 21 | + searchQueries: { |
| 22 | + first: |
| 23 | + 'identifiers.value containsAll n00063831 or identifiers.value containsAll n91028048', |
| 24 | + second: |
| 25 | + 'geographicName containsAll Cooperstown (N.D.) and keyword containsAll Cooperstown', |
| 26 | + }, |
| 27 | + browseQuery: 'C386498 R', |
| 28 | + browseOption: 'Personal name', |
| 29 | + filters: { |
| 30 | + authoritySource: 'LC Name Authority file (LCNAF)', |
| 31 | + excludeSeeFrom: REFERENCES_FILTER_CHECKBOXES.EXCLUDE_SEE_FROM, |
| 32 | + }, |
| 33 | + expectedResults: { |
| 34 | + firstQuery: ['C386498 Phillips, Bob, 1951-', 'C386498 Santritter, Joannes Lucilius'], |
| 35 | + secondQuery: 'C386498 Cooperstown (N.D.)', |
| 36 | + }, |
| 37 | + authorizedType: 'Authorized', |
| 38 | + marcFile: { |
| 39 | + marc: 'C386498MarcAuth.mrc', |
| 40 | + fileName: `testMarcFile386498.${getRandomPostfix()}.mrc`, |
| 41 | + jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_AUTHORITY, |
| 42 | + numberOfRecords: 100, |
| 43 | + }, |
| 44 | + createdAuthorityIDs: [], |
| 45 | + }; |
| 46 | + |
| 47 | + before('Create test data', () => { |
| 48 | + cy.getAdminToken(); |
| 49 | + MarcAuthorities.getMarcAuthoritiesViaApi({ |
| 50 | + limit: 100, |
| 51 | + query: 'keyword="C386498*"', |
| 52 | + }).then((authorities) => { |
| 53 | + if (authorities) { |
| 54 | + authorities.forEach(({ id }) => { |
| 55 | + MarcAuthority.deleteViaAPI(id); |
| 56 | + }); |
| 57 | + } |
| 58 | + }); |
| 59 | + |
| 60 | + cy.createTempUser([Permissions.uiMarcAuthoritiesAuthorityRecordView.gui]).then( |
| 61 | + (createdUserProperties) => { |
| 62 | + testData.userProperties = createdUserProperties; |
| 63 | + |
| 64 | + DataImport.uploadFileViaApi( |
| 65 | + testData.marcFile.marc, |
| 66 | + testData.marcFile.fileName, |
| 67 | + testData.marcFile.jobProfileToRun, |
| 68 | + ).then((response) => { |
| 69 | + response.forEach((record) => { |
| 70 | + testData.createdAuthorityIDs.push(record.authority.id); |
| 71 | + }); |
| 72 | + }); |
| 73 | + |
| 74 | + cy.login(testData.userProperties.username, testData.userProperties.password, { |
| 75 | + path: TopMenu.marcAuthorities, |
| 76 | + waiter: MarcAuthorities.waitLoading, |
| 77 | + }); |
| 78 | + }, |
| 79 | + ); |
| 80 | + }); |
| 81 | + |
| 82 | + after('Delete test data', () => { |
| 83 | + cy.getAdminToken(); |
| 84 | + Users.deleteViaApi(testData.userProperties.userId); |
| 85 | + testData.createdAuthorityIDs.forEach((id) => { |
| 86 | + MarcAuthority.deleteViaAPI(id, true); |
| 87 | + }); |
| 88 | + }); |
| 89 | + |
| 90 | + // KNOWN ISSUE: Steps 5 fail due to UIMARCAUTH-532 |
| 91 | + it.skip( |
| 92 | + 'C386498 Switching between Search and Browse in "MARC authority" app (advanced search) (spitfire)', |
| 93 | + { tags: ['extendedPathBroken', 'spitfire', 'C386498'] }, |
| 94 | + () => { |
| 95 | + // Step 1: Select "Advanced search" option, fill query and apply filters |
| 96 | + MarcAuthorities.selectSearchOptionInDropdown(testData.advancedSearchOption); |
| 97 | + MarcAuthorities.checkSelectOptionFieldContent(testData.advancedSearchOption); |
| 98 | + MarcAuthoritiesSearch.fillSearchInput(testData.searchQueries.first); |
| 99 | + MarcAuthorities.chooseAuthoritySourceOption(testData.filters.authoritySource); |
| 100 | + MarcAuthoritiesSearch.selectExcludeReferencesFilter(testData.filters.excludeSeeFrom); |
| 101 | + |
| 102 | + // Step 2: Click "Search" and verify results |
| 103 | + MarcAuthoritiesSearch.clickSearchButton(); |
| 104 | + testData.expectedResults.firstQuery.forEach((heading) => { |
| 105 | + MarcAuthorities.checkAfterSearch(testData.authorizedType, heading); |
| 106 | + }); |
| 107 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 108 | + |
| 109 | + // Step 3: Switch to Browse |
| 110 | + MarcAuthorities.switchToBrowse(); |
| 111 | + MarcAuthorities.verifyBrowseTabIsOpened(); |
| 112 | + |
| 113 | + // Step 4: Fill browse query and search |
| 114 | + MarcAuthorityBrowse.searchBy(testData.browseOption, testData.browseQuery); |
| 115 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 116 | + |
| 117 | + // Step 5: Switch to Search - verify state is same as Step 2 |
| 118 | + MarcAuthorities.switchToSearch(); |
| 119 | + MarcAuthorities.verifySearchTabIsOpened(); |
| 120 | + MarcAuthorities.checkSelectOptionFieldContent(testData.advancedSearchOption); |
| 121 | + MarcAuthorities.checkSearchInput(testData.searchQueries.first); |
| 122 | + testData.expectedResults.firstQuery.forEach((heading) => { |
| 123 | + MarcAuthorities.checkAfterSearch(testData.authorizedType, heading); |
| 124 | + }); |
| 125 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 126 | + |
| 127 | + // Step 6: Update search query with another value |
| 128 | + MarcAuthoritiesSearch.fillSearchInput(testData.searchQueries.second); |
| 129 | + |
| 130 | + // Step 7: Click "Search" and verify single result with detail view |
| 131 | + MarcAuthoritiesSearch.clickSearchButton(); |
| 132 | + MarcAuthorities.checkAfterSearch( |
| 133 | + testData.authorizedType, |
| 134 | + testData.expectedResults.secondQuery, |
| 135 | + ); |
| 136 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 137 | + |
| 138 | + // Step 8: Switch to Browse - verify browse results still from Step 4 |
| 139 | + MarcAuthorities.switchToBrowse(); |
| 140 | + MarcAuthorities.verifyBrowseTabIsOpened(); |
| 141 | + MarcAuthorities.checkSearchInput(testData.browseQuery); |
| 142 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 143 | + |
| 144 | + // Step 9: Switch to Search - verify state same as Step 7 |
| 145 | + MarcAuthorities.switchToSearch(); |
| 146 | + MarcAuthorities.verifySearchTabIsOpened(); |
| 147 | + MarcAuthorities.checkSelectOptionFieldContent(testData.advancedSearchOption); |
| 148 | + MarcAuthorities.checkSearchInput(testData.searchQueries.second); |
| 149 | + MarcAuthorities.checkAfterSearch( |
| 150 | + testData.authorizedType, |
| 151 | + testData.expectedResults.secondQuery, |
| 152 | + ); |
| 153 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 154 | + |
| 155 | + // Step 10: Click "Reset all" - verify Search is cleared |
| 156 | + MarcAuthorities.clickResetAndCheck(); |
| 157 | + |
| 158 | + // Step 11: Switch to Browse - verify browse results still displayed (not affected by reset) |
| 159 | + MarcAuthorities.switchToBrowse(); |
| 160 | + MarcAuthorities.verifyBrowseTabIsOpened(); |
| 161 | + MarcAuthorities.checkSearchInput(testData.browseQuery); |
| 162 | + MarcAuthorities.verifySearchResultTabletIsAbsent(false); |
| 163 | + |
| 164 | + // Step 12: Switch to Search - verify search state is still cleared |
| 165 | + MarcAuthorities.switchToSearch(); |
| 166 | + MarcAuthorities.verifySearchTabIsOpened(); |
| 167 | + MarcAuthorities.checkSearchOption('keyword'); |
| 168 | + MarcAuthorities.checkSearchInput(''); |
| 169 | + MarcAuthorities.verifySearchResultTabletIsAbsent(true); |
| 170 | + }, |
| 171 | + ); |
| 172 | + }); |
| 173 | + }); |
| 174 | +}); |
0 commit comments