saleor-dashboard/cypress/apiRequests/Channels.js
Karolina Rakoczy 3bd83c3731
tests for channels (#1185)
* tests for channels

* fix display product after channel activate

* remove comments
2021-07-01 01:14:25 +02:00

68 lines
1.3 KiB
JavaScript

export function createChannel({
isActive = true,
name,
slug = name,
currencyCode = "PLN"
}) {
const createChannelMutation = `mutation{
channelCreate(input: {
isActive: ${isActive}
name: "${name}"
slug: "${slug}"
currencyCode: "${currencyCode}"
}){
channel{
id
name
slug
}
channelErrors{
code
message
}
}
}`;
return cy
.sendRequestWithQuery(createChannelMutation)
.its("body.data.channelCreate.channel");
}
export function getChannels() {
const getChannelsInfoQuery = `query{
channels{
name
id
isActive
slug
currencyCode
}
}`;
return cy.sendRequestWithQuery(getChannelsInfoQuery);
}
export function deleteChannel(channelId, targetChannelId) {
const deleteChannelMutation = `mutation{
channelDelete(id: "${channelId}", input:{
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);
}