Saleor 1741 tests for orders (#1011)
* first test for draft orders * tests for channels in draft orders * tests for channels in draft orders * tests for channels in draft orders * test for moving draft order to orders * test for orders * test for orders * tests for draft orders * tests for draft orders * tests for draft orders * tests for draft orders * test for moving draft order * tests for orders
This commit is contained in:
parent
824f1cdb9e
commit
f8d5593fc3
6 changed files with 160 additions and 5 deletions
|
@ -35,6 +35,7 @@ export function createDraftOrder(customerId, shippingMethodId, channelId) {
|
||||||
}
|
}
|
||||||
order{
|
order{
|
||||||
id
|
id
|
||||||
|
number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export const ORDERS_SELECTORS = {
|
export const ORDERS_SELECTORS = {
|
||||||
orders: "[data-test='submenu-item-label'][data-test-id='orders']",
|
orders: "[data-test='submenu-item-label'][data-test-id='orders']",
|
||||||
createOrder: "[data-test-id='create-order-button']",
|
createOrder: "[data-test-id='create-order-button']",
|
||||||
orderRow: "[data-test-id='order-table-row']"
|
orderRow: "[data-test-id='order-table-row']",
|
||||||
|
salesChannel: "[data-test-id='order-sales-channel']"
|
||||||
};
|
};
|
||||||
|
|
116
cypress/integration/orders/orders.js
Normal file
116
cypress/integration/orders/orders.js
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createCustomer,
|
||||||
|
deleteCustomersStartsWith
|
||||||
|
} from "../../apiRequests/Customer";
|
||||||
|
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
|
||||||
|
import { selectChannelInPicker } from "../../steps/channelsSteps";
|
||||||
|
import { finalizeDraftOrder } from "../../steps/draftOrderSteps";
|
||||||
|
import { urlList } from "../../url/urlList";
|
||||||
|
import { getDefaultChannel } from "../../utils/channelsUtils";
|
||||||
|
import { createOrder } from "../../utils/ordersUtils";
|
||||||
|
import * as productsUtils from "../../utils/productsUtils";
|
||||||
|
import {
|
||||||
|
createShipping,
|
||||||
|
deleteShippingStartsWith
|
||||||
|
} from "../../utils/shippingUtils";
|
||||||
|
|
||||||
|
describe("Orders", () => {
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const randomName = startsWith + faker.random.number();
|
||||||
|
|
||||||
|
let customer;
|
||||||
|
let defaultChannel;
|
||||||
|
let warehouse;
|
||||||
|
let shippingMethod;
|
||||||
|
let variantsList;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteCustomersStartsWith(startsWith);
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
let address;
|
||||||
|
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
address = addresses.plAddress;
|
||||||
|
createCustomer(`${randomName}@example.com`, randomName, address, true);
|
||||||
|
})
|
||||||
|
.then(customerResp => {
|
||||||
|
customer = customerResp.body.data.customerCreate.user;
|
||||||
|
createShipping({
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
name: randomName,
|
||||||
|
address
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
productType: productTypeResp,
|
||||||
|
attribute: attributeResp,
|
||||||
|
category: categoryResp
|
||||||
|
}) => {
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: randomName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
productTypeId: productTypeResp.id,
|
||||||
|
attributeId: attributeResp.id,
|
||||||
|
categoryId: categoryResp.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(({ variants: variantsResp }) => {
|
||||||
|
variantsList = variantsResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create order with selected channel", () => {
|
||||||
|
cy.visit(urlList.orders)
|
||||||
|
.get(ORDERS_SELECTORS.createOrder)
|
||||||
|
.click();
|
||||||
|
selectChannelInPicker(defaultChannel.name);
|
||||||
|
finalizeDraftOrder(randomName).then(draftOrderNumber => {
|
||||||
|
cy.visit(urlList.orders);
|
||||||
|
cy.contains(ORDERS_SELECTORS.orderRow, draftOrderNumber).click();
|
||||||
|
cy.contains(ORDERS_SELECTORS.salesChannel, defaultChannel.name).should(
|
||||||
|
"be.visible"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should not be possible to change channel in order", () => {
|
||||||
|
createOrder({
|
||||||
|
customerId: customer.id,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
shippingMethodId: shippingMethod.id,
|
||||||
|
variantsList
|
||||||
|
}).then(order => {
|
||||||
|
cy.visit(urlList.orders);
|
||||||
|
cy.contains(ORDERS_SELECTORS.orderRow, order.number).click();
|
||||||
|
cy.get(ORDERS_SELECTORS.salesChannel)
|
||||||
|
.find("[button]")
|
||||||
|
.should("not.exist");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -27,13 +27,34 @@ export function createReadyToFulfillOrder(
|
||||||
return createDraftOrder(customerId, shippingMethodId, channelId)
|
return createDraftOrder(customerId, shippingMethodId, channelId)
|
||||||
.then(orderResp => {
|
.then(orderResp => {
|
||||||
order = orderResp;
|
order = orderResp;
|
||||||
variantsList.forEach(variantElement => {
|
assignVariantsToOrder(order, variantsList);
|
||||||
orderRequest.addProductToOrder(order.id, variantElement.id);
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then(() => orderRequest.markOrderAsPaid(order.id))
|
.then(() => orderRequest.markOrderAsPaid(order.id))
|
||||||
.then(() => orderRequest.completeOrder(order.id));
|
.then(() => orderRequest.completeOrder(order.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createOrder({
|
||||||
|
customerId,
|
||||||
|
shippingMethodId,
|
||||||
|
channelId,
|
||||||
|
variantsList
|
||||||
|
}) {
|
||||||
|
let order;
|
||||||
|
return createDraftOrder(customerId, shippingMethodId, channelId)
|
||||||
|
.then(orderResp => {
|
||||||
|
order = orderResp;
|
||||||
|
assignVariantsToOrder(order, variantsList);
|
||||||
|
})
|
||||||
|
.then(() => orderRequest.completeOrder(order.id))
|
||||||
|
.then(() => order);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assignVariantsToOrder(order, variantsList) {
|
||||||
|
variantsList.forEach(variantElement => {
|
||||||
|
orderRequest.addProductToOrder(order.id, variantElement.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function createDraftOrder(customerId, shippingMethodId, channelId) {
|
export function createDraftOrder(customerId, shippingMethodId, channelId) {
|
||||||
return orderRequest
|
return orderRequest
|
||||||
.createDraftOrder(customerId, shippingMethodId, channelId)
|
.createDraftOrder(customerId, shippingMethodId, channelId)
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const OrderChannelSectionCard: React.FC<OrderChannelSectionCardProps> = (
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card data-test-id="order-sales-channel">
|
||||||
<CardTitle
|
<CardTitle
|
||||||
title={intl.formatMessage({
|
title={intl.formatMessage({
|
||||||
defaultMessage: "Sales channel",
|
defaultMessage: "Sales channel",
|
||||||
|
|
|
@ -13413,6 +13413,7 @@ exports[`Storyshots Orders / Order details channel section default 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -13460,6 +13461,7 @@ exports[`Storyshots Orders / Order details channel section loading 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -105138,6 +105140,7 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -106957,6 +106960,7 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -108776,6 +108780,7 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -109381,6 +109386,7 @@ exports[`Storyshots Views / Orders / Order details loading 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -111164,6 +111170,7 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -112983,6 +112990,7 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -114802,6 +114810,7 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -116621,6 +116630,7 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -118440,6 +118450,7 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -120259,6 +120270,7 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -122078,6 +122090,7 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -123897,6 +123910,7 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -125716,6 +125730,7 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
@ -127535,6 +127550,7 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
|
||||||
|
data-test-id="order-sales-channel"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="CardTitle-root-id"
|
class="CardTitle-root-id"
|
||||||
|
|
Loading…
Reference in a new issue