From 3a516e4f5ca744a72384ccc79d035ac4691385a3 Mon Sep 17 00:00:00 2001 From: Yauhen Viazau Date: Wed, 15 Jan 2025 19:37:56 +0500 Subject: [PATCH] FAT-18035: test added --- .../single-record-import/import-by-loc.cy.js | 45 ++++++++++++++----- .../fragments/inventory/inventoryActions.js | 13 +++++- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/inventory/single-record-import/import-by-loc.cy.js b/cypress/e2e/inventory/single-record-import/import-by-loc.cy.js index 6a64f06f9a..97bf9a2333 100644 --- a/cypress/e2e/inventory/single-record-import/import-by-loc.cy.js +++ b/cypress/e2e/inventory/single-record-import/import-by-loc.cy.js @@ -8,13 +8,20 @@ import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; let user; -const loc = '01012052'; -const instanceTitlePart = 'The history of New England from 1630 to 1649'; -const expectedFields = [ +const locC490900 = '01012052'; +const locC490902 = '68073904'; +const instanceTitlePartC490900 = 'The history of New England from 1630 to 1649'; +const instanceTitlePartC490902 = 'Vanity Fair; introduction and notes by Gilbert Phelps.'; +const expectedFieldsC490900 = [ { tag: '035', position: 4, content: undefined }, { tag: '035', position: 6, content: '$9 (DLC) 01012052' }, { tag: '035', position: 8, content: '$a (OCoLC)2628488' }, ]; +const expectedFieldsC490902 = [ + { tag: '035', position: 4, content: '$9 (DLC) 68073904' }, + { tag: '035', position: 5, content: undefined }, +]; +const createdInstaceIds = []; describe('Inventory', () => { describe('Single record import', () => { @@ -28,7 +35,7 @@ describe('Inventory', () => { cy.toggleLocSingleImportProfileViaAPI(); InventoryInstances.getInstancesViaApi({ limit: 100, - query: `title="${instanceTitlePart}"`, + query: `(title="${instanceTitlePartC490900}" or title="${instanceTitlePartC490902}")`, }).then((instances) => { if (instances) { instances.forEach(({ id }) => { @@ -44,13 +51,16 @@ describe('Inventory', () => { path: TopMenu.inventoryPath, waiter: InventoryInstances.waitContentLoading, }); + cy.reload(); + cy.wait('@/authn/refresh', { timeout: 20000 }); + InventoryInstances.waitContentLoading(); }); after('Delete test data', () => { cy.getAdminToken(); cy.toggleLocSingleImportProfileViaAPI(false); - cy.getInstance({ limit: 1, expandAll: true, query: `"lccn"=="${loc}"` }).then((instance) => { - InventoryInstance.deleteInstanceViaApi(instance.id); + createdInstaceIds.forEach((id) => { + InventoryInstance.deleteInstanceViaApi(id); }); Users.deleteViaApi(user.userId); }); @@ -59,12 +69,27 @@ describe('Inventory', () => { 'C490900 Generated "035" field displays in ascending fields order in imported via single record import "MARC bibliographic" record which has multiple existing "035" fields (spitfire)', { tags: ['criticalPath', 'spitfire', 'C490900'] }, () => { - cy.reload(); - cy.wait('@/authn/refresh', { timeout: 20000 }); - InventoryActions.importLoc(loc); + InventoryActions.importLoc(locC490900); + InstanceRecordView.waitLoading(); + InventoryInstance.getId().then((id) => createdInstaceIds.push(id)); + InventoryInstance.editMarcBibliographicRecord(); + expectedFieldsC490900.forEach((field) => { + QuickMarcEditor.verifyTagValue(field.position, field.tag); + if (field.content) QuickMarcEditor.checkContent(field.content, field.position); + }); + }, + ); + + it( + 'C490902 Generated "035" field displays in ascending fields order in imported via single record import "MARC bibliographic" record which has one existing "035" field (spitfire)', + { tags: ['criticalPath', 'spitfire', 'C490902'] }, + () => { + InventoryActions.importLoc(locC490902); + InventoryInstance.checkInstanceTitle(instanceTitlePartC490902); InstanceRecordView.waitLoading(); + InventoryInstance.getId().then((id) => createdInstaceIds.push(id)); InventoryInstance.editMarcBibliographicRecord(); - expectedFields.forEach((field) => { + expectedFieldsC490902.forEach((field) => { QuickMarcEditor.verifyTagValue(field.position, field.tag); if (field.content) QuickMarcEditor.checkContent(field.content, field.position); }); diff --git a/cypress/support/fragments/inventory/inventoryActions.js b/cypress/support/fragments/inventory/inventoryActions.js index bb485e45c0..aa943a206d 100644 --- a/cypress/support/fragments/inventory/inventoryActions.js +++ b/cypress/support/fragments/inventory/inventoryActions.js @@ -1,4 +1,4 @@ -import { Button, Section, Select, TextField } from '../../../../interactors'; +import { Button, Section, Select, TextField, Modal, or } from '../../../../interactors'; import DateTools from '../../utils/dateTools'; import InventoryInstance from './inventoryInstance'; import FileManager from '../../utils/fileManager'; @@ -11,6 +11,9 @@ const OCLWorldCatIdentifierTextField = TextField({ name: 'externalIdentifier' }) const importTypeSelect = Select({ name: 'externalIdentifierType' }); const locIdInputField = TextField('Enter the Library of Congress identifier'); const singleImportSuccessCalloutText = (number) => `Record ${number} created. Results may take a few moments to become visible in Inventory`; +const importProfileSelect = Select({ name: 'selectedJobProfileId' }); +const importModal = Modal({ id: 'import-record-modal' }); +const cancelImportButtonInModal = importModal.find(Button('Cancel')); function open() { cy.do(Section({ id: 'pane-results' }).find(Button('Actions')).click()); @@ -160,9 +163,17 @@ export default { importLoc(specialLOCidentifier = InventoryInstance.validLOC) { open(); cy.do(importButtonInActions.click()); + cy.expect([ + importModal.exists(), + importTypeSelect.exists(), + importProfileSelect.exists(), + importButtonInModal.is({ disabled: or(true, false) }), + cancelImportButtonInModal.exists(), + ]); cy.do(importTypeSelect.choose('Library of Congress')); cy.expect(locIdInputField.exists()); this.fillImportFields(specialLOCidentifier); + cy.wait(1000); this.pressImportInModal(specialLOCidentifier); InventoryInstance.checkExpectedMARCSource(); },