Fix should make a refund 2107 (#2950)
* get/update taxes for tests * update creating shipping and product of tax class
This commit is contained in:
parent
91478a8b6d
commit
d695bb9aa6
7 changed files with 122 additions and 1 deletions
|
@ -28,6 +28,10 @@ import {
|
|||
createShipping,
|
||||
deleteShippingStartsWith,
|
||||
} from "../../support/api/utils/shippingUtils";
|
||||
import {
|
||||
getDefaultTaxClass,
|
||||
updateTaxConfigurationForChannel,
|
||||
} from "../../support/api/utils/taxesUtils";
|
||||
import { selectChannelInPicker } from "../../support/pages/channelsPage";
|
||||
import { finalizeDraftOrder } from "../../support/pages/draftOrderPage";
|
||||
|
||||
|
@ -41,6 +45,7 @@ describe("Orders", () => {
|
|||
let shippingMethod;
|
||||
let variantsList;
|
||||
let address;
|
||||
let taxClass;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
|
@ -52,8 +57,11 @@ describe("Orders", () => {
|
|||
getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
updateTaxConfigurationForChannel({ channelSlug: defaultChannel.slug });
|
||||
getDefaultTaxClass();
|
||||
})
|
||||
.then(() => {
|
||||
.then(resp => {
|
||||
taxClass = resp;
|
||||
cy.fixture("addresses");
|
||||
})
|
||||
.then(addresses => {
|
||||
|
@ -66,6 +74,7 @@ describe("Orders", () => {
|
|||
channelId: defaultChannel.id,
|
||||
name: randomName,
|
||||
address,
|
||||
taxClassId: taxClass.id,
|
||||
});
|
||||
})
|
||||
.then(
|
||||
|
@ -90,6 +99,7 @@ describe("Orders", () => {
|
|||
productTypeId: productTypeResp.id,
|
||||
attributeId: attributeResp.id,
|
||||
categoryId: categoryResp.id,
|
||||
taxClassId: taxClass.id,
|
||||
});
|
||||
},
|
||||
)
|
||||
|
|
|
@ -102,6 +102,7 @@ export function createProduct({
|
|||
categoryId,
|
||||
collectionId,
|
||||
description,
|
||||
taxClassId,
|
||||
}) {
|
||||
const collection = getValueWithDefault(
|
||||
collectionId,
|
||||
|
@ -120,6 +121,11 @@ export function createProduct({
|
|||
${attributeValuesLine}
|
||||
}]`,
|
||||
);
|
||||
const selectedTaxClass = getValueWithDefault(
|
||||
taxClassId,
|
||||
`taxClass: "${taxClassId}"`,
|
||||
`taxClass: ""`,
|
||||
);
|
||||
const mutation = `mutation createProduct${descriptionData.mutationVariables}{
|
||||
productCreate(input:{
|
||||
${attributes}
|
||||
|
@ -130,6 +136,7 @@ export function createProduct({
|
|||
${category}
|
||||
${collection}
|
||||
${descriptionData.descriptionLine}
|
||||
${selectedTaxClass}
|
||||
}){
|
||||
product{
|
||||
id
|
||||
|
|
|
@ -6,6 +6,7 @@ export function createShippingRate({
|
|||
type = "PRICE",
|
||||
maxWeight,
|
||||
minWeight,
|
||||
taxClassId,
|
||||
}) {
|
||||
const maxOrderWeight = getValueWithDefault(
|
||||
maxWeight,
|
||||
|
@ -16,6 +17,12 @@ export function createShippingRate({
|
|||
`minimumOrderWeight: ${minWeight}`,
|
||||
);
|
||||
|
||||
const selectedTaxClass = getValueWithDefault(
|
||||
taxClassId,
|
||||
`taxClass: "${taxClassId}"`,
|
||||
`taxClass: ""`,
|
||||
);
|
||||
|
||||
const mutation = `mutation{
|
||||
shippingPriceCreate(input:{
|
||||
name: "${name}"
|
||||
|
@ -23,6 +30,7 @@ export function createShippingRate({
|
|||
type: ${type}
|
||||
${minOrderWeight}
|
||||
${maxOrderWeight}
|
||||
${selectedTaxClass}
|
||||
}){
|
||||
shippingMethod{
|
||||
id
|
||||
|
|
59
cypress/support/api/requests/Taxes.js
Normal file
59
cypress/support/api/requests/Taxes.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
export function getTaxConfigurationList() {
|
||||
const query = `query{
|
||||
taxConfigurations(first:100){
|
||||
edges{
|
||||
node{
|
||||
id
|
||||
channel{
|
||||
id
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return cy
|
||||
.sendRequestWithQuery(query)
|
||||
.then(resp => resp.body.data.taxConfigurations.edges);
|
||||
}
|
||||
|
||||
export function updateTaxes({
|
||||
id,
|
||||
chargeTaxes = true,
|
||||
taxCalculationStrategy = "FLAT_RATES",
|
||||
}) {
|
||||
const mutation = `mutation{
|
||||
taxConfigurationUpdate(id:"${id}", input:{
|
||||
chargeTaxes:${chargeTaxes}
|
||||
displayGrossPrices:true
|
||||
pricesEnteredWithTax:false
|
||||
removeCountriesConfiguration: []
|
||||
taxCalculationStrategy:${taxCalculationStrategy}
|
||||
updateCountriesConfiguration: []
|
||||
}){
|
||||
errors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function getTaxClassList() {
|
||||
const query = `query{
|
||||
taxClasses(first:100){
|
||||
edges{
|
||||
node{
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return cy
|
||||
.sendRequestWithQuery(query)
|
||||
.then(resp => resp.body.data.taxClasses.edges);
|
||||
}
|
|
@ -35,6 +35,7 @@ export function createProductInChannel({
|
|||
trackInventory = true,
|
||||
weight = 1,
|
||||
sku = name,
|
||||
taxClassId,
|
||||
}) {
|
||||
let product;
|
||||
let variantsList;
|
||||
|
@ -49,6 +50,7 @@ export function createProductInChannel({
|
|||
visibleInListings,
|
||||
collectionId,
|
||||
description,
|
||||
taxClassId,
|
||||
})
|
||||
.then(productResp => {
|
||||
product = productResp;
|
||||
|
@ -263,6 +265,7 @@ export function createProductInChannelWithoutVariants({
|
|||
visibleInListings = true,
|
||||
collectionId = null,
|
||||
description = null,
|
||||
taxClassId,
|
||||
}) {
|
||||
let product;
|
||||
return productRequest
|
||||
|
@ -273,6 +276,7 @@ export function createProductInChannelWithoutVariants({
|
|||
categoryId,
|
||||
collectionId,
|
||||
description,
|
||||
taxClassId,
|
||||
})
|
||||
.then(productResp => {
|
||||
product = productResp;
|
||||
|
|
|
@ -9,6 +9,7 @@ export function createShipping({
|
|||
address,
|
||||
price = 1,
|
||||
minProductPrice = 0,
|
||||
taxClassId,
|
||||
}) {
|
||||
let shippingMethod;
|
||||
let shippingZone;
|
||||
|
@ -31,6 +32,7 @@ export function createShipping({
|
|||
shippingMethodRequest.createShippingRate({
|
||||
name,
|
||||
shippingZone: shippingZone.id,
|
||||
taxClassId,
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
31
cypress/support/api/utils/taxesUtils.js
Normal file
31
cypress/support/api/utils/taxesUtils.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {
|
||||
getTaxClassList,
|
||||
getTaxConfigurationList,
|
||||
updateTaxes,
|
||||
} from "../requests/Taxes";
|
||||
|
||||
export function updateTaxConfigurationForChannel({
|
||||
channelSlug,
|
||||
chargeTaxes = true,
|
||||
taxCalculationStrategy = "FLAT_RATES",
|
||||
}) {
|
||||
getTaxConfigurationList().then(taxConfigurationList => {
|
||||
const taxConfigurationForChannel = taxConfigurationList.find(
|
||||
taxConfiguration => taxConfiguration.node.channel.slug === channelSlug,
|
||||
);
|
||||
updateTaxes({
|
||||
id: taxConfigurationForChannel.node.id,
|
||||
chargeTaxes,
|
||||
taxCalculationStrategy,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getDefaultTaxClass() {
|
||||
getTaxClassList().then(taxClassArray => {
|
||||
const taxClass = taxClassArray.find(
|
||||
taxClassItem => taxClassItem.node.name === "No Taxes",
|
||||
);
|
||||
return taxClass.node;
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue