saleor-dashboard/cypress/support/api/requests/utils/Utils.js
Karolina Rakoczy 2c64a966cc
Saleor 4437 refactor tests (#1389)
* reference type cypress working

* refactor

* remove screenshots

* add reference

* add slash marker

* run tests based on shop version

* fix run tests based on shop version

* fix run tests based on shop version

* change base url to localhost

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix yml

* fix yml

* chage file names

* fix files names

* fix broken imports add checking for errors in grpah responses

* fix broken imports add checking for errors in grpah responses

* update jest

* fix snapshot
2021-09-27 12:04:21 +02:00

37 lines
1.5 KiB
JavaScript

export const getValueWithDefault = (condition, value, defaultValue = "") =>
condition ? value : defaultValue;
export function getDefaultAddress(address, addressType, withName = true) {
if (!address) {
return "";
}
const defaultAddress = `city: "${address.city}"
country: ${address.country}
countryArea: "${address.countryArea}"
phone: "${address.phone}"
postalCode: "${address.postalCode}"
streetAddress1: "${address.streetAddress1}"
streetAddress2: "${address.streetAddress2}"`;
if (withName) {
defaultAddress.concat(`firstName: "Test"
lastName: "Test"
companyName: "${address.companyName}"`);
}
return `${addressType}:{${defaultAddress}}`;
}
export function getVariantsLines(variantsList, quantity) {
return variantsList.map(
variant => `{quantity:${quantity}
variantId:"${variant.id}"}`
);
}
export function getVariantsListIds(variantsList) {
return variantsList.map(variant => `"${variant.id}"`).join();
}
export const getPaymentDataLine = paymentData =>
paymentData
? `, paymentData:"{\\"riskData\\":{\\"clientData\\":\\"${paymentData.clientData}\\"}, \\"paymentMethod\\":{\\"type\\":\\"scheme\\", \\"encryptedCardNumber\\":\\"${paymentData.encryptedCardNumber}\\", \\"encryptedExpiryMonth\\":\\"${paymentData.encryptedExpiryMonth}\\", \\"encryptedExpiryYear\\":\\"${paymentData.encryptedExpiryYear}\\", \\"encryptedSecurityCode\\":\\"${paymentData.encryptedSecurityCode}\\", \\"brand\\":\\"${paymentData.brand}\\"}}"`
: "";