Bug 40345: Pass a patron to insertSampleCheckout
So we won't generate a new patron per checkout
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 96bb7116b0)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
50961ff2fc
commit
9ef3760c8a
|
|
@ -230,6 +230,41 @@ describe("insertData", () => {
|
|||
cy.task("deleteSampleObjects", objects_checkout);
|
||||
});
|
||||
});
|
||||
|
||||
it("insertSampleCheckout - pass an already generated patron", () => {
|
||||
cy.task("buildSampleObject", {
|
||||
object: "patron",
|
||||
values: {
|
||||
incorrect_address: null,
|
||||
patron_card_lost: null,
|
||||
},
|
||||
}).then(generatedPatron => {
|
||||
cy.task("insertObject", {
|
||||
type: "patron",
|
||||
object: generatedPatron,
|
||||
}).then(patron => {
|
||||
cy.task("insertSampleCheckout", { patron }).then(
|
||||
objects_checkout => {
|
||||
expect(objects_checkout.patron).to.not.exists;
|
||||
cy.task("apiGet", {
|
||||
endpoint: `/api/v1/checkouts/${objects_checkout.checkout.checkout_id}`,
|
||||
}).then(checkout => {
|
||||
expect(checkout.item_id).to.be.equal(
|
||||
objects_checkout.items[0].item_id
|
||||
);
|
||||
expect(checkout.patron_id).to.be.equal(
|
||||
generatedPatron.patron_id
|
||||
);
|
||||
});
|
||||
cy.task("deleteSampleObjects", [
|
||||
objects_checkout,
|
||||
{ patron },
|
||||
]);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
|
|||
|
|
@ -205,29 +205,31 @@ const insertSampleHold = async ({
|
|||
return { hold, patron };
|
||||
};
|
||||
|
||||
const insertSampleCheckout = async ({ baseUrl, authHeader }) => {
|
||||
const insertSampleCheckout = async ({ patron, baseUrl, authHeader }) => {
|
||||
const { biblio, items, libraries, item_type } = await insertSampleBiblio({
|
||||
item_count: 1,
|
||||
baseUrl,
|
||||
authHeader,
|
||||
});
|
||||
const generatedPatron = await buildSampleObject({
|
||||
object: "patron",
|
||||
values: {
|
||||
library_id: libraries[0].library_id,
|
||||
incorrect_address: null,
|
||||
patron_card_lost: null,
|
||||
},
|
||||
baseUrl,
|
||||
authHeader,
|
||||
});
|
||||
|
||||
const patron = await insertObject({
|
||||
type: "patron",
|
||||
object: generatedPatron,
|
||||
baseUrl,
|
||||
authHeader,
|
||||
});
|
||||
let generatedPatron;
|
||||
if (!patron) {
|
||||
generatedPatron = await buildSampleObject({
|
||||
object: "patron",
|
||||
values: {
|
||||
library_id: libraries[0].library_id,
|
||||
incorrect_address: null,
|
||||
patron_card_lost: null,
|
||||
},
|
||||
});
|
||||
|
||||
patron = await insertObject({
|
||||
type: "patron",
|
||||
object: generatedPatron,
|
||||
baseUrl,
|
||||
authHeader,
|
||||
});
|
||||
}
|
||||
|
||||
const generatedCheckout = buildSampleObject({
|
||||
object: "checkout",
|
||||
|
|
@ -243,7 +245,15 @@ const insertSampleCheckout = async ({ baseUrl, authHeader }) => {
|
|||
baseUrl,
|
||||
authHeader,
|
||||
});
|
||||
return { biblio, items, libraries, item_type, patron, checkout };
|
||||
return {
|
||||
biblio,
|
||||
items,
|
||||
libraries,
|
||||
item_type,
|
||||
patron,
|
||||
checkout,
|
||||
...(generatedPatron ? { patron: generatedPatron } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
const deleteSampleObjects = async allObjects => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue