2021-07-15 09:25:31 +00:00
|
|
|
import { getDefaultAddress, getValueWithDefault } from "./utils/Utils";
|
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
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function markOrderAsPaid(orderId) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
orderMarkAsPaid(id:"${orderId}"){
|
2022-06-06 08:47:39 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
message
|
|
|
|
}
|
2022-08-04 10:59:42 +00:00
|
|
|
order{
|
|
|
|
id
|
|
|
|
number
|
|
|
|
lines{
|
|
|
|
id
|
|
|
|
}
|
2023-05-11 06:46:33 +00:00
|
|
|
total{
|
|
|
|
gross{
|
|
|
|
amount
|
|
|
|
currency
|
|
|
|
}
|
|
|
|
}
|
2022-08-04 10:59:42 +00:00
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
|
|
|
}`;
|
2022-08-04 10:59:42 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation).its("body.data.orderMarkAsPaid");
|
2021-03-12 12:14:18 +00:00
|
|
|
}
|
2021-01-27 09:41:55 +00:00
|
|
|
|
2021-09-10 08:59:46 +00:00
|
|
|
export function updateOrdersSettings(automaticallyConfirmAllNewOrders = true) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
orderSettingsUpdate(input:{
|
|
|
|
automaticallyConfirmAllNewOrders: ${automaticallyConfirmAllNewOrders}
|
|
|
|
}){
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function addProductToOrder(orderId, variantId, quantity = 1) {
|
|
|
|
const mutation = `mutation{
|
2021-04-06 12:25:56 +00:00
|
|
|
orderLinesCreate(id:"${orderId}", input:{
|
2021-03-12 14:57:02 +00:00
|
|
|
quantity:${quantity}
|
|
|
|
variantId: "${variantId}"
|
|
|
|
}){
|
2022-10-25 11:44:10 +00:00
|
|
|
order{
|
|
|
|
shippingMethods{
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
2022-06-06 08:47:39 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2022-10-25 11:44:10 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation).its("body.data.orderLinesCreate");
|
2021-03-12 12:14:18 +00:00
|
|
|
}
|
2021-01-27 09:41:55 +00:00
|
|
|
|
2022-10-25 11:44:10 +00:00
|
|
|
export function createDraftOrder({ customerId, channelId, address }) {
|
2021-07-15 09:25:31 +00:00
|
|
|
const user = getValueWithDefault(customerId, `user:"${customerId}"`);
|
|
|
|
|
2021-03-12 14:57:02 +00:00
|
|
|
const mutation = `mutation{
|
|
|
|
draftOrderCreate(input:{
|
2021-07-15 09:25:31 +00:00
|
|
|
${user}
|
2021-06-07 15:16:44 +00:00
|
|
|
channelId: "${channelId}"
|
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
|
|
|
${getDefaultAddress(address, "shippingAddress")}
|
|
|
|
${getDefaultAddress(address, "billingAddress")}
|
2021-03-12 14:57:02 +00:00
|
|
|
}){
|
2021-06-07 15:16:44 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
message
|
|
|
|
}
|
|
|
|
order{
|
|
|
|
id
|
2021-03-17 10:00:30 +00:00
|
|
|
number
|
2022-10-25 11:44:10 +00:00
|
|
|
id
|
|
|
|
shippingMethods{
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
paymentStatus
|
|
|
|
totalBalance{
|
|
|
|
amount
|
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-04-28 13:10:47 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(mutation)
|
|
|
|
.its("body.data.draftOrderCreate.order");
|
2021-03-12 12:14:18 +00:00
|
|
|
}
|
2021-05-31 07:50:31 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function completeOrder(orderId) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
draftOrderComplete(id:"${orderId}"){
|
|
|
|
order{
|
|
|
|
id
|
2021-05-31 07:50:31 +00:00
|
|
|
number
|
|
|
|
lines{
|
|
|
|
id
|
|
|
|
}
|
2023-05-11 06:46:33 +00:00
|
|
|
total{
|
|
|
|
gross{
|
|
|
|
amount
|
|
|
|
currency
|
|
|
|
}
|
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
2021-11-22 12:34:21 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
message
|
2021-11-22 12:34:21 +00:00
|
|
|
field
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-05-31 07:50:31 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation).its("body.data.draftOrderComplete");
|
2021-01-27 09:41:55 +00:00
|
|
|
}
|
2021-05-31 07:50:31 +00:00
|
|
|
|
2021-04-28 13:10:47 +00:00
|
|
|
export function getOrder(orderId) {
|
|
|
|
const query = `query getOrder{
|
|
|
|
order(id:"${orderId}"){
|
|
|
|
status
|
2022-01-31 08:37:49 +00:00
|
|
|
token
|
2021-05-16 11:38:53 +00:00
|
|
|
paymentStatus
|
2021-04-28 13:10:47 +00:00
|
|
|
isShippingRequired
|
2023-05-11 06:46:33 +00:00
|
|
|
transactions{
|
|
|
|
id
|
|
|
|
}
|
2021-04-28 13:10:47 +00:00
|
|
|
shippingMethod{
|
|
|
|
id
|
|
|
|
}
|
2021-07-15 09:25:31 +00:00
|
|
|
metadata{
|
|
|
|
key
|
|
|
|
value
|
|
|
|
}
|
|
|
|
privateMetadata{
|
|
|
|
key
|
|
|
|
value
|
|
|
|
}
|
2021-10-21 10:45:38 +00:00
|
|
|
shippingAddress{
|
|
|
|
companyName
|
|
|
|
streetAddress1
|
|
|
|
streetAddress2
|
|
|
|
city
|
|
|
|
postalCode
|
|
|
|
countryArea
|
|
|
|
phone
|
|
|
|
}
|
|
|
|
billingAddress{
|
|
|
|
companyName
|
|
|
|
streetAddress1
|
|
|
|
streetAddress2
|
|
|
|
city
|
|
|
|
postalCode
|
|
|
|
countryArea
|
|
|
|
phone
|
|
|
|
}
|
2021-04-28 13:10:47 +00:00
|
|
|
}
|
|
|
|
}`;
|
2023-05-11 06:46:33 +00:00
|
|
|
return cy.sendRequestWithQuery(query).its("body.data.order");
|
2021-04-28 13:10:47 +00:00
|
|
|
}
|
2021-05-31 07:50:31 +00:00
|
|
|
|
|
|
|
export function fulfillOrder({ orderId, warehouse, quantity, linesId }) {
|
|
|
|
const lines = linesId.reduce((lines, lineId) => {
|
|
|
|
const line = `{orderLineId:"${lineId.id}"
|
|
|
|
stocks:{
|
|
|
|
quantity:${quantity}
|
|
|
|
warehouse:"${warehouse}"
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return lines + line;
|
|
|
|
}, "");
|
|
|
|
const mutation = `mutation fulfill{
|
|
|
|
orderFulfill(order:"${orderId}" input:{
|
|
|
|
lines:[${lines}]
|
|
|
|
}){
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
order{
|
|
|
|
id
|
|
|
|
number
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation).its("body.data.orderFulfill");
|
|
|
|
}
|
2022-10-25 11:44:10 +00:00
|
|
|
|
|
|
|
export function addShippingMethod(orderId, shippingMethodId) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
orderUpdateShipping(order:"${orderId}", input:{
|
|
|
|
shippingMethod:"${shippingMethodId}"
|
|
|
|
}){
|
|
|
|
order{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation).its("body.data.orderUpdateShipping");
|
|
|
|
}
|