fix failing tests (#1302)

* fix failing tests

* no retries

* add waiting for confirmation msg

* remove unused import

* fix test for staff

* fix test for staff

* fix tests for orders

* fix tests for channels

* fix autocomplete

* fix filters

* fix filters

* fix create shipping method
This commit is contained in:
Karolina Rakoczy 2021-09-10 10:59:46 +02:00 committed by GitHub
parent 457d50c251
commit e7a06281f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 142 additions and 58 deletions

View file

@ -2,7 +2,8 @@ export function createAttribute({
name, name,
attributeValues = ["value"], attributeValues = ["value"],
type = "PRODUCT_TYPE", type = "PRODUCT_TYPE",
inputType = "DROPDOWN" inputType = "DROPDOWN",
filterableInDashboard = false
}) { }) {
const values = attributeValues.map(element => `{name:"${element}"}`); const values = attributeValues.map(element => `{name:"${element}"}`);
const mutation = `mutation{ const mutation = `mutation{
@ -12,6 +13,7 @@ export function createAttribute({
type:${type} type:${type}
values: [${values}] values: [${values}]
inputType: ${inputType} inputType: ${inputType}
filterableInDashboard: ${filterableInDashboard}
}){ }){
attribute{ attribute{
id id
@ -84,11 +86,15 @@ export function getAttribute(attributeId) {
return cy.sendRequestWithQuery(query).its("body.data.attribute"); return cy.sendRequestWithQuery(query).its("body.data.attribute");
} }
export function updateAttribute({ filterableInDashboard }) { export function updateAttribute({ attributeId, filterableInDashboard }) {
const mutation = `mutation{ const mutation = `mutation{
attributeUpdate(id:"" input:{ attributeUpdate(id:"${attributeId}" input:{
filterableInDashboard:false filterableInDashboard: ${filterableInDashboard}
}){ }){
attribute{
id
filterableInDashboard
}
errors{ errors{
field field
message message

View file

@ -2,7 +2,8 @@ export function createChannel({
isActive = true, isActive = true,
name, name,
slug = name, slug = name,
currencyCode = "PLN" currencyCode = "PLN",
defaultCountry = "PL"
}) { }) {
const createChannelMutation = `mutation{ const createChannelMutation = `mutation{
channelCreate(input: { channelCreate(input: {
@ -10,13 +11,14 @@ export function createChannel({
name: "${name}" name: "${name}"
slug: "${slug}" slug: "${slug}"
currencyCode: "${currencyCode}" currencyCode: "${currencyCode}"
defaultCountry: ${defaultCountry}
}){ }){
channel{ channel{
id id
name name
slug slug
} }
channelErrors{ errors{
code code
message message
} }
@ -26,6 +28,7 @@ export function createChannel({
.sendRequestWithQuery(createChannelMutation) .sendRequestWithQuery(createChannelMutation)
.its("body.data.channelCreate.channel"); .its("body.data.channelCreate.channel");
} }
export function getChannels() { export function getChannels() {
const getChannelsInfoQuery = `query{ const getChannelsInfoQuery = `query{
channels{ channels{

View file

@ -11,6 +11,20 @@ export function markOrderAsPaid(orderId) {
return cy.sendRequestWithQuery(mutation); return cy.sendRequestWithQuery(mutation);
} }
export function updateOrdersSettings(automaticallyConfirmAllNewOrders = true) {
const mutation = `mutation{
orderSettingsUpdate(input:{
automaticallyConfirmAllNewOrders: ${automaticallyConfirmAllNewOrders}
}){
errors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function addProductToOrder(orderId, variantId, quantity = 1) { export function addProductToOrder(orderId, variantId, quantity = 1) {
const mutation = `mutation{ const mutation = `mutation{
orderLinesCreate(id:"${orderId}", input:{ orderLinesCreate(id:"${orderId}", input:{

View file

@ -10,5 +10,6 @@ export const ADD_CHANNEL_FORM_SELECTORS = {
currencyAutocompleteDropdown: currencyAutocompleteDropdown:
"[data-test='singleautocomplete-select-option'][data-test-type='custom']", "[data-test='singleautocomplete-select-option'][data-test-type='custom']",
addShippingZoneButton: '[data-test-id="add-shipping-zone-button"]', addShippingZoneButton: '[data-test-id="add-shipping-zone-button"]',
shippingAutocompleteSelect: "[data-test-id='shippingAutoCompleteSelect']" shippingAutocompleteSelect: "[data-test-id='shippingAutoCompleteSelect']",
countryAutocompleteInput: '[data-test-id="country-select-input"]'
}; };

View file

@ -2,6 +2,7 @@ export const SHARED_ELEMENTS = {
header: "[data-test-id='page-header']", header: "[data-test-id='page-header']",
progressBar: '[role="progressbar"]', progressBar: '[role="progressbar"]',
circularProgress: '[class*="CircularProgress-circle"]', circularProgress: '[class*="CircularProgress-circle"]',
autocompleteCircle: '[class*="arrowInnerContainer"]',
skeleton: '[data-test-id="skeleton"]', skeleton: '[data-test-id="skeleton"]',
table: 'table[class*="Table"]', table: 'table[class*="Table"]',
tableRow: '[data-test="id"], [class*="MuiTableRow"]', tableRow: '[data-test="id"], [class*="MuiTableRow"]',
@ -14,7 +15,8 @@ export const SHARED_ELEMENTS = {
empty: '[class*="codex-editor--empty"]' empty: '[class*="codex-editor--empty"]'
}, },
filters: { filters: {
filterGroupActivateCheckbox: '[data-test="filterGroupActive"]' filterGroupActivateCheckbox: '[data-test="filterGroupActive"]',
filterRow: '[data-test="channel-availability-item"]'
} }
}; };

View file

@ -124,7 +124,7 @@ filterTests(["all"], () => {
.should("not.exist") .should("not.exist")
.wait("@productBulkDelete"); .wait("@productBulkDelete");
getCategory(category.id).then(categoryResp => { getCategory(category.id).then(categoryResp => {
expect(categoryResp.products).to.be.null; expect(categoryResp.products.edges.length).to.be.eq(0);
}); });
}); });

View file

@ -35,18 +35,23 @@ describe("Tests for using attributes in filters", () => {
}); });
it("should use attribute as filter", () => { it("should use attribute as filter", () => {
updateAttribute({ filterableInDashboard: false }); updateAttribute({
attributeId: attribute.id,
filterableInDashboard: false
});
enterAttributeAndChanegeIsFilterableInDashbord(attribute.id); enterAttributeAndChanegeIsFilterableInDashbord(attribute.id);
enterProductListPage(); enterProductListPage();
selectAttributeFilter(attribute.slug, startsWith); selectAttributeFilter(attribute.slug, attribute.name);
cy.contains(SHARED_ELEMENTS.tableRow, startsWith).should("be.visible"); cy.contains(SHARED_ELEMENTS.tableRow, attribute.name).should("be.visible");
}); });
it("should remove attribute from filters", () => { it("should remove attribute from filters", () => {
updateAttribute({ filterableInDashboard: false }); updateAttribute({ attributeId: attribute.id, filterableInDashboard: true });
enterAttributeAndChanegeIsFilterableInDashbord(attribute.id); enterAttributeAndChanegeIsFilterableInDashbord(attribute.id);
enterProductListPage(); enterProductListPage();
showFilters(); showFilters();
cy.contains(attribute.name).should("not.exist"); cy.contains(SHARED_ELEMENTS.filters.filterRow, attribute.name).should(
"not.exist"
);
}); });
}); });

View file

@ -26,6 +26,7 @@ filterTests(["all"], () => {
const channelStartsWith = `CyChannels`; const channelStartsWith = `CyChannels`;
const randomName = `${channelStartsWith} ${faker.datatype.number()}`; const randomName = `${channelStartsWith} ${faker.datatype.number()}`;
const currency = "PLN"; const currency = "PLN";
const defaultCountry = "Poland";
let shippingZone; let shippingZone;
before(() => { before(() => {

View file

@ -10,10 +10,13 @@ import { ONE_PERMISSION_USERS } from "../../../Data/users";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements"; import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details"; import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
import { selectChannelInHeader } from "../../../steps/channelsSteps"; import { enterHomePageChangeChannelAndReturn } from "../../../steps/channelsSteps";
import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar"; import {
waitForProgressBarToNotBeVisible,
waitForProgressBarToNotExist
} from "../../../steps/shared/progressBar";
import filterTests from "../../../support/filterTests"; import filterTests from "../../../support/filterTests";
import { getFormattedCurrencyAmount } from "../../../support/format/formatCurrencyAmount"; import { getCurrencyAndAmountInString } from "../../../support/format/formatCurrencyAmount";
import { urlList } from "../../../url/urlList"; import { urlList } from "../../../url/urlList";
import * as channelsUtils from "../../../utils/channelsUtils"; import * as channelsUtils from "../../../utils/channelsUtils";
import * as shippingUtils from "../../../utils/shippingUtils"; import * as shippingUtils from "../../../utils/shippingUtils";
@ -98,18 +101,22 @@ filterTests(["all"], () => {
} }
cy.contains(shippingZone.name).click(); cy.contains(shippingZone.name).click();
cy.wait("@ShippingZone"); cy.wait("@ShippingZone");
selectChannelInHeader(defaultChannel.name); enterHomePageChangeChannelAndReturn(defaultChannel.name);
waitForProgressBarToNotBeVisible();
cy.get(SHARED_ELEMENTS.skeleton).should("not.exist");
cy.getTextFromElement( cy.getTextFromElement(
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
) )
.then(text => { .then(text => {
const expectedValue = getFormattedCurrencyAmount( const expectedValue = getCurrencyAndAmountInString(
defaultChannelPrice, defaultChannelPrice,
defaultChannel.currencyCode defaultChannel.currencyCode
); );
expect(text).to.be.eq(expectedValue); expect(text).to.be.eq(expectedValue);
selectChannelInHeader(createdChannel.name); enterHomePageChangeChannelAndReturn(createdChannel.name);
waitForProgressBarToNotBeVisible();
cy.get(SHARED_ELEMENTS.skeleton).should("not.exist");
}) })
.then(() => { .then(() => {
cy.getTextFromElement( cy.getTextFromElement(
@ -117,7 +124,7 @@ filterTests(["all"], () => {
); );
}) })
.then(text => { .then(text => {
const expectedValue = getFormattedCurrencyAmount( const expectedValue = getCurrencyAndAmountInString(
createdChannelPrice, createdChannelPrice,
createdChannelCurrency createdChannelCurrency
); );

View file

@ -63,6 +63,7 @@ filterTests(["all"], () => {
} }
); );
}); });
it("Draft order channel should be taken from global channel picker when changed", () => { it("Draft order channel should be taken from global channel picker when changed", () => {
cy.visit(urlList.homePage); cy.visit(urlList.homePage);
selectChannelInHeader(otherChannel.name); selectChannelInHeader(otherChannel.name);
@ -80,6 +81,7 @@ filterTests(["all"], () => {
} }
); );
}); });
it("should create draft order with chosen channel", () => { it("should create draft order with chosen channel", () => {
cy.visit(urlList.homePage); cy.visit(urlList.homePage);
selectChannelInHeader(defaultChannel.name); selectChannelInHeader(defaultChannel.name);

View file

@ -5,6 +5,7 @@ import {
createCustomer, createCustomer,
deleteCustomersStartsWith deleteCustomersStartsWith
} from "../../apiRequests/Customer"; } from "../../apiRequests/Customer";
import { updateOrdersSettings } from "../../apiRequests/Order";
import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors"; import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors";
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors"; import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
import { selectChannelInPicker } from "../../steps/channelsSteps"; import { selectChannelInPicker } from "../../steps/channelsSteps";
@ -33,6 +34,7 @@ filterTests(["all"], () => {
deleteShippingStartsWith(startsWith); deleteShippingStartsWith(startsWith);
productsUtils.deleteProductsStartsWith(startsWith); productsUtils.deleteProductsStartsWith(startsWith);
updateOrdersSettings();
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;

View file

@ -5,7 +5,7 @@ import {
createCustomer, createCustomer,
deleteCustomersStartsWith deleteCustomersStartsWith
} from "../../apiRequests/Customer"; } from "../../apiRequests/Customer";
import { getOrder } from "../../apiRequests/Order"; import { getOrder, updateOrdersSettings } from "../../apiRequests/Order";
import { ONE_PERMISSION_USERS } from "../../Data/users"; import { ONE_PERMISSION_USERS } from "../../Data/users";
import { ORDER_REFUND } from "../../elements/orders/order-refund"; import { ORDER_REFUND } from "../../elements/orders/order-refund";
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors"; import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
@ -46,6 +46,7 @@ filterTests(["all"], () => {
deleteShippingStartsWith(startsWith); deleteShippingStartsWith(startsWith);
productsUtils.deleteProductsStartsWith(startsWith); productsUtils.deleteProductsStartsWith(startsWith);
updateOrdersSettings();
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
@ -158,9 +159,6 @@ filterTests(["all"], () => {
cy.contains(ORDERS_SELECTORS.orderRow, order.number).click(); cy.contains(ORDERS_SELECTORS.orderRow, order.number).click();
cy.get(SHARED_ELEMENTS.skeleton) cy.get(SHARED_ELEMENTS.skeleton)
.should("not.exist") .should("not.exist")
.get(ORDERS_SELECTORS.orderFulfillmentFrame)
.find(BUTTON_SELECTORS.showMoreButton)
.click()
.get(ORDERS_SELECTORS.cancelFulfillment) .get(ORDERS_SELECTORS.cancelFulfillment)
.click(); .click();
}) })

View file

@ -9,6 +9,7 @@ import {
selectProductsOutOfStock selectProductsOutOfStock
} from "../../../steps/catalog/products/productsListSteps"; } from "../../../steps/catalog/products/productsListSteps";
import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar"; import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar";
import { searchInTable } from "../../../steps/shared/tables";
import filterTests from "../../../support/filterTests"; import filterTests from "../../../support/filterTests";
import { urlList } from "../../../url/urlList"; import { urlList } from "../../../url/urlList";
import { getDefaultChannel } from "../../../utils/channelsUtils"; import { getDefaultChannel } from "../../../utils/channelsUtils";
@ -112,9 +113,10 @@ filterTests(["all"], () => {
categoryId: category.id, categoryId: category.id,
price price
}); });
waitForProgressBarToNotExist();
selectChannel(channel.slug); selectChannel(channel.slug);
selectProductsOutOfStock(); selectProductsOutOfStock();
searchInTable(productOutOfStock);
cy.get(PRODUCTS_LIST.productsNames).should("have.length", 1);
cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => { cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => {
expect(product).to.includes(productOutOfStock); expect(product).to.includes(productOutOfStock);
}); });

View file

@ -11,7 +11,7 @@ import {
createVariant, createVariant,
variantsShouldBeVisible variantsShouldBeVisible
} from "../../steps/catalog/products/VariantsSteps"; } from "../../steps/catalog/products/VariantsSteps";
import { selectChannelInHeader } from "../../steps/channelsSteps"; import { enterHomePageChangeChannelAndReturn } from "../../steps/channelsSteps";
import filterTests from "../../support/filterTests"; import filterTests from "../../support/filterTests";
import { urlList } from "../../url/urlList"; import { urlList } from "../../url/urlList";
import { import {
@ -106,7 +106,7 @@ filterTests(["all", "critical"], () => {
price, price,
attribute: attributeValues[0] attribute: attributeValues[0]
}); });
selectChannelInHeader(defaultChannel.name); enterHomePageChangeChannelAndReturn(defaultChannel.name);
variantsShouldBeVisible({ name, price }); variantsShouldBeVisible({ name, price });
getProductVariants(createdProduct.id, defaultChannel.slug); getProductVariants(createdProduct.id, defaultChannel.slug);
}) })
@ -144,7 +144,7 @@ filterTests(["all", "critical"], () => {
}); });
}) })
.then(() => { .then(() => {
selectChannelInHeader(defaultChannel.name); enterHomePageChangeChannelAndReturn(defaultChannel.name);
variantsShouldBeVisible({ variantsShouldBeVisible({
name: variants[1].name, name: variants[1].name,
price: variants[1].price price: variants[1].price
@ -189,9 +189,9 @@ filterTests(["all", "critical"], () => {
price: variantsPrice, price: variantsPrice,
attribute: attributeValues[0] attribute: attributeValues[0]
}); });
selectChannelInHeader(defaultChannel.name); enterHomePageChangeChannelAndReturn(defaultChannel.name);
variantsShouldBeVisible({ name, price: variantsPrice }); variantsShouldBeVisible({ name, price: variantsPrice });
selectChannelInHeader(newChannel.name); enterHomePageChangeChannelAndReturn(newChannel.name);
variantsShouldBeVisible({ name, price: variantsPrice }); variantsShouldBeVisible({ name, price: variantsPrice });
getProductVariants(createdProduct.id, defaultChannel.slug); getProductVariants(createdProduct.id, defaultChannel.slug);
}) })

View file

@ -10,6 +10,7 @@ import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetail
import { STAFF_MEMBERS_LIST } from "../elements/staffMembers/staffMembersList"; import { STAFF_MEMBERS_LIST } from "../elements/staffMembers/staffMembersList";
import { expectWelcomeMessageIncludes } from "../steps/homePageSteps"; import { expectWelcomeMessageIncludes } from "../steps/homePageSteps";
import { getDisplayedSelectors } from "../steps/permissions"; import { getDisplayedSelectors } from "../steps/permissions";
import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages";
import { import {
fillUpSetPassword, fillUpSetPassword,
fillUpUserDetails, fillUpUserDetails,
@ -98,8 +99,9 @@ filterTests(["stagedOnly"], () => {
.click() .click()
.addAliasToGraphRequest("StaffMemberUpdate") .addAliasToGraphRequest("StaffMemberUpdate")
.get(BUTTON_SELECTORS.confirm) .get(BUTTON_SELECTORS.confirm)
.click() .click();
.wait("@StaffMemberUpdate") confirmationMessageShouldDisappear();
cy.wait("@StaffMemberUpdate")
.clearSessionData() .clearSessionData()
.loginUserViaRequest("auth", { email, password }) .loginUserViaRequest("auth", { email, password })
.visit(urlList.homePage); .visit(urlList.homePage);

View file

@ -2,6 +2,7 @@ import { ATTRIBUTES_DETAILS } from "../elements/attribute/attributes_details";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { attributeDetailsUrl } from "../url/urlList"; import { attributeDetailsUrl } from "../url/urlList";
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
import { waitForProgressBarToNotBeVisible } from "./shared/progressBar";
export function createAttributeWithInputType({ export function createAttributeWithInputType({
name, name,
@ -86,8 +87,8 @@ export function selectNumericSystem({ unitSystem, unitsOf, unit }) {
} }
export function enterAttributeAndChanegeIsFilterableInDashbord(attributeId) { export function enterAttributeAndChanegeIsFilterableInDashbord(attributeId) {
cy.visit(attributeDetailsUrl(attributeId)) cy.visit(attributeDetailsUrl(attributeId));
.get(ATTRIBUTES_DETAILS.dashboardProperties.useInFilteringCheckbox) waitForProgressBarToNotBeVisible();
.click(); cy.get(ATTRIBUTES_DETAILS.dashboardProperties.useInFilteringCheckbox).click();
submitAttribute(); submitAttribute();
} }

View file

@ -8,11 +8,10 @@ import { waitForProgressBarToNotBeVisible } from "../../shared/progressBar";
import { fillUpPriceList } from "./priceList"; import { fillUpPriceList } from "./priceList";
export function variantsShouldBeVisible({ name, price }) { export function variantsShouldBeVisible({ name, price }) {
cy.contains(PRODUCT_DETAILS.variantRow, name) cy.contains(PRODUCT_DETAILS.variantRow, name).should("be.visible");
.should("be.visible") cy.contains(PRODUCT_DETAILS.variantPrice, price);
.find(PRODUCT_DETAILS.variantPrice) // .invoke("text")
.invoke("text") // .then(text => expect(text).to.includes(price));
.then(text => expect(text).to.includes(price));
} }
export function createFirstVariant({ sku, warehouseId, price, attribute }) { export function createFirstVariant({ sku, warehouseId, price, attribute }) {
cy.get(PRODUCT_DETAILS.addVariantsButton).click(); cy.get(PRODUCT_DETAILS.addVariantsButton).click();

View file

@ -1,7 +1,7 @@
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details"; import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form"; import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { fillAutocompleteSelect } from "../../shared/selects"; import { fillAutocompleteSelect, fillMultiSelect } from "../../shared/selects";
import { addMetadataField } from "../metadataSteps"; import { addMetadataField } from "../metadataSteps";
import { editSeoSettings } from "../seoSteps"; import { editSeoSettings } from "../seoSteps";
@ -105,7 +105,7 @@ export function fillUpCollectionAndCategory({ category, collection }) {
return fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput, category) return fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput, category)
.then(selected => { .then(selected => {
organization.category = selected; organization.category = selected;
fillAutocompleteSelect(PRODUCT_DETAILS.collectionInput, collection); fillMultiSelect(PRODUCT_DETAILS.collectionInput, collection);
}) })
.then(selected => { .then(selected => {
organization.collection = selected; organization.collection = selected;

View file

@ -1,6 +1,6 @@
import { CATEGORY_DETAILS } from "../elements/catalog/categories/category-details"; import { CATEGORY_DETAILS } from "../elements/catalog/categories/category-details";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage"; import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
export function createCategory({ name, description }) { export function createCategory({ name, description }) {
cy.get(CATEGORY_DETAILS.nameInput) cy.get(CATEGORY_DETAILS.nameInput)

View file

@ -6,13 +6,15 @@ import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-
import { HEADER_SELECTORS } from "../elements/header/header-selectors"; import { HEADER_SELECTORS } from "../elements/header/header-selectors";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements"; import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
import { urlList } from "../url/urlList";
import { fillAutocompleteSelect } from "./shared/selects"; import { fillAutocompleteSelect } from "./shared/selects";
export function createChannelByView({ export function createChannelByView({
name, name,
currency, currency,
slug = name, slug = name,
shippingZone shippingZone,
defaultCountry = "Poland"
}) { }) {
cy.addAliasToGraphRequest("Channel") cy.addAliasToGraphRequest("Channel")
.get(CHANNELS_SELECTORS.createChannelButton) .get(CHANNELS_SELECTORS.createChannelButton)
@ -31,6 +33,10 @@ export function createChannelByView({
cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyAutocompleteDropdown).click(); cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyAutocompleteDropdown).click();
} }
}); });
fillAutocompleteSelect(
ADD_CHANNEL_FORM_SELECTORS.countryAutocompleteInput,
defaultCountry
);
if (shippingZone) { if (shippingZone) {
addShippingZone(shippingZone); addShippingZone(shippingZone);
} }
@ -96,3 +102,15 @@ export function selectChannelVariantInDetailsPage(channelName, attributeName) {
.find(BUTTON_SELECTORS.submit) .find(BUTTON_SELECTORS.submit)
.click(); .click();
} }
export function enterHomePageAndChangeChannel(channelName) {
cy.visit(urlList.homePage);
selectChannelInHeader(channelName);
}
export function enterHomePageChangeChannelAndReturn(channelName) {
cy.url().then(url => {
enterHomePageAndChangeChannel(channelName);
cy.visit(url);
});
}

View file

@ -58,7 +58,8 @@ export function getDisplayedSelectors(selectors = LEFT_MENU_SELECTORS) {
export function expectAllSelectorsPermitted(permissions, selectors) { export function expectAllSelectorsPermitted(permissions, selectors) {
Object.values(selectors).forEach(selector => { Object.values(selectors).forEach(selector => {
const isSelectorPermitted = isPermitted(permissions, selector); const isSelectorPermitted = isPermitted(permissions, selector);
expect(isSelectorPermitted).to.be.true; expect(isSelectorPermitted, `${selector} selector should be in permitted`)
.to.be.true;
}); });
} }
function isPermitted(permissions, selector) { function isPermitted(permissions, selector) {

View file

@ -1,5 +1,8 @@
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { selectorWithDataValue } from "../../elements/shared/sharedElements"; import {
selectorWithDataValue,
SHARED_ELEMENTS
} from "../../elements/shared/sharedElements";
export function fillAutocompleteSelect(selectSelector, option) { export function fillAutocompleteSelect(selectSelector, option) {
cy.get(selectSelector) cy.get(selectSelector)
@ -12,16 +15,26 @@ export function fillAutocompleteSelect(selectSelector, option) {
cy.wrap(option).as("option"); cy.wrap(option).as("option");
} else { } else {
cy.get(BUTTON_SELECTORS.selectOption) cy.get(BUTTON_SELECTORS.selectOption)
.wait(1000)
.first() .first()
.invoke("text") .invoke("text")
.as("option"); .as("option")
cy.get(BUTTON_SELECTORS.selectOption) .get(BUTTON_SELECTORS.selectOption)
.first() .first()
.click(); .click();
} }
return cy.get("@option"); return cy.get("@option");
} }
export function fillMultiSelect(selectSelector, option) {
fillAutocompleteSelect(selectSelector, option).then(returnedOption => {
cy.get(SHARED_ELEMENTS.header)
.first()
.click({ force: true });
return cy.wrap(returnedOption);
});
}
export function fillBaseSelect(selectSelector, value) { export function fillBaseSelect(selectSelector, value) {
cy.get(selectSelector) cy.get(selectSelector)
.click() .click()

View file

@ -1,5 +1,11 @@
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { waitForProgressBarToNotExist } from "./progressBar";
export function searchInTable(query) {
cy.get(SHARED_ELEMENTS.searchInput).type(query);
waitForProgressBarToNotExist();
}
export function findElementOnTable(elementName) { export function findElementOnTable(elementName) {
cy.getTextFromElement(SHARED_ELEMENTS.table).then(tableText => { cy.getTextFromElement(SHARED_ELEMENTS.table).then(tableText => {

View file

@ -31,16 +31,11 @@ export function createShippingZone(
confirmationMessageShouldDisappear(); confirmationMessageShouldDisappear();
cy.get(SHIPPING_ZONE_DETAILS.warehouseSelector) cy.get(SHIPPING_ZONE_DETAILS.warehouseSelector)
.click() .click()
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
.scrollTo("bottom")
// Remove this code between comments after fixing bug: SALEOR-3611
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
.should("not.exist")
.get(SHIPPING_ZONE_DETAILS.warehouseSelector) .get(SHIPPING_ZONE_DETAILS.warehouseSelector)
.click() .type(warehouseName)
// Remove this code between comments after fixing bug: SALEOR-3611 .get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
.get(SHIPPING_ZONE_DETAILS.option) .scrollTo("bottom");
.contains(warehouseName) cy.contains(SHIPPING_ZONE_DETAILS.option, warehouseName)
.click({ force: true }) .click({ force: true })
.get(SHIPPING_ZONE_DETAILS.channelSelector) .get(SHIPPING_ZONE_DETAILS.channelSelector)
.click() .click()

View file

@ -3,6 +3,7 @@ import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm"; import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails"; import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
import { userDetailsUrl } from "../url/urlList"; import { userDetailsUrl } from "../url/urlList";
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages";
import { visitAndWaitForProgressBarToDisappear } from "./shared/progressBar"; import { visitAndWaitForProgressBarToDisappear } from "./shared/progressBar";
import { fillAutocompleteSelect } from "./shared/selects"; import { fillAutocompleteSelect } from "./shared/selects";
@ -26,6 +27,7 @@ export function fillUpUserDetails(firstName, lastName, email) {
.type(email) .type(email)
.get(BUTTON_SELECTORS.submit) .get(BUTTON_SELECTORS.submit)
.click(); .click();
confirmationMessageShouldDisappear();
fillAutocompleteSelect(STAFF_MEMBER_DETAILS.permissionsSelect); fillAutocompleteSelect(STAFF_MEMBER_DETAILS.permissionsSelect);
cy.addAliasToGraphRequest("StaffMemberUpdate"); cy.addAliasToGraphRequest("StaffMemberUpdate");
cy.get(BUTTON_SELECTORS.confirm) cy.get(BUTTON_SELECTORS.confirm)

View file

@ -6,3 +6,7 @@ export function getFormattedCurrencyAmount(amount, currency) {
}); });
return formattedCurrencyAmount; return formattedCurrencyAmount;
} }
export function getCurrencyAndAmountInString(amount, currency) {
return `${currency}${amount.toFixed(2)}`;
}