2021-02-11 13:58:05 +00:00
|
|
|
// <reference types="cypress" />
|
|
|
|
import faker from "faker";
|
|
|
|
|
2021-05-16 11:38:53 +00:00
|
|
|
import { createChannel } from "../../../apiRequests/Channels";
|
2021-06-30 23:14:25 +00:00
|
|
|
import {
|
|
|
|
createShippingZone,
|
|
|
|
getShippingZone
|
|
|
|
} from "../../../apiRequests/ShippingMethod";
|
2021-06-10 10:48:59 +00:00
|
|
|
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
2021-05-16 11:38:53 +00:00
|
|
|
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
|
|
|
import { ADD_CHANNEL_FORM_SELECTORS } from "../../../elements/channels/add-channel-form-selectors";
|
|
|
|
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
|
|
|
|
import { CHANNELS_SELECTORS } from "../../../elements/channels/channels-selectors";
|
|
|
|
import { SELECT_CHANNELS_TO_ASSIGN } from "../../../elements/channels/select-channels-to-assign";
|
|
|
|
import { HEADER_SELECTORS } from "../../../elements/header/header-selectors";
|
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
|
|
|
import { createChannelByView } from "../../../steps/channelsSteps";
|
2021-07-15 09:20:59 +00:00
|
|
|
import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar";
|
2021-05-16 11:38:53 +00:00
|
|
|
import { urlList } from "../../../url/urlList";
|
|
|
|
import { deleteChannelsStartsWith } from "../../../utils/channelsUtils";
|
2021-06-30 23:14:25 +00:00
|
|
|
import { deleteShippingStartsWith } from "../../../utils/shippingUtils";
|
2021-02-11 13:58:05 +00:00
|
|
|
|
|
|
|
describe("Channels", () => {
|
2021-06-30 23:14:25 +00:00
|
|
|
const channelStartsWith = `CyChannels`;
|
|
|
|
const randomName = `${channelStartsWith} ${faker.datatype.number()}`;
|
2021-02-11 13:58:05 +00:00
|
|
|
const currency = "PLN";
|
2021-06-30 23:14:25 +00:00
|
|
|
let shippingZone;
|
2021-02-11 13:58:05 +00:00
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
2021-03-12 12:14:18 +00:00
|
|
|
deleteChannelsStartsWith(channelStartsWith);
|
2021-06-30 23:14:25 +00:00
|
|
|
deleteShippingStartsWith(channelStartsWith);
|
|
|
|
createShippingZone(randomName, "US").then(shippingZoneResp => {
|
|
|
|
shippingZone = shippingZoneResp;
|
|
|
|
});
|
2021-02-11 13:58:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-06-10 10:48:59 +00:00
|
|
|
cy.clearSessionData().loginUserViaRequest(
|
|
|
|
"auth",
|
|
|
|
ONE_PERMISSION_USERS.channel
|
|
|
|
);
|
2021-02-11 13:58:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should create new channel", () => {
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
2021-02-23 12:09:58 +00:00
|
|
|
cy.addAliasToGraphRequest("Channels");
|
2021-02-22 12:10:51 +00:00
|
|
|
cy.visit(urlList.channels);
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.softExpectSkeletonIsVisible();
|
2021-02-23 12:09:58 +00:00
|
|
|
cy.wait("@Channels");
|
2021-06-30 23:14:25 +00:00
|
|
|
createChannelByView({ name: randomChannel, currency });
|
|
|
|
cy.wait("@Channel");
|
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
// New channel should be visible in channels list
|
2021-06-30 23:14:25 +00:00
|
|
|
cy.get(ADD_CHANNEL_FORM_SELECTORS.backToChannelsList)
|
2021-02-11 13:58:05 +00:00
|
|
|
.click()
|
|
|
|
.get(CHANNELS_SELECTORS.channelsTable)
|
2021-02-11 14:17:00 +00:00
|
|
|
.contains(randomChannel);
|
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
// new channel should be visible in channel selector
|
|
|
|
cy.visit(urlList.homePage)
|
|
|
|
.get(HEADER_SELECTORS.channelSelect)
|
|
|
|
.click()
|
|
|
|
.get(HEADER_SELECTORS.channelSelectList)
|
|
|
|
.contains(randomChannel)
|
2021-02-11 14:17:00 +00:00
|
|
|
.click();
|
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
// new channel should be visible at product availability form
|
2021-06-10 10:48:59 +00:00
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
2021-04-08 16:14:15 +00:00
|
|
|
cy.addAliasToGraphRequest("InitialProductFilterAttributes");
|
2021-02-23 12:09:58 +00:00
|
|
|
cy.visit(urlList.products);
|
2021-04-08 16:14:15 +00:00
|
|
|
cy.wait("@InitialProductFilterAttributes");
|
2021-07-15 09:20:59 +00:00
|
|
|
waitForProgressBarToNotExist();
|
2021-05-16 11:38:53 +00:00
|
|
|
cy.get(PRODUCTS_LIST.emptyProductRow).should("not.exist");
|
2021-04-01 12:33:36 +00:00
|
|
|
cy.get(PRODUCTS_LIST.productsList)
|
2021-02-11 13:58:05 +00:00
|
|
|
.first()
|
|
|
|
.click()
|
2021-04-01 12:33:36 +00:00
|
|
|
.get(AVAILABLE_CHANNELS_FORM.menageChannelsButton)
|
2021-02-11 13:58:05 +00:00
|
|
|
.click()
|
2021-04-01 12:33:36 +00:00
|
|
|
.get(SELECT_CHANNELS_TO_ASSIGN.listOfChannels)
|
2021-02-11 13:58:05 +00:00
|
|
|
.contains(randomChannel);
|
|
|
|
});
|
|
|
|
|
2021-06-30 23:14:25 +00:00
|
|
|
it("should create channel with shippingZone", () => {
|
|
|
|
// remove login after fixing SALEOR-3162
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
|
|
|
|
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
|
|
|
cy.addAliasToGraphRequest("Channels");
|
|
|
|
cy.visit(urlList.channels);
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.softExpectSkeletonIsVisible();
|
2021-06-30 23:14:25 +00:00
|
|
|
cy.wait("@Channels");
|
|
|
|
createChannelByView({
|
|
|
|
name: randomChannel,
|
|
|
|
currency,
|
|
|
|
shippingZone: shippingZone.name
|
|
|
|
});
|
|
|
|
cy.wait("@Channel");
|
|
|
|
getShippingZone(shippingZone.id).then(shippingZoneResp => {
|
|
|
|
const assignedChannel = shippingZoneResp.channels.find(
|
|
|
|
channel => channel.name === randomChannel
|
|
|
|
);
|
|
|
|
expect(assignedChannel).to.be.ok;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
it("should validate slug name", () => {
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
2021-04-28 13:10:47 +00:00
|
|
|
createChannel({
|
|
|
|
isActive: false,
|
|
|
|
name: randomChannel,
|
|
|
|
slug: randomChannel,
|
|
|
|
currencyCode: currency
|
|
|
|
});
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.channels);
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.softExpectSkeletonIsVisible();
|
2021-06-30 23:14:25 +00:00
|
|
|
createChannelByView({ name: randomChannel, currency });
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.get(ADD_CHANNEL_FORM_SELECTORS.slugValidationMessage).should(
|
|
|
|
"be.visible"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
it("should validate duplicated currency", () => {
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.channels);
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.softExpectSkeletonIsVisible();
|
2021-06-30 23:14:25 +00:00
|
|
|
createChannelByView({
|
|
|
|
name: randomChannel,
|
|
|
|
currency: "notExistingCurrency"
|
|
|
|
});
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyValidationMessage).should(
|
|
|
|
"be.visible"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should delete channel", () => {
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomChannelToDelete = `${channelStartsWith} ${faker.datatype.number()}`;
|
2021-04-28 13:10:47 +00:00
|
|
|
createChannel({
|
|
|
|
isActive: false,
|
|
|
|
name: randomChannelToDelete,
|
|
|
|
slug: randomChannelToDelete,
|
|
|
|
currencyCode: currency
|
|
|
|
});
|
2021-02-23 12:09:58 +00:00
|
|
|
cy.addAliasToGraphRequest("Channels");
|
|
|
|
cy.visit(urlList.channels);
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.softExpectSkeletonIsVisible();
|
2021-02-23 12:09:58 +00:00
|
|
|
cy.wait("@Channels");
|
2021-03-02 08:38:24 +00:00
|
|
|
cy.contains(CHANNELS_SELECTORS.channelName, randomChannelToDelete)
|
2021-02-11 13:58:05 +00:00
|
|
|
.parentsUntil(CHANNELS_SELECTORS.channelsTable)
|
|
|
|
.find("button")
|
2021-02-23 12:09:58 +00:00
|
|
|
.click();
|
|
|
|
cy.addAliasToGraphRequest("Channels");
|
|
|
|
cy.get(BUTTON_SELECTORS.submit).click();
|
|
|
|
cy.wait("@Channels");
|
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.get(CHANNELS_SELECTORS.channelName)
|
|
|
|
.contains(randomChannelToDelete)
|
|
|
|
.should("not.exist");
|
|
|
|
});
|
|
|
|
});
|