-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcreate-instance-ecs.cy.js
More file actions
149 lines (139 loc) · 6.19 KB
/
Copy pathcreate-instance-ecs.cy.js
File metadata and controls
149 lines (139 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import Work from '../../support/fragments/linked-data/work';
import TopMenu from '../../support/fragments/topMenu';
import Marigold from '../../support/fragments/linked-data/marigold';
import EditResource from '../../support/fragments/linked-data/editResource';
import SearchAndFilter from '../../support/fragments/linked-data/searchAndFilter';
import {
APPLICATION_NAMES,
DEFAULT_JOB_PROFILE_NAMES,
EDIT_RESOURCE_HEADINGS,
} from '../../support/constants';
import {
MARIGOLD_CAPABILITIES,
MARIGOLD_CAPABILITY_SETS,
} from '../../support/dictionary/marigoldCapabilities';
import TopMenuNavigation from '../../support/fragments/topMenuNavigation';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
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';
import Affiliations, { tenantNames } from '../../support/dictionary/affiliations';
import Permissions from '../../support/dictionary/permissions';
import ConsortiumManager from '../../support/fragments/settings/consortium-manager/consortium-manager';
import NewInstance from '../../support/fragments/linked-data/newInstance';
import InstanceProfileModal from '../../support/fragments/linked-data/instanceProfileModal';
import Users from '../../support/fragments/users/users';
let user;
describe('Citation: create instance in central tenant + holdings in member', () => {
const testData = {
marcFilePath: 'marcBibFileForC451572.mrc',
modifiedMarcFile: `C736677 editedMarcFile${getRandomPostfix()}.mrc`,
marcFileName: `C736677 marcFile${getRandomPostfix()}.mrc`,
uniqueTitle: `Cypress test ${getRandomPostfix()}`,
uniqueIsbn: `ISBN${getRandomLetters(8)}`,
uniqueCreator: `Creator-${getRandomLetters(10)}`,
uniqueInstanceTitle: `Instance AQA title ${getRandomPostfix()}`,
callNumber: '331.2',
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();
cy.createTempUser([Permissions.inventoryAll.gui]).then((userProperties) => {
user = userProperties;
cy.assignCapabilitiesToExistingUser(
user.userId,
MARIGOLD_CAPABILITIES,
MARIGOLD_CAPABILITY_SETS,
);
});
cy.then(() => {
// Assign affiliation to member tenant and set permissions
cy.assignAffiliationToUser(Affiliations.College, user.userId);
cy.setTenant(Affiliations.College);
cy.assignPermissionsToExistingUser(user.userId, [Permissions.inventoryAll.gui]);
cy.resetTenant();
});
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.deleteFullInstancesByTitleViaApi(resourceData.title);
Work.getInstancesByTitle(testData.uniqueTitle).then((instances) => {
const filteredInstances = instances.filter(
(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.deleteFullInstancesByTitleViaApi(testData.uniqueInstanceTitle);
Users.deleteViaApi(user.userId);
});
beforeEach('Apply test data manually', () => {
cy.login(user.username, user.password, {
path: TopMenu.inventoryPath,
waiter: InventorySearchAndFilter.waitLoading,
authRefresh: true,
});
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.central);
// create test data based on uploaded marc file
Marigold.createTestWorkDataManuallyBasedOnMarcUpload(resourceData.title);
});
it(
'C736677 [User journey] Marigold - Create new instance in central tenant (citation)',
{ tags: ['draft', 'citation', 'marigold', 'C736677'] },
() => {
// search by title for work created in precondition
SearchAndFilter.searchResourceByTitle(resourceData.title);
// open work for editing
Marigold.selectFromSearchTable(1);
Marigold.editWork();
EditResource.waitLoading(EDIT_RESOURCE_HEADINGS.EDIT_WORK);
// add new instance
EditResource.openNewInstanceFormViaActions();
InstanceProfileModal.waitLoading();
InstanceProfileModal.selectDefaultOption();
NewInstance.addMainInstanceTitle(testData.uniqueInstanceTitle);
NewInstance.addInstanceIdentifiers(testData);
EditResource.saveAndClose();
// wait for LDE page to be displayed
Marigold.waitLoading();
// switch to member tenant
TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY);
ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college);
// search for newly added instance
InventoryInstances.searchByTitle(testData.uniqueInstanceTitle, false);
InventorySearchAndFilter.verifyNoRecordsFound();
},
);
});