From 682b5468c6b5bc8e64ec4929d862a7e210c82e1b Mon Sep 17 00:00:00 2001 From: Dmitriy-Litvinenko Date: Fri, 27 Feb 2026 20:56:03 +0200 Subject: [PATCH] FAT-23690: Fix unstable tests --- cypress/e2e/checkout/checkout.basic.cy.js | 44 +++++++++++++++++++ .../check-out-actions/check-out-actions.js | 7 ++- .../support/fragments/requests/newRequest.js | 1 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/checkout/checkout.basic.cy.js b/cypress/e2e/checkout/checkout.basic.cy.js index 237626cbc5..17068b117a 100644 --- a/cypress/e2e/checkout/checkout.basic.cy.js +++ b/cypress/e2e/checkout/checkout.basic.cy.js @@ -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 = ''; @@ -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({ @@ -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( diff --git a/cypress/support/fragments/check-out-actions/check-out-actions.js b/cypress/support/fragments/check-out-actions/check-out-actions.js index e820a04aae..d8daef3691 100644 --- a/cypress/support/fragments/check-out-actions/check-out-actions.js +++ b/cypress/support/fragments/check-out-actions/check-out-actions.js @@ -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()); @@ -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(), ]); }, diff --git a/cypress/support/fragments/requests/newRequest.js b/cypress/support/fragments/requests/newRequest.js index 306a709496..99fe67f085 100644 --- a/cypress/support/fragments/requests/newRequest.js +++ b/cypress/support/fragments/requests/newRequest.js @@ -55,6 +55,7 @@ function addRequester(userName) { function openNewRequestPane() { cy.do([actionsButton.click(), newRequestButton.click()]); + cy.wait(10000); } function openNewMediatedRequestPane() {