saleor-dashboard/cypress/utils/shippingUtils.js
Karolina Rakoczy 75d85e66cb
test for product without shipping option (#1154)
* test for product without shipping option

* fix broken tests
2021-07-06 12:33:04 +02:00

57 lines
1.5 KiB
JavaScript

import * as shippingMethodRequest from "../apiRequests/ShippingMethod";
import * as warehouseRequest from "../apiRequests/Warehouse";
export function createShipping({
channelId,
name,
address,
price = 1,
minProductPrice = 0
}) {
let shippingMethod;
let shippingZone;
let warehouse;
return shippingMethodRequest
.createShippingZone(name, address.country, channelId)
.then(shippingZoneResp => {
shippingZone = shippingZoneResp;
warehouseRequest.createWarehouse({
name,
shippingZone: shippingZone.id,
address
});
})
.then(warehouseResp => {
warehouse = warehouseResp;
createShippingRate({ name, shippingZoneId: shippingZone.id });
})
.then(sippingMethodResp => {
shippingMethod = sippingMethodResp;
shippingMethodRequest.addChannelToShippingMethod(
shippingMethod.id,
channelId,
price,
minProductPrice
);
})
.then(() => ({ shippingMethod, shippingZone, warehouse }));
}
export function createShippingRate({ name, shippingZoneId }) {
return shippingMethodRequest
.createShippingRate({ name, shippingZoneId })
.its("body.data.shippingPriceCreate.shippingMethod");
}
export function deleteShippingStartsWith(startsWith) {
cy.deleteElementsStartsWith(
shippingMethodRequest.deleteShippingZone,
shippingMethodRequest.getShippingZones,
startsWith
);
cy.deleteElementsStartsWith(
warehouseRequest.deleteWarehouse,
warehouseRequest.getWarehouses,
startsWith
);
}