2021-03-17 10:00:30 +00:00
|
|
|
// <reference types="cypress" />
|
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import {
|
|
|
|
createCustomer,
|
|
|
|
deleteCustomersStartsWith
|
2021-05-16 11:38:53 +00:00
|
|
|
} from "../../../apiRequests/Customer";
|
2021-05-31 07:50:31 +00:00
|
|
|
import { getOrder } from "../../../apiRequests/Order";
|
2021-06-10 10:48:59 +00:00
|
|
|
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
2021-05-31 07:50:31 +00:00
|
|
|
import { ORDER_REFUND } from "../../../elements/orders/order-refund";
|
2021-05-16 11:38:53 +00:00
|
|
|
import { ORDERS_SELECTORS } from "../../../elements/orders/orders-selectors";
|
2021-05-31 07:50:31 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
|
|
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
2021-05-16 11:38:53 +00:00
|
|
|
import { selectChannelInPicker } from "../../../steps/channelsSteps";
|
|
|
|
import { finalizeDraftOrder } from "../../../steps/draftOrderSteps";
|
2021-05-31 07:50:31 +00:00
|
|
|
import { fillAutocompleteSelect } from "../../../steps/shared/autocompleteSelect";
|
2021-05-16 11:38:53 +00:00
|
|
|
import { urlList } from "../../../url/urlList";
|
|
|
|
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
2021-05-31 07:50:31 +00:00
|
|
|
import {
|
|
|
|
createFulfilledOrder,
|
|
|
|
createOrder,
|
|
|
|
createReadyToFulfillOrder
|
|
|
|
} from "../../../utils/ordersUtils";
|
2021-05-16 11:38:53 +00:00
|
|
|
import * as productsUtils from "../../../utils/products/productsUtils";
|
2021-03-17 10:00:30 +00:00
|
|
|
import {
|
|
|
|
createShipping,
|
|
|
|
deleteShippingStartsWith
|
2021-05-16 11:38:53 +00:00
|
|
|
} from "../../../utils/shippingUtils";
|
2021-03-17 10:00:30 +00:00
|
|
|
|
|
|
|
describe("Orders", () => {
|
2021-04-16 11:36:24 +00:00
|
|
|
const startsWith = "CyOrders-";
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomName = startsWith + faker.datatype.number();
|
2021-03-17 10:00:30 +00:00
|
|
|
|
|
|
|
let customer;
|
|
|
|
let defaultChannel;
|
|
|
|
let warehouse;
|
|
|
|
let shippingMethod;
|
|
|
|
let variantsList;
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
let address;
|
2021-03-17 10:00:30 +00:00
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteCustomersStartsWith(startsWith);
|
|
|
|
deleteShippingStartsWith(startsWith);
|
|
|
|
productsUtils.deleteProductsStartsWith(startsWith);
|
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
)
|
2021-04-28 13:10:47 +00:00
|
|
|
.then(({ variantsList: variantsResp }) => {
|
2021-03-17 10:00:30 +00:00
|
|
|
variantsList = variantsResp;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-06-10 10:48:59 +00:00
|
|
|
cy.clearSessionData().loginUserViaRequest(
|
|
|
|
"auth",
|
|
|
|
ONE_PERMISSION_USERS.order
|
|
|
|
);
|
2021-03-17 10:00:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should create order with selected channel", () => {
|
2021-07-05 13:05:13 +00:00
|
|
|
// Remove login as admin after fixing SALEOR-3154
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
2021-03-17 10:00:30 +00:00
|
|
|
cy.visit(urlList.orders)
|
|
|
|
.get(ORDERS_SELECTORS.createOrder)
|
|
|
|
.click();
|
|
|
|
selectChannelInPicker(defaultChannel.name);
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
finalizeDraftOrder(randomName, address).then(draftOrderNumber => {
|
2021-03-17 10:00:30 +00:00
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.contains(ORDERS_SELECTORS.orderRow, draftOrderNumber).click();
|
|
|
|
cy.contains(ORDERS_SELECTORS.salesChannel, defaultChannel.name).should(
|
|
|
|
"be.visible"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-05-31 07:50:31 +00:00
|
|
|
|
2021-06-10 10:48:59 +00:00
|
|
|
// This test will pass after fixing SALEOR-3154
|
2021-03-17 10:00:30 +00:00
|
|
|
it("should not be possible to change channel in order", () => {
|
|
|
|
createOrder({
|
|
|
|
customerId: customer.id,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
shippingMethodId: shippingMethod.id,
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
variantsList,
|
|
|
|
address
|
2021-03-17 10:00:30 +00:00
|
|
|
}).then(order => {
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.contains(ORDERS_SELECTORS.orderRow, order.number).click();
|
|
|
|
cy.get(ORDERS_SELECTORS.salesChannel)
|
|
|
|
.find("[button]")
|
|
|
|
.should("not.exist");
|
|
|
|
});
|
|
|
|
});
|
2021-05-31 07:50:31 +00:00
|
|
|
|
|
|
|
it("should cancel fulfillment", () => {
|
|
|
|
let order;
|
|
|
|
createFulfilledOrder({
|
|
|
|
customerId: customer.id,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
shippingMethodId: shippingMethod.id,
|
|
|
|
variantsList,
|
|
|
|
address,
|
|
|
|
warehouse: warehouse.id
|
|
|
|
})
|
|
|
|
.then(({ order: orderResp }) => {
|
|
|
|
order = orderResp;
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.contains(ORDERS_SELECTORS.orderRow, order.number).click();
|
|
|
|
cy.get(SHARED_ELEMENTS.skeleton)
|
|
|
|
.should("not.exist")
|
|
|
|
.get(ORDERS_SELECTORS.orderFulfillmentFrame)
|
|
|
|
.find(BUTTON_SELECTORS.showMoreButton)
|
|
|
|
.click()
|
|
|
|
.get(ORDERS_SELECTORS.cancelFulfillment)
|
|
|
|
.click();
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
fillAutocompleteSelect(
|
|
|
|
ORDERS_SELECTORS.cancelFulfillmentSelectField,
|
|
|
|
warehouse.name
|
|
|
|
);
|
|
|
|
cy.addAliasToGraphRequest("OrderFulfillmentCancel");
|
|
|
|
cy.get(BUTTON_SELECTORS.submit).click();
|
|
|
|
cy.wait("@OrderFulfillmentCancel");
|
|
|
|
getOrder(order.id);
|
|
|
|
})
|
|
|
|
.then(orderResp => {
|
|
|
|
expect(orderResp.status).to.be.eq("UNFULFILLED");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should make a refund", () => {
|
|
|
|
let order;
|
|
|
|
createReadyToFulfillOrder({
|
|
|
|
customerId: customer.id,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
shippingMethodId: shippingMethod.id,
|
|
|
|
variantsList,
|
|
|
|
address
|
|
|
|
})
|
|
|
|
.then(({ order: orderResp }) => {
|
|
|
|
order = orderResp;
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.contains(ORDERS_SELECTORS.orderRow, order.number).click();
|
|
|
|
cy.get(ORDERS_SELECTORS.refundButton)
|
|
|
|
.click()
|
|
|
|
.get(ORDER_REFUND.productsQuantityInput)
|
|
|
|
.type("1")
|
|
|
|
.addAliasToGraphRequest("OrderFulfillmentRefundProducts");
|
|
|
|
cy.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.wait("@OrderFulfillmentRefundProducts");
|
|
|
|
getOrder(order.id);
|
|
|
|
})
|
|
|
|
.then(orderResp => {
|
|
|
|
expect(orderResp.paymentStatus).to.be.eq("FULLY_REFUNDED");
|
|
|
|
});
|
|
|
|
});
|
2021-03-17 10:00:30 +00:00
|
|
|
});
|