2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../support"/>
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors";
|
|
|
|
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
|
|
|
|
import { urlList } from "../../fixtures/urlList";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
createCustomer,
|
2022-06-27 16:49:35 +00:00
|
|
|
deleteCustomersStartsWith,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../support/api/requests/Customer";
|
|
|
|
import { updateOrdersSettings } from "../../support/api/requests/Order";
|
|
|
|
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
|
|
|
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
createShipping,
|
2022-06-27 16:49:35 +00:00
|
|
|
deleteShippingStartsWith,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../support/api/utils/shippingUtils";
|
|
|
|
import { selectChannelInPicker } from "../../support/pages/channelsPage";
|
|
|
|
import { finalizeDraftOrder } from "../../support/pages/draftOrderPage";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
xdescribe("Draft orders", () => {
|
|
|
|
const startsWith = "CyDraftOrders-";
|
|
|
|
const randomName = startsWith + faker.datatype.number();
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
let defaultChannel;
|
|
|
|
let warehouse;
|
|
|
|
let address;
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteCustomersStartsWith(startsWith);
|
|
|
|
deleteShippingStartsWith(startsWith);
|
|
|
|
productsUtils.deleteProductsStartsWith(startsWith);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
updateOrdersSettings();
|
|
|
|
getDefaultChannel()
|
|
|
|
.then(channel => {
|
|
|
|
defaultChannel = channel;
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
cy.fixture("addresses");
|
|
|
|
})
|
|
|
|
.then(addresses => {
|
|
|
|
address = addresses.plAddress;
|
|
|
|
createCustomer(
|
|
|
|
`${randomName}@example.com`,
|
|
|
|
randomName,
|
|
|
|
addresses.plAddress,
|
2022-06-27 16:49:35 +00:00
|
|
|
true,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
createShipping({
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
name: randomName,
|
2022-06-27 16:49:35 +00:00
|
|
|
address: addresses.plAddress,
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(({ warehouse: warehouseResp }) => {
|
|
|
|
warehouse = warehouseResp;
|
|
|
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
2022-06-27 16:49:35 +00:00
|
|
|
name: randomName,
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(
|
|
|
|
({
|
|
|
|
productType: productTypeResp,
|
|
|
|
attribute: attributeResp,
|
2022-06-27 16:49:35 +00:00
|
|
|
category: categoryResp,
|
2022-06-27 09:30:51 +00:00
|
|
|
}) => {
|
|
|
|
productsUtils.createProductInChannel({
|
2021-07-23 09:46:44 +00:00
|
|
|
name: randomName,
|
2022-06-27 09:30:51 +00:00
|
|
|
channelId: defaultChannel.id,
|
|
|
|
warehouseId: warehouse.id,
|
|
|
|
productTypeId: productTypeResp.id,
|
|
|
|
attributeId: attributeResp.id,
|
2022-06-27 16:49:35 +00:00
|
|
|
categoryId: categoryResp.id,
|
2021-09-29 13:24:47 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2023-01-16 09:43:13 +00:00
|
|
|
cy.checkIfDataAreNotNull({ defaultChannel, warehouse, address }),
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
2022-12-30 07:21:28 +00:00
|
|
|
"should move draft order to orders. TC: SALEOR_2103",
|
2022-06-27 09:30:51 +00:00
|
|
|
{ tags: ["@orders", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
cy.visit(urlList.orders);
|
2022-06-27 09:30:51 +00:00
|
|
|
cy.expectSkeletonIsVisible();
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.get(ORDERS_SELECTORS.createOrderButton).click();
|
2021-07-23 09:46:44 +00:00
|
|
|
selectChannelInPicker(defaultChannel.name);
|
|
|
|
finalizeDraftOrder(randomName, address).then(draftOrderNumber => {
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.contains(ORDERS_SELECTORS.orderRow, draftOrderNumber).should(
|
|
|
|
$order => {
|
|
|
|
expect($order).to.be.visible;
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
cy.visit(urlList.draftOrders);
|
|
|
|
cy.contains(
|
|
|
|
DRAFT_ORDERS_LIST_SELECTORS.draftOrderRow,
|
2022-06-27 16:49:35 +00:00
|
|
|
draftOrderNumber,
|
2021-07-23 09:46:44 +00:00
|
|
|
).should($draftOrder => {
|
|
|
|
expect($draftOrder).to.not.exist;
|
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|