Back-end testing with graphQL
During my time at RoLo, I did have a couple of occasions to run tests against the back-end using mutations via graphQL playground. I’m unsure how much of this I can/should post without revealing a bunch about the databases, but here goes.
Admittedly, this was done outside of Cypress only because I didn’t know at the time that it was actually possible to include tests like this.
mutation {
updateOrder(
input: {
orderId: 15186,
refundInformation: [{
amount: 1,
cardBrand: null,
cardPayment: false,
last4: null,
ssChargeId: null,
notes: "change product",
}],
refundPayment: true,
groupOrderPayment: null,
reservations: [
{
reservationId: 26988,
type: "changeProduct",
startDate: "2022-02-25",
endDate: "2022-02-27",
quantity: "1",
xProductId: "879",
}
],
productQuestionAnswers: [],
addOns: [],
assignments: [],
orderItemsArray: [
{
xProductId: "879",
xRefTypeId: 3,
quantity: 1,
startDate: "2022-02-25",
endDate: "2022-02-27",
}
],
adminNotes:"TEST1",
noRefund: null
}
) {
error
success
}
}
Result
Another mutation:
mutation {
updateOrder(
input: {
orderId: 15188,
refundInformation: null,
refundPayment: false,
groupOrderPayment: {
isRefund: true,
amount: -10,
notes: "some update"
},
reservations: [
{
reservationId: "26990",
type: "changeProduct",
startDate: "2022-02-25",
endDate: "2022-02-27",
quantity: "1",
xProductId: "879",
xRefTypeId: 3,
}
],
productQuestionAnswers: [],
addOns: [],
assignments: [],
orderItemsArray: [
{
xProductId: "879",
xRefTypeId: 3,
quantity: 1,
startDate: "2022-02-25",
endDate: "2022-02-27",
}
],
adminNotes: "",
noRefund: null
}
) {
error
success
}
}
Result (billed to group)
And yet another…
mutation {
updateOrder(
input: {
orderId: 15187,
refundInformation: [{
amount: 5,
cardBrand: "VISA",
cardPayment: true,
last4: "4242",
ssChargeId: "ch_3KX4KSGhNUysQh7Y1wOEKWg4",
notes: "change product",
}],
refundPayment: true,
groupOrderPayment: null,
reservations: [
{
reservationId: "26989",
type: "changeProduct",
startDate: "2022-02-25",
endDate: "2022-02-27",
quantity: "1",
xProductId: "879",
xRefTypeId: 3,
}
],
productQuestionAnswers: [],
addOns: [],
assignments: [],
orderItemsArray: [
{
xProductId: "879",
xRefTypeId: 3,
quantity: 1,
startDate: "2022-02-25",
endDate: "2022-02-27",
}
],
adminNotes: "TEST",
noRefund: null
}
) {
error
success
}
}
Result
Here’s one with an up-charge when changing products to one that is more expensive:
mutation {
updateOrder(
input: {
orderId: 15241,
refundInformation: null,
refundPayment: false,
groupOrderPayment: null,
paymentInput: {
token: "",
description: "payment description",
saveCard: false,
selectedCard: "4242",
useCard: true,
adminId: "1004"
},
reservations: [
{
reservationId: "27093",
type: "changeProduct",
startDate: "2022-02-28",
endDate: "2022-03-01",
quantity: "1",
xProductId: "880",
xRefTypeId: 3,
}
],
productQuestionAnswers: [],
addOns: [],
assignments: [],
orderItemsArray: [
{
xProductId: "880",
xRefTypeId: 3,
quantity: 1,
startDate: "2022-02-23",
endDate: "2022-03-01",
}
],
adminNotes: "Up-charge test",
noRefund: null
}
) {
error
success
}
}
Result