2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../support"/>
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import { CHANNEL_FORM_SELECTORS } from "../../elements/channels/channel-form-selectors";
|
|
|
|
import { HEADER_SELECTORS } from "../../elements/header/header-selectors";
|
|
|
|
import { DRAFT_ORDER_SELECTORS } from "../../elements/orders/draft-order-selectors";
|
|
|
|
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { urlList } from "../../fixtures/urlList";
|
|
|
|
import { createChannel } from "../../support/api/requests/Channels";
|
|
|
|
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
selectChannelInHeader,
|
2022-06-27 16:49:35 +00:00
|
|
|
selectChannelInPicker,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../support/pages/channelsPage";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
xdescribe("Channels in draft orders", () => {
|
|
|
|
const startsWith = "CyChannelInDraftOrders-";
|
|
|
|
const randomName = startsWith + faker.datatype.number();
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
let defaultChannel;
|
|
|
|
let otherChannel;
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
channelsUtils.deleteChannelsStartsWith(startsWith);
|
|
|
|
channelsUtils
|
|
|
|
.getDefaultChannel()
|
|
|
|
.then(channel => {
|
|
|
|
defaultChannel = channel;
|
|
|
|
createChannel({ name: randomName });
|
|
|
|
})
|
|
|
|
.then(channelResp => {
|
|
|
|
otherChannel = channelResp;
|
|
|
|
});
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"Draft order channel should be taken from global channel picker",
|
|
|
|
{ tags: ["@orders", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
let channelName;
|
|
|
|
cy.visit(urlList.homePage);
|
|
|
|
cy.getTextFromElement(HEADER_SELECTORS.channelSelect).then(
|
|
|
|
channelInHeader => {
|
|
|
|
channelName = channelInHeader;
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
cy.visit(urlList.orders)
|
|
|
|
.get(ORDERS_SELECTORS.createOrder)
|
|
|
|
.click();
|
|
|
|
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
|
|
|
|
selectedChannelName => {
|
|
|
|
expect(channelName).to.contains(selectedChannelName);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
cy.get(CHANNEL_FORM_SELECTORS.confirmButton).click();
|
|
|
|
cy.getTextFromElement(DRAFT_ORDER_SELECTORS.salesChannel).then(
|
|
|
|
channelNameInDraftOrder => {
|
|
|
|
expect(channelName).to.contains(channelNameInDraftOrder);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-09-10 08:59:46 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"Draft order channel should be taken from global channel picker when changed",
|
|
|
|
{ tags: ["@orders", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
cy.visit(urlList.homePage);
|
|
|
|
selectChannelInHeader(otherChannel.name);
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.get(ORDERS_SELECTORS.createOrder).click();
|
|
|
|
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
|
|
|
|
channelInSelect => {
|
|
|
|
expect(channelInSelect).to.be.eq(otherChannel.name);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
cy.get(CHANNEL_FORM_SELECTORS.confirmButton).click();
|
|
|
|
cy.getTextFromElement(DRAFT_ORDER_SELECTORS.salesChannel).then(
|
|
|
|
channelInDraftOrder => {
|
|
|
|
expect(channelInDraftOrder).to.be.eq(otherChannel.name);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-09-10 08:59:46 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should create draft order with chosen channel",
|
|
|
|
{ tags: ["@orders", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
cy.visit(urlList.homePage);
|
|
|
|
selectChannelInHeader(defaultChannel.name);
|
|
|
|
cy.visit(urlList.orders);
|
|
|
|
cy.get(ORDERS_SELECTORS.createOrder).click();
|
|
|
|
cy.getTextFromElement(CHANNEL_FORM_SELECTORS.channelSelect).then(
|
|
|
|
channelInSelect => {
|
|
|
|
expect(channelInSelect).to.be.eq(defaultChannel.name);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
selectChannelInPicker(otherChannel.name);
|
|
|
|
cy.getTextFromElement(DRAFT_ORDER_SELECTORS.salesChannel).then(
|
|
|
|
channelInDraftOrder => {
|
|
|
|
expect(channelInDraftOrder).to.be.eq(otherChannel.name);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|