Skip to content

Commit

Permalink
citations tests updated; shiftLeft tag added
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrener-eis committed Dec 27, 2024
1 parent 06e3fd6 commit 862c3ac
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 35 deletions.
72 changes: 69 additions & 3 deletions cypress/e2e/linked-data/check-view-and-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,79 @@ import TopMenu from '../../support/fragments/topMenu';
import LinkedDataEditor from '../../support/fragments/linked-data/linkedDataEditor';
import TopMenuNavigation from '../../support/fragments/topMenuNavigation';
import SearchAndFilter from '../../support/fragments/linked-data/searchAndFilter';
import InventorySearchAndFilter from '../../support/fragments/inventory/inventorySearchAndFilter';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
import Work from '../../support/fragments/linked-data/work';
import FileManager from '../../support/utils/fileManager';
import getRandomPostfix, { getRandomLetters } from '../../support/utils/stringTools';
import DataImport from '../../support/fragments/data_import/dataImport';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../support/constants';

describe('Citation: check navigation', () => {
beforeEach(() => {
const testData = {
marcFilePath: 'marcBibFileForC451572.mrc',
modifiedMarcFile: `C451572 editedMarcFile${getRandomPostfix()}.mrc`,
marcFileName: `C451572 marcFile${getRandomPostfix()}.mrc`,
uniqueTitle: `Cypress test ${getRandomPostfix()}`,
uniqueIsbn: `ISBN${getRandomLetters(8)}`,
uniqueCreator: `Creator-${getRandomLetters(10)}`,
};

const resourceData = {
creator: testData.uniqueCreator,
language: 'spa',
classificationNumber: 'PC4112',
title: `${testData.uniqueTitle} TT test35 cultural approach to intermediate Spanish tk1 /`,
isbnIdentifier: testData.uniqueIsbn,
lccnIdentifier: 'aa1994901234',
publisher: 'Scott, Foresman, test',
publicationDate: '2024',
edition: '3rd ed. test',
};

before('Create test data via API', () => {
// Set unique title, ISBN and Creator for searching
DataImport.editMarcFile(
testData.marcFilePath,
testData.modifiedMarcFile,
["!A Alice's Adventures in Wonderland", '123456789123456', 'Neale-Silva, Eduardo'],
[testData.uniqueTitle, testData.uniqueIsbn, testData.uniqueCreator],
);
cy.getAdminToken();
DataImport.uploadFileViaApi(
testData.modifiedMarcFile,
testData.marcFileName,
DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
);
});

after('Delete test data', () => {
FileManager.deleteFile(`cypress/fixtures/${testData.modifiedMarcFile}`);
cy.getAdminToken();
// delete inventory instance both from inventory and LDE modules
// this might change later once corresponding instance will automatically get deleted in linked-data
InventoryInstances.getInstanceIdApi({
limit: 1,
query: `title="${resourceData.title}"`,
}).then((id) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
Work.getInstancesByTitle(testData.uniqueTitle).then((instances) => {
const filteredInstances = instances.filter(
(element) => element.titles[0].value === testData.uniqueTitle,
);
Work.deleteById(filteredInstances[0].id);
});
Work.getIdByTitle(testData.uniqueTitle).then((id) => Work.deleteById(id));
});

beforeEach('Apply test data manually', () => {
cy.loginAsAdmin({
path: TopMenu.linkedDataEditor,
waiter: LinkedDataEditor.waitLoading,
path: TopMenu.inventoryPath,
waiter: InventorySearchAndFilter.waitLoading,
});
// create test data based on uploaded marc file
LinkedDataEditor.createTestWorkDataManuallyBasedOnMarcUpload(resourceData.title);
});

it(
Expand Down
65 changes: 57 additions & 8 deletions cypress/e2e/linked-data/duplicate-instance.cy.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,92 @@
import Work from '../../support/fragments/linked-data/work';
import TopMenu from '../../support/fragments/topMenu';
import getRandomPostfix from '../../support/utils/stringTools';
import LinkedDataEditor from '../../support/fragments/linked-data/linkedDataEditor';
import EditResource from '../../support/fragments/linked-data/editResource';
import SearchAndFilter from '../../support/fragments/linked-data/searchAndFilter';
import { APPLICATION_NAMES, LOCATION_NAMES } from '../../support/constants';
import { APPLICATION_NAMES, LOCATION_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../support/constants';
import TopMenuNavigation from '../../support/fragments/topMenuNavigation';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
import InventoryInstance from '../../support/fragments/inventory/inventoryInstance';
import InventorySearchAndFilter from '../../support/fragments/inventory/inventorySearchAndFilter';
import FileManager from '../../support/utils/fileManager';
import getRandomPostfix, { getRandomLetters } from '../../support/utils/stringTools';
import DataImport from '../../support/fragments/data_import/dataImport';

describe('Citation: duplicate instance', () => {
const testData = {
marcFilePath: 'marcBibFileForC451572.mrc',
modifiedMarcFile: `C451572 editedMarcFile${getRandomPostfix()}.mrc`,
marcFileName: `C451572 marcFile${getRandomPostfix()}.mrc`,
uniqueTitle: `Cypress test ${getRandomPostfix()}`,
uniqueIsbn: `ISBN${getRandomLetters(8)}`,
uniqueCreator: `Creator-${getRandomLetters(10)}`,
uniqueInstanceTitle: `Instance AQA title ${getRandomPostfix()}`,
callNumber: '331.2',
};

const resourceData = {
creator: testData.uniqueCreator,
language: 'spa',
classificationNumber: 'PC4112',
title: `${testData.uniqueTitle} TT test35 cultural approach to intermediate Spanish tk1 /`,
isbnIdentifier: testData.uniqueIsbn,
lccnIdentifier: 'aa1994901234',
publisher: 'Scott, Foresman, test',
publicationDate: '2024',
edition: '3rd ed. test',
};

before('Create test data via API', () => {
// Set unique title, ISBN and Creator for searching
DataImport.editMarcFile(
testData.marcFilePath,
testData.modifiedMarcFile,
["!A Alice's Adventures in Wonderland", '123456789123456', 'Neale-Silva, Eduardo'],
[testData.uniqueTitle, testData.uniqueIsbn, testData.uniqueCreator],
);
cy.getAdminToken();
DataImport.uploadFileViaApi(
testData.modifiedMarcFile,
testData.marcFileName,
DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
);
});

after('Delete test data', () => {
FileManager.deleteFile(`cypress/fixtures/${testData.modifiedMarcFile}`);
cy.getAdminToken();
// delete inventory instance both from inventory and LDE modules
// this might change later once corresponding instance will automatically get deleted in linked-data
InventoryInstances.getInstanceIdApi({
limit: 1,
query: `title="${testData.uniqueInstanceTitle}"`,
query: `title="${resourceData.title}"`,
}).then((id) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
Work.getInstancesByTitle(testData.uniqueInstanceTitle).then((instances) => {
Work.getInstancesByTitle(testData.uniqueTitle).then((instances) => {
const filteredInstances = instances.filter(
(element) => element.titles[0].value === testData.uniqueInstanceTitle,
(element) => element.titles[0].value === testData.uniqueTitle,
);
Work.deleteById(filteredInstances[0].id);
});
// delete work created in pre-condition
Work.getIdByTitle(testData.uniqueTitle).then((id) => Work.deleteById(id));
// delete duplicate instance data
InventoryInstances.getInstanceIdApi({
limit: 1,
query: `title="${testData.uniqueInstanceTitle}"`,
}).then((id) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
});

beforeEach(() => {
beforeEach('Apply test data manually', () => {
cy.loginAsAdmin({
path: TopMenu.linkedDataEditor,
waiter: SearchAndFilter.waitLoading,
path: TopMenu.inventoryPath,
waiter: InventorySearchAndFilter.waitLoading,
});
// create test data based on uploaded marc file
LinkedDataEditor.createTestWorkDataManuallyBasedOnMarcUpload(resourceData.title);
});

it(
Expand All @@ -63,6 +111,7 @@ describe('Citation: duplicate instance', () => {
// navigate to the inventory module
TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.INVENTORY);
InventoryInstances.searchByTitle(testData.uniqueInstanceTitle);
InventoryInstance.verifySourceInAdministrativeData('LINKED_DATA');
// Add holdings
const HoldingsRecordEdit = InventoryInstance.pressAddHoldingsButton();
HoldingsRecordEdit.fillHoldingFields({
Expand Down
77 changes: 69 additions & 8 deletions cypress/e2e/linked-data/duplicate-work.cy.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,98 @@
import Work from '../../support/fragments/linked-data/work';
import TopMenu from '../../support/fragments/topMenu';
import getRandomPostfix from '../../support/utils/stringTools';
import LinkedDataEditor from '../../support/fragments/linked-data/linkedDataEditor';
import EditResource from '../../support/fragments/linked-data/editResource';
import SearchAndFilter from '../../support/fragments/linked-data/searchAndFilter';
import NewInstance from '../../support/fragments/linked-data/newInstance';
import { APPLICATION_NAMES } from '../../support/constants';
import { APPLICATION_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../support/constants';
import TopMenuNavigation from '../../support/fragments/topMenuNavigation';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
import InventorySearchAndFilter from '../../support/fragments/inventory/inventorySearchAndFilter';
import InventoryInstance from '../../support/fragments/inventory/inventoryInstance';
import FileManager from '../../support/utils/fileManager';
import getRandomPostfix, { getRandomLetters } from '../../support/utils/stringTools';
import DataImport from '../../support/fragments/data_import/dataImport';

describe('Citation: duplicate existing work', () => {
const testData = {
marcFilePath: 'marcBibFileForC451572.mrc',
modifiedMarcFile: `C451572 editedMarcFile${getRandomPostfix()}.mrc`,
marcFileName: `C451572 marcFile${getRandomPostfix()}.mrc`,
uniqueTitle: `Cypress test ${getRandomPostfix()}`,
uniqueIsbn: `ISBN${getRandomLetters(8)}`,
uniqueCreator: `Creator-${getRandomLetters(10)}`,
uniqueDuplicateTitle: `Cypress test duplicate ${getRandomPostfix()}`,
uniqueInstanceTitle: `Instance AQA title ${getRandomPostfix()}`,
resourceIdentifiers: [
{ type: 'ISBN', value: '1587657090' },
{ type: 'ISBN', value: '9781587657092' },
],
};

const resourceData = {
creator: testData.uniqueCreator,
language: 'spa',
classificationNumber: 'PC4112',
title: `${testData.uniqueTitle} TT test35 cultural approach to intermediate Spanish tk1 /`,
isbnIdentifier: testData.uniqueIsbn,
lccnIdentifier: 'aa1994901234',
publisher: 'Scott, Foresman, test',
publicationDate: '2024',
edition: '3rd ed. test',
};

before('Create test data via API', () => {
// Set unique title, ISBN and Creator for searching
DataImport.editMarcFile(
testData.marcFilePath,
testData.modifiedMarcFile,
["!A Alice's Adventures in Wonderland", '123456789123456', 'Neale-Silva, Eduardo'],
[testData.uniqueTitle, testData.uniqueIsbn, testData.uniqueCreator],
);
cy.getAdminToken();
DataImport.uploadFileViaApi(
testData.modifiedMarcFile,
testData.marcFileName,
DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
);
});

after('Delete test data', () => {
FileManager.deleteFile(`cypress/fixtures/${testData.modifiedMarcFile}`);
cy.getAdminToken();
// delete inventory instance both from inventory and LDE modules
// this might change later once corresponding instance will automatically get deleted in linked-data
InventoryInstances.getInstanceIdApi({
limit: 1,
query: `title="${resourceData.title}"`,
}).then((id) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
Work.getInstancesByTitle(testData.uniqueTitle).then((instances) => {
const filteredInstances = instances.filter(
(element) => element.titles[0].value === testData.uniqueTitle,
);
Work.deleteById(filteredInstances[0].id);
});
Work.getIdByTitle(testData.uniqueTitle).then((id) => Work.deleteById(id));
// delete duplicate work data
Work.getInstancesByTitle(testData.uniqueInstanceTitle).then((instances) => {
const filteredInstances = instances.filter(
(element) => element.titles[0].value === testData.uniqueInstanceTitle,
);
Work.deleteById(filteredInstances[0].id);
});
Work.getIdByTitle(testData.uniqueDuplicateTitle).then((id) => Work.deleteById(id));
InventoryInstances.deleteInstanceByTitleViaApi(testData.uniqueInstanceTitle);
});

beforeEach(() => {
beforeEach('Apply test data manually', () => {
cy.loginAsAdmin({
path: TopMenu.linkedDataEditor,
waiter: SearchAndFilter.waitLoading,
path: TopMenu.inventoryPath,
waiter: InventorySearchAndFilter.waitLoading,
});
// create test data based on uploaded marc file
LinkedDataEditor.createTestWorkDataManuallyBasedOnMarcUpload(resourceData.title);
});

it(
Expand All @@ -45,7 +106,7 @@ describe('Citation: duplicate existing work', () => {
LinkedDataEditor.editWork();
// duplicate work
EditResource.duplicateResource();
EditResource.setValueForTheField(testData.uniqueTitle, 'Preferred Title for Work');
EditResource.setValueForTheField(testData.uniqueDuplicateTitle, 'Preferred Title for Work');
EditResource.saveAndKeepEditing();
// add instance
EditResource.openNewInstanceForm();
Expand All @@ -55,8 +116,8 @@ describe('Citation: duplicate existing work', () => {
// wait for LDE page to be displayed
LinkedDataEditor.waitLoading();
// search created work by title
SearchAndFilter.searchResourceByTitle(testData.uniqueTitle);
SearchAndFilter.checkSearchResultsByTitle(testData.uniqueTitle);
SearchAndFilter.searchResourceByTitle(testData.uniqueDuplicateTitle);
SearchAndFilter.checkSearchResultsByTitle(testData.uniqueDuplicateTitle);
// check that newly created instance is displayed in the inventory
TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.INVENTORY);
InventoryInstances.searchByTitle(testData.uniqueInstanceTitle);
Expand Down
Loading

0 comments on commit 862c3ac

Please sign in to comment.