Skip to content

Commit

Permalink
FAT-18035: test added
Browse files Browse the repository at this point in the history
  • Loading branch information
zentestuken committed Jan 15, 2025
1 parent 7fe7e38 commit 3a516e4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
45 changes: 35 additions & 10 deletions cypress/e2e/inventory/single-record-import/import-by-loc.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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 }) => {
Expand All @@ -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);
});
Expand All @@ -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);
});
Expand Down
13 changes: 12 additions & 1 deletion cypress/support/fragments/inventory/inventoryActions.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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());
Expand Down Expand Up @@ -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();
},
Expand Down

0 comments on commit 3a516e4

Please sign in to comment.