Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions cypress/e2e/checkout/checkout.basic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ 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';
import OtherSettings from '../../support/fragments/settings/circulation/otherSettings';

describe('Check out', () => {
const patronGroup = getTestEntityValue('staff');
const USER_NAME = 'username';
const getPrefPatronIdentifier = (otherSettings) => otherSettings.body.circulationSettings[0]?.value?.prefPatronIdentifier || '';
let shouldRemoveUserNameAfterTest = false;
let userData = {};
let patronGroupId = '';

Expand Down Expand Up @@ -45,6 +49,23 @@ describe('Check out', () => {
PatronGroups.createViaApi(patronGroup).then((patronGroupResponse) => {
patronGroupId = patronGroupResponse;
});
// Fetching the current "Other settings" values.
// Checking if "Patron id(s) for checkout scanning" is enabled by "Username".
// Enabling it if not already enabled.
OtherSettings.getOtherSettingsViaApi().then((otherSettingsResp) => {
const prefPatronIdentifier = getPrefPatronIdentifier(otherSettingsResp);

if (!prefPatronIdentifier.includes(USER_NAME)) {
shouldRemoveUserNameAfterTest = true;
const updatedValue = prefPatronIdentifier
? `${prefPatronIdentifier},${USER_NAME}`
: USER_NAME;

OtherSettings.setOtherSettingsViaApi({
prefPatronIdentifier: updatedValue,
});
}
});
})
.then(() => {
InventoryInstances.createFolioInstanceViaApi({
Expand Down Expand Up @@ -107,6 +128,29 @@ describe('Check out', () => {
InventoryInstances.deleteInstanceAndHoldingRecordAndAllItemsViaApi(itemData.barcode);
Users.deleteViaApi(userData.userId);
PatronGroups.deleteViaApi(patronGroupId);
// Fetching the current "Other settings" values.
// Checking if "Patron id(s) for checkout scanning" is enabled by "Username".
// Verifying that it was enabled earlier.
// Ensuring that "Username" is not the only enabled value, since at least one value is required.
// Disabling "Username" if appropriate.
OtherSettings.getOtherSettingsViaApi().then((otherSettingsResp) => {
const prefPatronIdentifier = getPrefPatronIdentifier(otherSettingsResp);

if (
shouldRemoveUserNameAfterTest &&
prefPatronIdentifier.includes(USER_NAME) &&
prefPatronIdentifier !== USER_NAME
) {
const updatedValue = prefPatronIdentifier
.split(',')
.filter((id) => id !== USER_NAME)
.join(',');

OtherSettings.setOtherSettingsViaApi({
prefPatronIdentifier: updatedValue,
});
}
});
});

it(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
},

checkOutItem(itemBarcode) {
cy.wait(1000);
cy.do(TextField('Item ID').fillIn(itemBarcode));
cy.wait(1000);
cy.do(Pane('Scan items').find(Button('Enter')).click());
Expand All @@ -86,9 +87,11 @@ export default {
cy.expect([
MultiColumnList({ rowCount: 1 }).find(MultiColumnListCell('1')).exists(),
MultiColumnList({ rowCount: 1 })
.find(MultiColumnListCell(`Barcode${itemBarcode}`))
.find(MultiColumnListCell({ content: including(itemBarcode) }))
.exists(),
MultiColumnList({ rowCount: 1 })
.find(MultiColumnListCell({ content: including(instanceTitle) }))
.exists(),
MultiColumnList({ rowCount: 1 }).find(MultiColumnListCell(instanceTitle)).exists(),
Label('Total items scanned: 1').exists(),
]);
},
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 @@ -55,6 +55,7 @@ function addRequester(userName) {

function openNewRequestPane() {
cy.do([actionsButton.click(), newRequestButton.click()]);
cy.wait(10000);
}

function openNewMediatedRequestPane() {
Expand Down
Loading