saleor-dashboard/cypress/support/api/requests/Channels.js

120 lines
2.7 KiB
JavaScript
Raw Normal View History

export function createChannel({
isActive = true,
name,
slug = name,
currencyCode = "PLN",
defaultCountry = "PL",
}) {
const createChannelMutation = `mutation{
channelCreate(input: {
isActive: ${isActive}
name: "${name}"
slug: "${slug}"
currencyCode: "${currencyCode}"
defaultCountry: ${defaultCountry}
}){
channel{
id
name
slug
}
errors{
code
message
}
}
}`;
return cy
.sendRequestWithQuery(createChannelMutation)
.its("body.data.channelCreate.channel");
}
export function getChannels() {
const getChannelsInfoQuery = `query{
channels{
name
id
isActive
slug
currencyCode
2021-02-15 09:44:50 +00:00
}
}`;
return cy.sendRequestWithQuery(getChannelsInfoQuery);
}
export function deleteChannel(channelId, targetChannelId) {
const deleteChannelMutation = `mutation{
channelDelete(id: "${channelId}", input:{
2021-06-07 15:16:44 +00:00
channelId: "${targetChannelId}"
}){
channel{
name
}
2022-06-06 08:47:39 +00:00
errors{
message
}
}
}`;
return cy.sendRequestWithQuery(deleteChannelMutation);
}
export function activateChannel(channelId) {
const mutation = `mutation{
channelActivate(id:"${channelId}"){
errors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function updateChannelWarehouses(channelId, warehouseId) {
const mutation = `mutation{
channelUpdate(id:"${channelId}", input:{
addWarehouses:"${warehouseId}"
}){
errors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function updateChannelOrderSettings({
channelId,
automaticallyConfirmAllNewOrders = true,
automaticallyFulfillNonShippableGiftCard = true,
expireOrdersAfter = 0,
markAsPaidStrategy = "PAYMENT_FLOW", // TRANSACTION_FLOW - creates the TransactionItem object.
defaultTransactionFlowStrategy = "AUTHORIZATION",
}) {
const mutation = `mutation{
channelUpdate(id:"${channelId}", input: {orderSettings: {
automaticallyConfirmAllNewOrders: ${automaticallyConfirmAllNewOrders},
automaticallyFulfillNonShippableGiftCard: ${automaticallyFulfillNonShippableGiftCard},
expireOrdersAfter: ${expireOrdersAfter},
markAsPaidStrategy: ${markAsPaidStrategy},
defaultTransactionFlowStrategy: ${defaultTransactionFlowStrategy}
}}){
errors{
field
message
}
channel {
orderSettings{
automaticallyConfirmAllNewOrders
automaticallyFulfillNonShippableGiftCard
expireOrdersAfter
markAsPaidStrategy
defaultTransactionFlowStrategy
}
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}