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

72 lines
1.3 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
}
channelErrors{
message
}
}
}`;
return cy.sendRequestWithQuery(deleteChannelMutation);
}
export function activateChannel(channelId) {
const mutation = `mutation{
channelActivate(id:"${channelId}"){
errors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}