saleor-dashboard/cypress/support/api/requests/Channels.js
Karolina Rakoczy 2c64a966cc
Saleor 4437 refactor tests (#1389)
* reference type cypress working

* refactor

* remove screenshots

* add reference

* add slash marker

* run tests based on shop version

* fix run tests based on shop version

* fix run tests based on shop version

* change base url to localhost

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix yml

* fix yml

* chage file names

* fix files names

* fix broken imports add checking for errors in grpah responses

* fix broken imports add checking for errors in grpah responses

* update jest

* fix snapshot
2021-09-27 12:04:21 +02:00

71 lines
1.3 KiB
JavaScript

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
}
}`;
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);
}