diff --git a/t/cypress/integration/t/mockData.ts b/t/cypress/integration/t/mockData.ts index 1d6d21df0a..33b20279c6 100644 --- a/t/cypress/integration/t/mockData.ts +++ b/t/cypress/integration/t/mockData.ts @@ -20,6 +20,16 @@ describe("Generate Random Patron", () => { ); }); }); + + it("should not overwrite _id if passed", () => { + const home_library_id = "LIB4TEST"; + cy.task("buildSampleObject", { + object: "item", + values: { home_library_id }, + }).then(mockItem => { + expect(mockItem.home_library_id).to.equal(home_library_id); + }); + }); }); describe("Generate Random Patrons", () => { diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js index 0f9c292df8..c2025abeeb 100644 --- a/t/cypress/plugins/mockData.js +++ b/t/cypress/plugins/mockData.js @@ -74,7 +74,10 @@ const generateDataFromSchema = (properties, values = {}) => { }); Object.keys(ids).forEach(k => { - if (mockData.hasOwnProperty(k + "_id")) { + if ( + mockData.hasOwnProperty(k + "_id") && + !values.hasOwnProperty(k + "_id") + ) { mockData[k + "_id"] = ids[k]; } });