Skip to content

Commit 3d42d7f

Browse files
authored
FAT-27419-pt2: tests added (#7467)
1 parent ea84419 commit 3d42d7f

13 files changed

Lines changed: 830 additions & 9 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../support/constants';
2+
import { Permissions } from '../../../support/dictionary';
3+
import DataImport from '../../../support/fragments/data_import/dataImport';
4+
import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView';
5+
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
6+
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
7+
import TopMenu from '../../../support/fragments/topMenu';
8+
import Users from '../../../support/fragments/users/users';
9+
import { randomFourDigitNumber } from '../../../support/utils/stringTools';
10+
import { or } from '../../../../interactors';
11+
12+
describe('Data Import', () => {
13+
describe('Importing MARC Bib files', () => {
14+
const testData = {
15+
marcFile: {
16+
marc: 'marcBibFileForC288432.mrc',
17+
fileName: `testMarcFileC288432.${randomFourDigitNumber()}.mrc`,
18+
jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
19+
},
20+
};
21+
const subjectHeading =
22+
'C288432_subA--C288432_subC--C288432_subD--C288432_subG--C288432_subV--C288432_subX--C288432_subY--C288432_subZ';
23+
const subjectHeadingNoHyphens = subjectHeading.replace(/--/g, ' ');
24+
25+
let instanceId;
26+
let user;
27+
28+
before('Create user and import test data', () => {
29+
cy.getAdminToken();
30+
DataImport.uploadFileViaApi(
31+
testData.marcFile.marc,
32+
testData.marcFile.fileName,
33+
testData.marcFile.jobProfileToRun,
34+
).then((response) => {
35+
instanceId = response[0].instance.id;
36+
});
37+
38+
cy.createTempUser([Permissions.inventoryAll.gui]).then((userProperties) => {
39+
user = userProperties;
40+
41+
cy.login(user.username, user.password, {
42+
path: TopMenu.inventoryPath,
43+
waiter: InventoryInstances.waitContentLoading,
44+
});
45+
});
46+
});
47+
48+
after('Delete test data', () => {
49+
cy.getAdminToken();
50+
InventoryInstance.deleteInstanceViaApi(instanceId);
51+
Users.deleteViaApi(user.userId);
52+
});
53+
54+
it(
55+
'C288432 Check the default mapping of 647 Subject heading field from the MARC record to the Inventory Instance Subjects field (folijet)',
56+
{ tags: ['extendedPath', 'folijet', 'C288432'] },
57+
() => {
58+
// Step 1-2: File imported via API in before hook using default job profile
59+
// Step 3-4: Search for imported instance by UUID; verify 647 subject (subfields a c d g v x y z)
60+
InventoryInstances.searchByTitle(instanceId);
61+
InventoryInstances.selectInstanceById(instanceId);
62+
InstanceRecordView.waitLoading();
63+
InventoryInstance.verifySubjectHeading(or(subjectHeading, subjectHeadingNoHyphens));
64+
},
65+
);
66+
});
67+
});
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../support/constants';
2+
import { Permissions } from '../../../support/dictionary';
3+
import DataImport from '../../../support/fragments/data_import/dataImport';
4+
import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView';
5+
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
6+
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
7+
import TopMenu from '../../../support/fragments/topMenu';
8+
import Users from '../../../support/fragments/users/users';
9+
import { randomFourDigitNumber } from '../../../support/utils/stringTools';
10+
11+
describe('Data Import', () => {
12+
describe('Importing MARC Bib files', () => {
13+
const testData = {
14+
marcFile: {
15+
marc: 'marcBibFileForC380724.mrc',
16+
fileName: `testMarcFileC380724.${randomFourDigitNumber()}.mrc`,
17+
jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
18+
},
19+
record1Classifications: [
20+
{ classificationIdentifierType: 'LC', classification: 'Z3807.M24 G38 0724' },
21+
{ classificationIdentifierType: 'LC', classification: 'TA3807.C24' },
22+
{ classificationIdentifierType: 'NLM', classification: 'W1 NE3807 v.24' },
23+
{ classificationIdentifierType: 'NLM', classification: 'QU 38 S724' },
24+
{ classificationIdentifierType: 'Dewey', classification: '380.724 HEA' },
25+
{ classificationIdentifierType: 'Dewey', classification: '380.7240' },
26+
{ classificationIdentifierType: 'GDC', classification: 'A 3.8/0:724' },
27+
{ classificationIdentifierType: 'GDC', classification: 'A 3.8/7:240' },
28+
{ classificationIdentifierType: 'GDC', classification: 'A 3.8:' },
29+
{ classificationIdentifierType: 'LC', classification: 'TA3807.C2' },
30+
{ classificationIdentifierType: 'LC', classification: 'Z3807.M24 G07 2438' },
31+
],
32+
record2Classifications: [
33+
{ classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000a' },
34+
{ classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000b' },
35+
{ classificationIdentifierType: 'NLM', classification: 'W1 ME3807 v.24 3807' },
36+
{ classificationIdentifierType: 'NLM', classification: 'QH 38.07 C724 3807' },
37+
{ classificationIdentifierType: 'UDC', classification: '380.724 B07' },
38+
{ classificationIdentifierType: 'UDC', classification: '307.248 B38' },
39+
{ classificationIdentifierType: 'Dewey', classification: '380.724 HEA' },
40+
{ classificationIdentifierType: 'Dewey', classification: '307.248 HEA' },
41+
{ classificationIdentifierType: 'GDC', classification: 'D 38.07:M 24' },
42+
{ classificationIdentifierType: 'GDC', classification: 'Y 3.AT 7:24 M 38/' },
43+
{ classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000c' },
44+
{ classificationIdentifierType: 'LC', classification: 'B3807.A24 P3807 2000d' },
45+
],
46+
};
47+
48+
let instanceId1;
49+
let instanceId2;
50+
let user;
51+
52+
before('Create user and import test data', () => {
53+
cy.getAdminToken();
54+
DataImport.uploadFileViaApi(
55+
testData.marcFile.marc,
56+
testData.marcFile.fileName,
57+
testData.marcFile.jobProfileToRun,
58+
).then((response) => {
59+
instanceId1 = response[0].instance.id;
60+
instanceId2 = response[1].instance.id;
61+
});
62+
63+
cy.createTempUser([Permissions.inventoryAll.gui]).then((userProperties) => {
64+
user = userProperties;
65+
66+
cy.login(user.username, user.password, {
67+
path: TopMenu.inventoryPath,
68+
waiter: InventoryInstances.waitContentLoading,
69+
});
70+
});
71+
});
72+
73+
after('Delete test data', () => {
74+
cy.getAdminToken();
75+
InventoryInstance.deleteInstanceViaApi(instanceId1);
76+
InventoryInstance.deleteInstanceViaApi(instanceId2);
77+
Users.deleteViaApi(user.userId);
78+
});
79+
80+
it(
81+
'C380724 Check the default mapping of Classification from the MARC record to the Inventory Instance Classification fields: Case 2 (folijet)',
82+
{ tags: ['extendedPath', 'folijet', 'C380724'] },
83+
() => {
84+
// Steps 1-4: Import done via API; open first record
85+
InventoryInstances.searchByTitle(instanceId1);
86+
InventoryInstances.selectInstanceById(instanceId1);
87+
InstanceRecordView.waitLoading();
88+
89+
// Steps 5-9: Verify record 1 classifications (050, 060, 082, 086, 090 with repeatable subfields)
90+
testData.record1Classifications.forEach(
91+
({ classificationIdentifierType, classification }) => {
92+
InstanceRecordView.verifyClassification(classificationIdentifierType, classification);
93+
},
94+
);
95+
96+
// Steps 10-16: Open second record; verify classifications (repeatable MARC fields)
97+
InventoryInstances.searchByTitle(instanceId2);
98+
InventoryInstances.selectInstanceById(instanceId2);
99+
InstanceRecordView.waitLoading();
100+
testData.record2Classifications.forEach(
101+
({ classificationIdentifierType, classification }) => {
102+
InstanceRecordView.verifyClassification(classificationIdentifierType, classification);
103+
},
104+
);
105+
},
106+
);
107+
});
108+
});
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import Permissions from '../../../support/dictionary/permissions';
2+
import DataImport from '../../../support/fragments/data_import/dataImport';
3+
import TopMenu from '../../../support/fragments/topMenu';
4+
import Users from '../../../support/fragments/users/users';
5+
import { getRandomLetters } from '../../../support/utils/stringTools';
6+
7+
describe('Data Import', () => {
8+
describe('Uploading files', () => {
9+
const filePathNoExtension = 'fileNoExtensionForC343279';
10+
let user;
11+
12+
before('Create test user and login', () => {
13+
cy.createTempUser([
14+
Permissions.moduleDataImportEnabled.gui,
15+
Permissions.settingsDataImportEnabled.gui,
16+
]).then((userProperties) => {
17+
user = userProperties;
18+
19+
cy.login(user.username, user.password, {
20+
path: TopMenu.dataImportPath,
21+
waiter: DataImport.waitLoading,
22+
});
23+
});
24+
});
25+
26+
after('Delete user', () => {
27+
cy.getAdminToken();
28+
Users.deleteViaApi(user.userId);
29+
});
30+
31+
it(
32+
'C343279 Disallow upload of a file without a file extension (folijet)',
33+
{ tags: ['extendedPath', 'folijet', 'C343279'] },
34+
() => {
35+
const fileNameNoExtension = `${filePathNoExtension}${getRandomLetters(15)}`;
36+
37+
// Step 1: Navigate to Data Import (done via login); verify landing page
38+
DataImport.verifyUploadState();
39+
40+
// Step 2: Upload file without extension; verify Import blocked modal
41+
DataImport.uploadFile(filePathNoExtension, fileNameNoExtension, false);
42+
DataImport.verifyImportBlockedModal({ noExtension: true });
43+
44+
// Step 3: Click Cancel; verify modal closes and landing page shown
45+
DataImport.cancelBlockedImportModal();
46+
DataImport.waitLoading();
47+
48+
// Step 4: Upload same file without extension again; verify same modal appears
49+
DataImport.uploadFile(filePathNoExtension, fileNameNoExtension, false);
50+
DataImport.verifyImportBlockedModal({ noExtension: true });
51+
52+
// Step 5: Click Choose other files to upload; verify modal closes
53+
DataImport.chooseOtherFilesBlockedImportModal();
54+
},
55+
);
56+
});
57+
});
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import Permissions from '../../../../support/dictionary/permissions';
2+
import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances';
3+
import InventorySearchAndFilter from '../../../../support/fragments/inventory/inventorySearchAndFilter';
4+
import TopMenu from '../../../../support/fragments/topMenu';
5+
import Users from '../../../../support/fragments/users/users';
6+
import getRandomPostfix from '../../../../support/utils/stringTools';
7+
import { NewOrder, Orders } from '../../../../support/fragments/orders';
8+
import { NewOrganization, Organizations } from '../../../../support/fragments/organizations';
9+
import OrderLineEditForm from '../../../../support/fragments/orders/orderLineEditForm';
10+
import OrderDetails from '../../../../support/fragments/orders/orderDetails';
11+
import SelectInstanceModal from '../../../../support/fragments/orders/modals/selectInstanceModal';
12+
13+
describe('Inventory', () => {
14+
describe('Search in "Select instance" plugin', () => {
15+
describe('Filters', () => {
16+
const randomPostfix = getRandomPostfix();
17+
const instanceTitlePrefix = `AT_C553055_FolioInstance_${randomPostfix}`;
18+
const dateRangeAccordionName = 'Date range';
19+
const organization = NewOrganization.getDefaultOrganization();
20+
organization.name = `AT_C553055_Org_${randomPostfix}`;
21+
const date1Values = Array.from({ length: 5 }, (_, i) => `${1902 + i}`);
22+
const instanceTitles = Array.from(
23+
{ length: date1Values.length },
24+
(_, i) => `${instanceTitlePrefix}_${i}`,
25+
);
26+
27+
let instanceTypeId;
28+
let order;
29+
let user;
30+
let instanceDateTypeIds;
31+
32+
before('Create users, data', () => {
33+
cy.getAdminToken();
34+
35+
cy.then(() => {
36+
InventoryInstances.deleteInstanceByTitleViaApi('C553055_');
37+
38+
cy.getInstanceTypes({ limit: 1 }).then((instanceTypes) => {
39+
instanceTypeId = instanceTypes[0].id;
40+
});
41+
cy.getInstanceDateTypesViaAPI().then(({ instanceDateTypes }) => {
42+
instanceDateTypeIds = instanceDateTypes.map((type) => type.id);
43+
});
44+
})
45+
.then(() => {
46+
Organizations.createOrganizationViaApi(organization).then(() => {
47+
const orderData = NewOrder.getDefaultOngoingOrder({
48+
vendorId: organization.id,
49+
});
50+
Orders.createOrderViaApi(orderData).then((createdOrder) => {
51+
order = createdOrder;
52+
});
53+
});
54+
})
55+
.then(() => {
56+
date1Values.forEach((date1, index) => {
57+
InventoryInstances.createFolioInstanceViaApi({
58+
instance: {
59+
instanceTypeId,
60+
title: instanceTitles[index],
61+
dates: {
62+
dateTypeId: instanceDateTypeIds[index],
63+
date1,
64+
},
65+
},
66+
});
67+
});
68+
})
69+
.then(() => {
70+
cy.createTempUser([
71+
Permissions.uiInventoryViewInstances.gui,
72+
Permissions.uiOrdersCreate.gui,
73+
]).then((userProperties) => {
74+
user = userProperties;
75+
76+
cy.login(user.username, user.password, {
77+
path: TopMenu.ordersPath,
78+
waiter: Orders.waitLoading,
79+
});
80+
Orders.selectOrderByPONumber(order.poNumber);
81+
OrderDetails.selectAddPOLine();
82+
OrderLineEditForm.clickTitleLookUpButton();
83+
InventorySearchAndFilter.instanceTabIsDefault();
84+
});
85+
});
86+
});
87+
88+
after('Delete test data', () => {
89+
cy.getAdminToken();
90+
InventoryInstances.deleteInstanceByTitleViaApi(instanceTitlePrefix);
91+
Users.deleteViaApi(user.userId);
92+
Organizations.deleteOrganizationViaApi(organization.id);
93+
Orders.deleteOrderViaApi(order.id);
94+
});
95+
96+
it(
97+
'C553055 "Select Instance" plugin | Filter "Instance" records by "Date range" filter using one box ("From" / "To") (spitfire)',
98+
{ tags: ['extendedPath', 'spitfire', 'C553055'] },
99+
() => {
100+
// Step 1: Search; verify all instances found with dates 1902-1906
101+
SelectInstanceModal.searchByName(instanceTitlePrefix);
102+
date1Values.forEach((date) => {
103+
InventorySearchAndFilter.verifyResultWithDate1Found(date);
104+
});
105+
InventorySearchAndFilter.verifyNumberOfSearchResults(instanceTitles.length);
106+
107+
// Step 2: Filter using From=1904 only (To empty); verify 1904-1906
108+
InventorySearchAndFilter.filterByDateRange(date1Values[2], '');
109+
date1Values.slice(2).forEach((date) => {
110+
InventorySearchAndFilter.verifyResultWithDate1Found(date);
111+
});
112+
InventorySearchAndFilter.verifyNumberOfSearchResults(3);
113+
114+
// Step 3: Clear From, filter using To=1904 only; verify 1902-1904
115+
InventorySearchAndFilter.toggleAccordionByName(dateRangeAccordionName, false);
116+
InventorySearchAndFilter.filterByDateRange('', date1Values[2]);
117+
date1Values.slice(0, 3).forEach((date) => {
118+
InventorySearchAndFilter.verifyResultWithDate1Found(date);
119+
});
120+
InventorySearchAndFilter.verifyNumberOfSearchResults(3);
121+
122+
// Step 4: Click x icon in Date range accordion; verify filter cleared
123+
InventorySearchAndFilter.clearFilter(dateRangeAccordionName);
124+
date1Values.forEach((date) => {
125+
InventorySearchAndFilter.verifyResultWithDate1Found(date);
126+
});
127+
InventorySearchAndFilter.verifyDateRangeAccordionValues('', '');
128+
},
129+
);
130+
});
131+
});
132+
});

0 commit comments

Comments
 (0)