add logs for failed mutations (#2078)

This commit is contained in:
Karolina Rakoczy 2022-06-06 10:47:39 +02:00 committed by GitHub
parent 8d361293c5
commit 6c7f6fc016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 58 additions and 50 deletions

View file

@ -120,9 +120,9 @@ filterTests({ definedTags: ["all", "refactored"] }, () => {
.then(() => {
addPayment(checkout.id);
})
.then(({ paymentErrors }) => {
.then(({ errors }) => {
expect(
paymentErrors,
errors,
"Should be not possible to add payment without shipping"
).to.have.lengthOf(1);
updateShippingInCheckout(checkout.token, shippingMethod.name);

View file

@ -1,6 +1,8 @@
/// <reference types="cypress"/>
/// <reference types="../../support"/>
import faker from "faker";
import { PRODUCT_DETAILS } from "../../elements/catalog/products/product-details";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
@ -24,7 +26,7 @@ import {
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
describe("Creating variants in preorder", () => {
const startsWith = "CreatePreOrder";
const name = `CreatePreOrder${faker.datatype.number()}`;
const attributeValues = ["value1", "value2", "value3"];
const threshold = 100;
const futureDate = new Date().setDate(new Date().getDate() + 14);
@ -38,19 +40,17 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
createProductWithShipping({ name: startsWith, attributeValues }).then(
resp => {
checkoutData = {
address: resp.address,
channelSlug: resp.defaultChannel.slug,
email: "example@example.com",
shippingMethodName: resp.shippingMethod.name
};
defaultChannel = resp.defaultChannel;
product = resp.product;
variantsList = resp.variantsList;
}
);
createProductWithShipping({ name, attributeValues }).then(resp => {
checkoutData = {
address: resp.address,
channelSlug: resp.defaultChannel.slug,
email: "example@example.com",
shippingMethodName: resp.shippingMethod.name
};
defaultChannel = resp.defaultChannel;
product = resp.product;
variantsList = resp.variantsList;
});
});
beforeEach(() => {

View file

@ -59,7 +59,7 @@ export function getAttributes(first, search) {
export function deleteAttribute(attributeId) {
const mutation = `mutation{
attributeDelete(id:"${attributeId}"){
attributeErrors{
errors{
field
message
}

View file

@ -7,7 +7,7 @@ export function createCategory({ name, slug = name, parent }) {
const parentLine = getValueWithDefault(parent, `parent:"${parent}"`);
const mutation = `mutation{
categoryCreate(input:{name:"${name}", slug: "${slug}"} ${parentLine}){
productErrors{
errors{
field
message
}
@ -78,7 +78,7 @@ export function getCategories(first, search) {
export function deleteCategory(categoryId) {
const mutation = `mutation{
categoryDelete(id:"${categoryId}"){
productErrors{
errors{
field
message
}

View file

@ -50,7 +50,7 @@ export function deleteChannel(channelId, targetChannelId) {
channel{
name
}
channelErrors{
errors{
message
}
}

View file

@ -126,7 +126,7 @@ export function addPayment({ checkoutId, gateway, token, amount }) {
${amountLine}
returnUrl: "https://qa.storefront.staging.saleor.cloud/checkout/payment-confirm"
}){
paymentErrors{
errors{
field
message
}

View file

@ -4,7 +4,7 @@ export function createCollection(name, slug = name) {
name:"${name}",
slug:"${name}"
}){
collectionErrors{
errors{
field
message
}
@ -46,7 +46,7 @@ export function deleteCollection(collectionId) {
collection{
id
}
collectionErrors{
errors{
field
message
}

View file

@ -23,7 +23,7 @@ export function createCustomer(email, customerName, address, isActive = false) {
id
email
}
accountErrors{
errors{
code
message
}
@ -48,7 +48,7 @@ export function deleteCustomersStartsWith(startsWith) {
export function deleteCustomer(customerId) {
const mutation = `mutation{
customerDelete(id:"${customerId}"){
accountErrors{
errors{
code
message
}

View file

@ -29,7 +29,7 @@ export function getSales(first, searchQuery) {
export function deleteSale(saleId) {
const mutation = `mutation{
saleDelete(id:"${saleId}"){
discountErrors{
errors{
field
message
}

View file

@ -21,7 +21,7 @@ export function getVouchers(first, startsWith) {
export function deleteVouchers(voucherId) {
const mutation = `mutation deleteVouchers{
voucherDelete(id:"${voucherId}"){
discountErrors{
errors{
field
message
}

View file

@ -3,7 +3,7 @@ import { getDefaultAddress, getValueWithDefault } from "./utils/Utils";
export function markOrderAsPaid(orderId) {
const mutation = `mutation{
orderMarkAsPaid(id:"${orderId}"){
orderErrors{
errors{
message
}
}
@ -31,7 +31,7 @@ export function addProductToOrder(orderId, variantId, quantity = 1) {
quantity:${quantity}
variantId: "${variantId}"
}){
orderErrors{
errors{
message
}
}

View file

@ -33,7 +33,7 @@ export function getFirstProducts(first, search) {
export function updateProduct(productId, input) {
const mutation = `mutation {
productUpdate(id:"${productId}", input:${stringify(input)} ){
productErrors{
errors{
field
message
}
@ -85,7 +85,7 @@ export function updateChannelPriceInVariant(variantId, channelId) {
price: 10
costPrice: 10
}){
productChannelListingErrors{
errors{
message
}
}
@ -133,7 +133,7 @@ export function createProduct({
id
name
}
productErrors{
errors{
field
message
}
@ -218,7 +218,7 @@ export function createVariant({
export function deleteProduct(productId) {
const mutation = `mutation{
productDelete(id: "${productId}"){
productErrors{
errors{
field
message
}

View file

@ -66,7 +66,7 @@ export function getProductTypes(first, search) {
export function deleteProductType(productTypeId) {
const mutation = `mutation{
productTypeDelete(id:"${productTypeId}"){
productErrors{
errors{
field
message
}

View file

@ -68,7 +68,7 @@ export function addChannelToShippingZone(shippingZoneId, channelId) {
shippingZoneUpdate(id:"${shippingZoneId}", input:{
addChannels:["${channelId}"]
}){
shippingErrors{
errors{
field
message
}
@ -106,7 +106,7 @@ export function addChannelToShippingMethod(
export function deleteShippingZone(shippingZoneId) {
const mutation = `mutation{
shippingZoneDelete(id:"${shippingZoneId}"){
shippingErrors{
errors{
message
}
}

View file

@ -12,7 +12,7 @@ export function createWarehouse({ name, shippingZone, address, slug = name }) {
${shippingZoneLine}
${getDefaultAddress(address, "address", false)}
}){
warehouseErrors{
errors{
field
message
}
@ -48,7 +48,7 @@ export function getWarehouses(first, search) {
export function deleteWarehouse(warehouseId) {
const mutation = `mutation{
deleteWarehouse(id:"${warehouseId}"){
warehouseErrors{
errors{
field
message
}

View file

@ -23,7 +23,7 @@ Cypress.Commands.add(
token
csrfToken
refreshToken
errors: accountErrors {
errors: errors {
code
field
message

View file

@ -46,17 +46,25 @@ Cypress.Commands.add("addAliasToGraphRequest", operationName => {
Cypress.Commands.add(
"sendRequestWithQuery",
(query, authorization = "auth", variables = "") =>
cy.request({
body: {
variables,
query
},
headers: {
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`
},
method: "POST",
url: urlList.apiUri
})
cy
.request({
body: {
variables,
query
},
headers: {
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`
},
method: "POST",
url: urlList.apiUri,
log: true
})
.then(response => {
const respInSting = JSON.stringify(response.body);
if (respInSting.includes(`"errors":[{`)) {
cy.log(query).log(JSON.stringify(response.body));
}
})
);
Cypress.on(
"uncaught:exception",