Bug 40169: mockData - Do not replace _id if passed
If we build an object and pass a primary key (ie. suffixed by _id) we should not replace it. Test plan: The test highlights the problem, it won't affect existing tests. 0. Apply only the first patch (Cypress tests) 1. Run yarn cypress run t/cypress/integration/t/mockData.ts => It fails 2. Apply this patch => It passes Signed-off-by: David Nind <david@davidnind.com> Amended-by: Jonathan Druart Remove .only Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
ea703016d4
commit
0aaf193a75
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue