Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAT-1270/C17093 #2455

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 48 additions & 1 deletion cypress/e2e/circulation-log/filter-notice-send.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import CheckOutActions from '../../support/fragments/check-out-actions/check-out
import Checkout from '../../support/fragments/checkout/checkout';
import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints';
import getRandomPostfix from '../../support/utils/stringTools';
import SearchResults from '../../support/fragments/circulation-log/searchResults';
import LoansPage from '../../support/fragments/loans/loansPage';
import ItemRecordView from '../../support/fragments/inventory/item/itemRecordView';
import NewNoticePolicyTemplate from '../../support/fragments/settings/circulation/patron-notices/newNoticePolicyTemplate';
import NewNoticePolicy from '../../support/fragments/settings/circulation/patron-notices/newNoticePolicy';

let user;
const templateBody = {
Expand Down Expand Up @@ -76,7 +81,8 @@ describe('circulation-log', () => {
);
})
.then(() => {
NoticePolicyTemplateApi.createViaApi(templateBody).then(() => {
NoticePolicyTemplateApi.createViaApi(templateBody).then((noticeTemplate) => {
testData.templateData = noticeTemplate;
NoticePolicyApi.createWithTemplateApi(noticePolicy);
});
cy.getNoticePolicy({ query: `name=="${noticePolicy.name}"` }).then((response) => {
Expand Down Expand Up @@ -147,4 +153,45 @@ describe('circulation-log', () => {
SearchPane.checkResultSearch(searchResultsData);
},
);

it(
'C17093 Check the Actions button from filtering Circulation log by (notices) send (volaris)',
{ tags: [testTypes.criticalPath, devTeams.volaris] },
() => {
const goToCircLogApp = (filterName) => {
cy.visit(TopMenu.circulationLogPath);
SearchPane.waitLoading();
SearchPane.setFilterOptionFromAccordion('notice', filterName);
SearchPane.searchByItemBarcode(item.barcode);
return SearchPane.findResultRowIndexByContent(filterName);
};

goToCircLogApp('Send').then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'Loan details');
LoansPage.waitLoading();
});
goToCircLogApp('Send').then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'User details');
Users.verifyFirstNameOnUserDetailsPane(user.firstName);
});
goToCircLogApp('Send').then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'Notice policy');
NewNoticePolicy.checkPolicyName(noticePolicy);
});
goToCircLogApp('Send').then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'Live version of template');
NewNoticePolicyTemplate.checkAfterSaving({
name: testData.templateData.name,
description: testData.templateData.description,
category: { requestId: testData.templateData.category },
subject: 'Subject_Test',
body: 'Test_email_body{{item.title}}',
});
});
goToCircLogApp('Send').then((rowIndex) => {
SearchResults.clickOnCell(item.barcode, Number(rowIndex));
ItemRecordView.waitLoading();
});
},
);
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid from 'uuid';
import moment from 'moment';
import permissions from '../../support/dictionary/permissions';
import devTeams from '../../support/dictionary/devTeams';
import { getTestEntityValue } from '../../support/utils/stringTools';
Expand All @@ -14,19 +15,71 @@ import UserEdit from '../../support/fragments/users/userEdit';
import InventoryInstances from '../../support/fragments/inventory/inventoryInstances';
import Locations from '../../support/fragments/settings/tenant/location-setup/locations';
import LoanPolicy from '../../support/fragments/circulation/loan-policy';
import SearchResults from '../../support/fragments/circulation-log/searchResults';
import ItemRecordView from '../../support/fragments/inventory/item/itemRecordView';
import LoansPage from '../../support/fragments/loans/loansPage';
import Requests from '../../support/fragments/requests/requests';
import { FULFILMENT_PREFERENCES, REQUEST_LEVELS, REQUEST_TYPES } from '../../support/constants';
import RequestPolicy from '../../support/fragments/circulation/request-policy';
import UserLoans from '../../support/fragments/users/loans/userLoans';

describe('Circulation log', () => {
let userData;
let userForRequest;
const testData = {
folioInstances: InventoryInstances.generateFolioInstances(),
userServicePoint: ServicePoints.getDefaultServicePoint(),
userServicePoint: ServicePoints.getDefaultServicePointWithPickUpLocation(),
};
const loanPolicyBody = {
const nonLoanablePolicyBody = {
id: uuid(),
name: getTestEntityValue('nonLoanable'),
loanable: false,
renewable: false,
};
const loanablePolicySecBody = {
id: uuid(),
name: getTestEntityValue('Loanable'),
loanable: true,
loansPolicy: {
closedLibraryDueDateManagementId: 'CURRENT_DUE_DATE_TIME',
period: {
duration: 1,
intervalId: 'Minutes',
},
profileId: 'Rolling',
},
renewable: true,
renewalsPolicy: {
unlimited: true,
renewFromId: 'SYSTEM_DATE',
},
};
const requestPolicyBody = {
requestTypes: [REQUEST_TYPES.RECALL],
name: getTestEntityValue('recallForCL'),
id: uuid(),
};
const goToCircLogApp = (filterName) => {
cy.visit(TopMenu.circulationLogPath);
SearchPane.waitLoading();
SearchPane.setFilterOptionFromAccordion('loan', filterName);
SearchPane.searchByItemBarcode(testData.itemBarcode);
return SearchPane.findResultRowIndexByContent(filterName);
};
const checkActionsButton = (filterName) => {
goToCircLogApp(filterName).then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'Loan details');
LoansPage.waitLoading();
});
goToCircLogApp(filterName).then((rowIndex) => {
SearchResults.chooseActionByRow(rowIndex, 'User details');
Users.verifyFirstNameOnUserDetailsPane(userData.firstName);
});
goToCircLogApp(filterName).then((rowIndex) => {
SearchResults.clickOnCell(testData.itemBarcode, Number(rowIndex));
ItemRecordView.waitLoading();
});
};
const filterByAction = (filterName, desc) => {
const searchResultsData = {
userBarcode: userData.barcode,
Expand Down Expand Up @@ -59,67 +112,65 @@ describe('Circulation log', () => {
testData.defaultLocation = Locations.getDefaultLocation({
servicePointId: testData.userServicePoint.id,
}).location;
Locations.createViaApi(testData.defaultLocation).then((location) => {
InventoryInstances.createFolioInstancesViaApi({
folioInstances: testData.folioInstances,
location,
});
testData.itemBarcode = testData.folioInstances[0].barcodes[0];
});
cy.createLoanType({
name: getTestEntityValue('loan'),
})
.then((loanType) => {
testData.loanTypeId = loanType.id;
cy.getItems({
limit: 1,
expandAll: true,
query: `"barcode"=="${testData.itemBarcode}"`,
}).then((res) => {
res.permanentLoanType = { id: testData.loanTypeId };
cy.updateItemViaApi(res);
Locations.createViaApi(testData.defaultLocation)
.then((location) => {
InventoryInstances.createFolioInstancesViaApi({
folioInstances: testData.folioInstances,
location,
});
})
.then(() => {
LoanPolicy.createViaApi(loanPolicyBody);
CirculationRules.addRuleViaApi({ t: testData.loanTypeId }, { l: loanPolicyBody.id }).then(
(newRule) => {
testData.addedRule = newRule;
},
);
testData.itemBarcode = testData.folioInstances[0].barcodes[0];
testData.itemId = testData.folioInstances[0].itemIds[0];
testData.instanceId = testData.folioInstances[0].instanceId;
testData.holdingTypeId = testData.folioInstances[0].holdingId;
});
cy.createLoanType({
name: getTestEntityValue('loan'),
}).then((loanType) => {
testData.loanTypeId = loanType.id;
cy.getItems({
limit: 1,
expandAll: true,
query: `"barcode"=="${testData.itemBarcode}"`,
}).then((res) => {
res.permanentLoanType = { id: testData.loanTypeId };
cy.updateItemViaApi(res);
});
});
cy.createTempUser([permissions.circulationLogAll.gui])
.then((userProperties) => {
userData = userProperties;
})
.then(() => {
UserEdit.addServicePointViaApi(
testData.userServicePoint.id,
userData.userId,
testData.userServicePoint.id,
);
})
.then(() => {
Checkout.checkoutThroughOverrideViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
userBarcode: userData.barcode,
cy.createTempUser([permissions.requestsAll.gui]).then((userProperties) => {
userForRequest = userProperties;
UserEdit.addServicePointViaApi(
testData.userServicePoint.id,
userForRequest.userId,
testData.userServicePoint.id,
);
});
})
.then(() => {
cy.loginAsAdmin();
});
});

after('Deleting created entities', () => {
CirculationRules.deleteRuleViaApi(testData.addedRule);
cy.deleteLoanPolicy(loanPolicyBody.id);
CheckInActions.checkinItemViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
checkInDate: new Date().toISOString(),
});
Requests.deleteRequestViaApi(testData.requestsId);
UserEdit.changeServicePointPreferenceViaApi(userData.userId, [testData.userServicePoint.id]);
UserEdit.changeServicePointPreferenceViaApi(userForRequest.userId, [
testData.userServicePoint.id,
]);
ServicePoints.deleteViaApi(testData.userServicePoint.id);
Users.deleteViaApi(userData.userId);
Users.deleteViaApi(userForRequest.userId);
InventoryInstances.deleteInstanceViaApi({
instance: testData.folioInstances[0],
servicePoint: testData.userServicePoint,
Expand All @@ -129,11 +180,136 @@ describe('Circulation log', () => {
Locations.deleteViaApi(testData.defaultLocation);
});

it(
'C16982 Filter Circulation log by Checked out through override (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
filterByAction('Checked out through override', 'Checked out to proxy: no.');
},
);
describe('Non Loanable', () => {
before('Creating circulation rule', () => {
LoanPolicy.createViaApi(nonLoanablePolicyBody);
CirculationRules.addRuleViaApi(
{ t: testData.loanTypeId },
{ l: nonLoanablePolicyBody.id },
).then((newRule) => {
testData.addedRule = newRule;
});
Checkout.checkoutThroughOverrideViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
userBarcode: userData.barcode,
});
});

after('Deleting circulation rule', () => {
CirculationRules.deleteRuleViaApi(testData.addedRule);
cy.deleteLoanPolicy(nonLoanablePolicyBody.id);
CheckInActions.checkinItemViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
checkInDate: new Date().toISOString(),
});
});
it(
'C16995 Check the Actions button from filtering Circulation log by Checked out through override (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
checkActionsButton('Checked out through override');
},
);

it(
'C16982 Filter Circulation log by Checked out through override (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
filterByAction('Checked out through override', 'Checked out to proxy: no.');
},
);

it(
'C45935 Check the Actions button from filtering Circulation log by renewed through override (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
UserLoans.renewItemViaApi({
id: uuid(),
itemBarcode: testData.itemBarcode,
userBarcode: userData.barcode,
overrideBlocks: {
comment: getTestEntityValue('override-message'),
renewalDueDateRequiredBlock: { dueDate: moment().add(6, 'hours').format() },
},
servicePointId: testData.userServicePoint.id,
});
checkActionsButton('Renewed through override');
},
);
});

describe('Loanable', () => {
before('Creating circulation rule', () => {
LoanPolicy.createViaApi(loanablePolicySecBody);
RequestPolicy.createViaApi(requestPolicyBody);
CirculationRules.addRuleViaApi(
{ t: testData.loanTypeId },
{ l: loanablePolicySecBody.id, r: requestPolicyBody.id },
).then((newRule) => {
testData.addedRule = newRule;
});
Checkout.checkoutItemViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
userBarcode: userData.barcode,
});
});

after('Deleting circulation rule', () => {
CirculationRules.deleteRuleViaApi(testData.addedRule);
cy.deleteLoanPolicy(loanablePolicySecBody.id);
RequestPolicy.deleteViaApi(requestPolicyBody.id);
CheckInActions.checkinItemViaApi({
itemBarcode: testData.itemBarcode,
servicePointId: testData.userServicePoint.id,
checkInDate: new Date().toISOString(),
});
});

it(
'C17006 Check the Actions button from filtering Circulation log by renewed (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
UserLoans.renewItemViaApi({
id: uuid(),
itemBarcode: testData.itemBarcode,
userBarcode: userData.barcode,
});
checkActionsButton('Renewed');
},
);

it(
'C17004 Check the Actions button from filtering Circulation log by recall requested (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
Requests.createNewRequestViaApi({
fulfillmentPreference: FULFILMENT_PREFERENCES.HOLD_SHELF,
holdingsRecordId: testData.holdingTypeId,
instanceId: testData.instanceId,
item: { barcode: testData.itemBarcode },
itemId: testData.itemId,
pickupServicePointId: testData.userServicePoint.id,
requestDate: new Date(),
requestExpirationDate: new Date(new Date().getTime() + 86400000),
requestLevel: REQUEST_LEVELS.ITEM,
requestType: REQUEST_TYPES.RECALL,
requesterId: userForRequest.userId,
}).then((request) => {
testData.requestsId = request.body.id;
});
checkActionsButton('Recall requested');
},
);

it(
'C17003 Filter circulation log by recall requested (volaris)',
{ tags: [TestTypes.criticalPath, devTeams.volaris] },
() => {
filterByAction('Recall requested', 'New due date');
},
);
});
});