Skip to content

Commit

Permalink
added a new test on title level request (FAT-15867) (#4154)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostapwd authored Sep 2, 2024
1 parent ae5b301 commit fbdd166
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ describe('Inventory', () => {
});

cy.setTenant(Affiliations.University);
TitleLevelRequests.disableTLRViaApi();
createdRecordsFromUniversity.forEach((instanceId) => {
InventoryInstance.deleteInstanceViaApi(instanceId);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/requests/cancel-item-level-request.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('Cancel item level request', () => {
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
})
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Create Recall Item level request', () => {
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
})
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/requests/edit-item-level-request.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Edit item level request', () => {
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
})
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/requests/edit-title-level-request.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Title Level Request', () => {
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
})
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/requests/find-requester-via-user-barcode.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Find requester via user barcode', () => {
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
})
.then(() => {
Expand Down
9 changes: 2 additions & 7 deletions cypress/e2e/requests/new-request-user-without-barcode.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import generateItemBarcode from '../../support/utils/generateItemBarcode';
import getRandomPostfix from '../../support/utils/stringTools';

describe('Choose requester without a barcode', () => {
const userData = {};
let userData = {};
const servicePoint = ServicePoints.getDefaultServicePointWithPickUpLocation();
const itemData = {
barcode: generateItemBarcode(),
Expand Down Expand Up @@ -68,12 +68,7 @@ describe('Choose requester without a barcode', () => {
.then(() => {
cy.createTempUser([Permissions.uiRequestsAll.gui], null, 'staff', false)
.then((userProperties) => {
userData.username = userProperties.username;
userData.password = userProperties.password;
userData.userId = userProperties.userId;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
userData = userProperties;
})
.then(() => {
UserEdit.addServicePointsViaApi([servicePoint.id], userData.userId, servicePoint.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SettingsMenu from '../../../support/fragments/settingsMenu';
import Users from '../../../support/fragments/users/users';

describe('Cancel item level request', () => {
const userData = {};
let userData = {};
const cancellationReason = {
id: uuid(),
name: uuid(),
Expand All @@ -21,12 +21,7 @@ describe('Cancel item level request', () => {
.then(() => {
cy.createTempUser([Permissions.settingsCircView.gui])
.then((userProperties) => {
userData.username = userProperties.username;
userData.password = userProperties.password;
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData = userProperties;
})
.then(() => {
cy.login(userData.username, userData.password, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import {
FULFILMENT_PREFERENCES,
ITEM_STATUS_NAMES,
REQUEST_LEVELS,
REQUEST_TYPES,
} from '../../support/constants';
import permissions from '../../support/dictionary/permissions';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
import EditRequest from '../../support/fragments/requests/edit-request';
import NewRequest from '../../support/fragments/requests/newRequest';
import RequestDetail from '../../support/fragments/requests/requestDetail';
import Requests from '../../support/fragments/requests/requests';
import SelectInstanceModal from '../../support/fragments/requests/selectInstanceModal';
import TitleLevelRequests from '../../support/fragments/settings/circulation/titleLevelRequests';
import Location from '../../support/fragments/settings/tenant/locations/newLocation';
import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints';
import TopMenu from '../../support/fragments/topMenu';
import UserEdit from '../../support/fragments/users/userEdit';
import Users from '../../support/fragments/users/users';
import generateItemBarcode from '../../support/utils/generateItemBarcode';
import { getTestEntityValue } from '../../support/utils/stringTools';

describe('Title Level Request', () => {
let userData = {};
const instanceData = {
title: getTestEntityValue('Instance'),
itemBarcode: generateItemBarcode(),
};
const testData = {
userServicePoint: ServicePoints.getDefaultServicePointWithPickUpLocation(),
};
before('Preconditions', () => {
cy.getAdminToken()
.then(() => {
ServicePoints.createViaApi(testData.userServicePoint);
testData.defaultLocation = Location.getDefaultLocation(testData.userServicePoint.id);
Location.createViaApi(testData.defaultLocation);
cy.getInstanceTypes({ limit: 1 }).then((instanceTypes) => {
instanceData.instanceTypeId = instanceTypes[0].id;
});
cy.getHoldingTypes({ limit: 1 }).then((holdingTypes) => {
instanceData.holdingTypeId = holdingTypes[0].id;
});
cy.getLoanTypes({ limit: 1 }).then((res) => {
instanceData.loanTypeId = res[0].id;
});
cy.getMaterialTypes({ limit: 1 }).then((materialTypes) => {
instanceData.materialTypeId = materialTypes.id;
});
})
.then(() => {
InventoryInstances.createFolioInstanceViaApi({
instance: {
instanceTypeId: instanceData.instanceTypeId,
title: instanceData.title,
},
holdings: [
{
holdingsTypeId: instanceData.holdingTypeId,
permanentLocationId: testData.defaultLocation.id,
},
],
items: [
{
barcode: instanceData.itemBarcode,
status: { name: ITEM_STATUS_NAMES.AVAILABLE },
permanentLoanType: { id: instanceData.loanTypeId },
materialType: { id: instanceData.materialTypeId },
},
],
}).then((specialInstanceIds) => {
instanceData.instanceId = specialInstanceIds.instanceId;
});
});

cy.createTempUser([
permissions.uiRequestsView.gui,
permissions.uiRequestsCreate.gui,
permissions.uiRequestsAll.gui,
permissions.uiRequestsEdit.gui,
permissions.uiUsersView.gui,
permissions.inventoryAll.gui,
]).then((userProperties) => {
userData = userProperties;
userData.patronGroup = userProperties.userGroup.group;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
UserEdit.addServicePointViaApi(
testData.userServicePoint.id,
userData.userId,
testData.userServicePoint.id,
);
cy.wait(3000);
cy.getInstance({
limit: 1,
expandAll: true,
query: `"id"=="${instanceData.instanceId}"`,
}).then((instance) => {
instanceData.instanceHRID = instance.hrid;
});
TitleLevelRequests.enableTLRViaApi();
cy.login(userData.username, userData.password, {
path: TopMenu.requestsPath,
waiter: Requests.waitLoading,
});
});
});

after('Deleting created entities', () => {
cy.getAdminToken();
Requests.getRequestApi({ query: `(instance.title=="${instanceData.title}")` }).then(
(requestResponse) => {
cy.wrap(requestResponse).each((request) => {
Requests.deleteRequestViaApi(request.id);
});
},
);
InventoryInstances.deleteInstanceAndHoldingRecordAndAllItemsViaApi(instanceData.itemBarcode);
UserEdit.changeServicePointPreferenceViaApi(userData.userId, [testData.userServicePoint.id]);
ServicePoints.deleteViaApi(testData.userServicePoint.id);
Users.deleteViaApi(userData.userId);
Location.deleteInstitutionCampusLibraryLocationViaApi(
testData.defaultLocation.institutionId,
testData.defaultLocation.campusId,
testData.defaultLocation.libraryId,
testData.defaultLocation.id,
);
});
it(
'C353599 C353600 Place title level request from title look-up (vega)',
{ tags: ['extendedPath', 'vega'] },
() => {
NewRequest.openNewRequestPane();
NewRequest.waitLoadingNewRequestPage();
NewRequest.enableTitleLevelRequest();
NewRequest.openTitleLookUp();
SelectInstanceModal.waitLoading();
SelectInstanceModal.searchByTitle(instanceData.title);
SelectInstanceModal.selectTheFirstInstance();
NewRequest.enterRequesterBarcode(userData.barcode);
NewRequest.verifyRequesterInformation(userData.username, userData.barcode);
NewRequest.chooseRequestType(REQUEST_TYPES.PAGE);
NewRequest.choosePickupServicePoint(testData.userServicePoint.name);
NewRequest.saveRequestAndClose();
NewRequest.verifyRequestSuccessfullyCreated(userData.username);
RequestDetail.checkTitleInformation({
TLRs: '1',
title: instanceData.title,
});
RequestDetail.checkRequestInformation({
type: REQUEST_TYPES.PAGE,
status: EditRequest.requestStatuses.NOT_YET_FILLED,
level: REQUEST_LEVELS.TITLE,
});
RequestDetail.checkRequesterInformation({
lastName: userData.fullName,
barcode: userData.barcode,
group: userData.patronGroup,
preference: FULFILMENT_PREFERENCES.HOLD_SHELF,
pickupSP: testData.userServicePoint.name,
});
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Title level request', () => {
UserEdit.changeServicePointPreferenceViaApi(userData.userId, [testData.servicePoint.id]);
ServicePoints.deleteViaApi(testData.servicePoint.id);
Users.deleteViaApi(userData.userId);
TitleLevelRequests.disableTLRViaApi();
});

it(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import generateItemBarcode from '../../support/utils/generateItemBarcode';
import getRandomPostfix, { randomFourDigitNumber } from '../../support/utils/stringTools';

describe('Requests', () => {
const userData = {};
let userData = {};
const servicePoint = ServicePoints.getDefaultServicePointWithPickUpLocation();
const itemData = {
barcode: generateItemBarcode(),
Expand Down Expand Up @@ -97,13 +97,7 @@ describe('Requests', () => {
.then(() => {
cy.createTempUser([Permissions.uiRequestsAll.gui])
.then((userProperties) => {
userData.username = userProperties.username;
userData.password = userProperties.password;
userData.userId = userProperties.userId;
userData.barcode = userProperties.barcode;
userData.firstName = userProperties.firstName;
userData.patronGroup = userProperties.patronGroup;
userData.fullName = `${userData.username}, ${Users.defaultUser.personal.firstName} ${Users.defaultUser.personal.middleName}`;
userData = userProperties;
})
.then(() => {
cy.wrap(true)
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/title-level-request/tlr-Item-renewable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ describe('TLR: Item renew', () => {
testData.defaultLocation.libraryId,
testData.defaultLocation.id,
);
TitleLevelRequests.disableTLRViaApi();
});

afterEach('Deleting created entities', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ describe('Title Level Request. Create Item or Title level request', () => {
testData.defaultLocation.libraryId,
testData.defaultLocation.id,
);
TitleLevelRequests.disableTLRViaApi();
});
it(
'C347890 Check that user can create Item level request from instance page (vega) (TaaS)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ describe('Create Item or Title level request', () => {
testData.defaultLocation.libraryId,
testData.defaultLocation.id,
);
TitleLevelRequests.disableTLRViaApi();
});
it(
'C347888 Check that user can create Title level request from User app (use Actions) (vega) (Taas)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ describe('Request Detail. TLR', () => {
testData.defaultLocation.libraryId,
testData.defaultLocation.id,
);
TitleLevelRequests.disableTLRViaApi();
});

it(
Expand Down
7 changes: 4 additions & 3 deletions cypress/support/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Cypress.Commands.add('getFirstUserGroupId', (searchParams, patronGroupName) => {
userGroupIdx =
response.body.usergroups.findIndex(({ group }) => group === patronGroupName) || 0;
}
return response.body.usergroups[userGroupIdx].id;
return response.body.usergroups[userGroupIdx];
});
});

Expand Down Expand Up @@ -86,7 +86,7 @@ Cypress.Commands.add(
}

cy.getFirstUserGroupId({ limit: patronGroupName ? 100 : 1 }, patronGroupName).then(
(userGroupdId) => {
(userGroup) => {
const queryField = 'displayName';
cy.getPermissionsApi({
query: `(${queryField}=="${permissions.join(`")or(${queryField}=="`)}"))"`,
Expand All @@ -96,7 +96,7 @@ Cypress.Commands.add(
// cy.log('internalPermissions=' + [...permissionsResponse.body.permissions.map(permission => permission.permissionName)]);
const userBody = {
...Users.defaultUser,
patronGroup: userGroupdId,
patronGroup: userGroup.id,
type: userType,
username: userProperties.username,
personal: { ...Users.defaultUser.personal, lastName: userProperties.username },
Expand Down Expand Up @@ -129,6 +129,7 @@ Cypress.Commands.add(
),
],
});
userProperties.userGroup = userGroup;
cy.overrideLocalSettings(userProperties.userId);
cy.wrap(userProperties).as('userProperties');
});
Expand Down
1 change: 1 addition & 0 deletions cypress/support/fragments/requests/newRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export default {
// need to synchronize actions before click
cy.wait(3000);
cy.do(titleLevelRequest.click());
cy.wait(2000);
},

waitLoadingNewRequestPage(TLR = false) {
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/fragments/requests/selectInstanceModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default {
cy.expect(selectInstanceModal.find(MultiColumnList()).has({ rowCount: 1 }));
},

selectTheFirstInstance() {
cy.do(selectInstanceModal.find(MultiColumnListRow({ index: 0 })).click());
},

fillInSearchField(title) {
cy.do([selectInstanceModal.find(searchField).fillIn(title)]);
},
Expand Down

0 comments on commit fbdd166

Please sign in to comment.