From e7a06281f1a6e660f32b3313b08527c3a4b8e6be Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Fri, 10 Sep 2021 10:59:46 +0200 Subject: [PATCH] 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 --- cypress/apiRequests/Attribute.js | 14 +++++++++---- cypress/apiRequests/Channels.js | 7 +++++-- cypress/apiRequests/Order.js | 14 +++++++++++++ .../channels/add-channel-form-selectors.js | 3 ++- cypress/elements/shared/sharedElements.js | 4 +++- cypress/integration/categories.js | 2 +- .../configuration/attributes/filters.js | 15 ++++++++----- cypress/integration/configuration/channels.js | 1 + .../shippingMethods/channelsInShipping.js | 21 ++++++++++++------- .../orders/channelsInDraftOrders.js | 2 ++ cypress/integration/orders/draftOrders.js | 2 ++ cypress/integration/orders/orders.js | 6 ++---- .../productsList/filteringProducts.js | 4 +++- .../integration/products/productsVariants.js | 10 ++++----- cypress/integration/staffMembers.js | 6 ++++-- cypress/steps/attributesSteps.js | 7 ++++--- .../steps/catalog/products/VariantsSteps.js | 9 ++++---- .../steps/catalog/products/productSteps.js | 4 ++-- cypress/steps/categoriesSteps.js | 2 +- cypress/steps/channelsSteps.js | 20 +++++++++++++++++- cypress/steps/permissions.js | 3 ++- cypress/steps/shared/selects.js | 19 ++++++++++++++--- cypress/steps/shared/tables.js | 6 ++++++ cypress/steps/shippingMethodSteps.js | 13 ++++-------- cypress/steps/user.js | 2 ++ .../support/format/formatCurrencyAmount.js | 4 ++++ 26 files changed, 142 insertions(+), 58 deletions(-) diff --git a/cypress/apiRequests/Attribute.js b/cypress/apiRequests/Attribute.js index 4061e2032..fc565fe5d 100644 --- a/cypress/apiRequests/Attribute.js +++ b/cypress/apiRequests/Attribute.js @@ -2,7 +2,8 @@ export function createAttribute({ name, attributeValues = ["value"], type = "PRODUCT_TYPE", - inputType = "DROPDOWN" + inputType = "DROPDOWN", + filterableInDashboard = false }) { const values = attributeValues.map(element => `{name:"${element}"}`); const mutation = `mutation{ @@ -12,6 +13,7 @@ export function createAttribute({ type:${type} values: [${values}] inputType: ${inputType} + filterableInDashboard: ${filterableInDashboard} }){ attribute{ id @@ -84,11 +86,15 @@ export function getAttribute(attributeId) { return cy.sendRequestWithQuery(query).its("body.data.attribute"); } -export function updateAttribute({ filterableInDashboard }) { +export function updateAttribute({ attributeId, filterableInDashboard }) { const mutation = `mutation{ - attributeUpdate(id:"" input:{ - filterableInDashboard:false + attributeUpdate(id:"${attributeId}" input:{ + filterableInDashboard: ${filterableInDashboard} }){ + attribute{ + id + filterableInDashboard + } errors{ field message diff --git a/cypress/apiRequests/Channels.js b/cypress/apiRequests/Channels.js index 27bdca4e4..fcdd9a642 100644 --- a/cypress/apiRequests/Channels.js +++ b/cypress/apiRequests/Channels.js @@ -2,7 +2,8 @@ export function createChannel({ isActive = true, name, slug = name, - currencyCode = "PLN" + currencyCode = "PLN", + defaultCountry = "PL" }) { const createChannelMutation = `mutation{ channelCreate(input: { @@ -10,13 +11,14 @@ export function createChannel({ name: "${name}" slug: "${slug}" currencyCode: "${currencyCode}" + defaultCountry: ${defaultCountry} }){ channel{ id name slug } - channelErrors{ + errors{ code message } @@ -26,6 +28,7 @@ export function createChannel({ .sendRequestWithQuery(createChannelMutation) .its("body.data.channelCreate.channel"); } + export function getChannels() { const getChannelsInfoQuery = `query{ channels{ diff --git a/cypress/apiRequests/Order.js b/cypress/apiRequests/Order.js index 88fec7252..800945a8a 100644 --- a/cypress/apiRequests/Order.js +++ b/cypress/apiRequests/Order.js @@ -11,6 +11,20 @@ export function markOrderAsPaid(orderId) { 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) { const mutation = `mutation{ orderLinesCreate(id:"${orderId}", input:{ diff --git a/cypress/elements/channels/add-channel-form-selectors.js b/cypress/elements/channels/add-channel-form-selectors.js index fda52da8f..f9ecc2585 100644 --- a/cypress/elements/channels/add-channel-form-selectors.js +++ b/cypress/elements/channels/add-channel-form-selectors.js @@ -10,5 +10,6 @@ export const ADD_CHANNEL_FORM_SELECTORS = { currencyAutocompleteDropdown: "[data-test='singleautocomplete-select-option'][data-test-type='custom']", 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"]' }; diff --git a/cypress/elements/shared/sharedElements.js b/cypress/elements/shared/sharedElements.js index 91c4b67ad..51d713efe 100644 --- a/cypress/elements/shared/sharedElements.js +++ b/cypress/elements/shared/sharedElements.js @@ -2,6 +2,7 @@ export const SHARED_ELEMENTS = { header: "[data-test-id='page-header']", progressBar: '[role="progressbar"]', circularProgress: '[class*="CircularProgress-circle"]', + autocompleteCircle: '[class*="arrowInnerContainer"]', skeleton: '[data-test-id="skeleton"]', table: 'table[class*="Table"]', tableRow: '[data-test="id"], [class*="MuiTableRow"]', @@ -14,7 +15,8 @@ export const SHARED_ELEMENTS = { empty: '[class*="codex-editor--empty"]' }, filters: { - filterGroupActivateCheckbox: '[data-test="filterGroupActive"]' + filterGroupActivateCheckbox: '[data-test="filterGroupActive"]', + filterRow: '[data-test="channel-availability-item"]' } }; diff --git a/cypress/integration/categories.js b/cypress/integration/categories.js index 91244efe2..cd7b2537d 100644 --- a/cypress/integration/categories.js +++ b/cypress/integration/categories.js @@ -124,7 +124,7 @@ filterTests(["all"], () => { .should("not.exist") .wait("@productBulkDelete"); getCategory(category.id).then(categoryResp => { - expect(categoryResp.products).to.be.null; + expect(categoryResp.products.edges.length).to.be.eq(0); }); }); diff --git a/cypress/integration/configuration/attributes/filters.js b/cypress/integration/configuration/attributes/filters.js index 6d2b248a1..b74d780c2 100644 --- a/cypress/integration/configuration/attributes/filters.js +++ b/cypress/integration/configuration/attributes/filters.js @@ -35,18 +35,23 @@ describe("Tests for using attributes in filters", () => { }); it("should use attribute as filter", () => { - updateAttribute({ filterableInDashboard: false }); + updateAttribute({ + attributeId: attribute.id, + filterableInDashboard: false + }); enterAttributeAndChanegeIsFilterableInDashbord(attribute.id); enterProductListPage(); - selectAttributeFilter(attribute.slug, startsWith); - cy.contains(SHARED_ELEMENTS.tableRow, startsWith).should("be.visible"); + selectAttributeFilter(attribute.slug, attribute.name); + cy.contains(SHARED_ELEMENTS.tableRow, attribute.name).should("be.visible"); }); it("should remove attribute from filters", () => { - updateAttribute({ filterableInDashboard: false }); + updateAttribute({ attributeId: attribute.id, filterableInDashboard: true }); enterAttributeAndChanegeIsFilterableInDashbord(attribute.id); enterProductListPage(); showFilters(); - cy.contains(attribute.name).should("not.exist"); + cy.contains(SHARED_ELEMENTS.filters.filterRow, attribute.name).should( + "not.exist" + ); }); }); diff --git a/cypress/integration/configuration/channels.js b/cypress/integration/configuration/channels.js index 713ea885d..aa8723b5c 100644 --- a/cypress/integration/configuration/channels.js +++ b/cypress/integration/configuration/channels.js @@ -26,6 +26,7 @@ filterTests(["all"], () => { const channelStartsWith = `CyChannels`; const randomName = `${channelStartsWith} ${faker.datatype.number()}`; const currency = "PLN"; + const defaultCountry = "Poland"; let shippingZone; before(() => { diff --git a/cypress/integration/configuration/shippingMethods/channelsInShipping.js b/cypress/integration/configuration/shippingMethods/channelsInShipping.js index 891aa8124..c913ea647 100644 --- a/cypress/integration/configuration/shippingMethods/channelsInShipping.js +++ b/cypress/integration/configuration/shippingMethods/channelsInShipping.js @@ -10,10 +10,13 @@ import { ONE_PERMISSION_USERS } from "../../../Data/users"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements"; import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details"; -import { selectChannelInHeader } from "../../../steps/channelsSteps"; -import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar"; +import { enterHomePageChangeChannelAndReturn } from "../../../steps/channelsSteps"; +import { + waitForProgressBarToNotBeVisible, + waitForProgressBarToNotExist +} from "../../../steps/shared/progressBar"; import filterTests from "../../../support/filterTests"; -import { getFormattedCurrencyAmount } from "../../../support/format/formatCurrencyAmount"; +import { getCurrencyAndAmountInString } from "../../../support/format/formatCurrencyAmount"; import { urlList } from "../../../url/urlList"; import * as channelsUtils from "../../../utils/channelsUtils"; import * as shippingUtils from "../../../utils/shippingUtils"; @@ -98,18 +101,22 @@ filterTests(["all"], () => { } cy.contains(shippingZone.name).click(); cy.wait("@ShippingZone"); - selectChannelInHeader(defaultChannel.name); + enterHomePageChangeChannelAndReturn(defaultChannel.name); + waitForProgressBarToNotBeVisible(); + cy.get(SHARED_ELEMENTS.skeleton).should("not.exist"); cy.getTextFromElement( SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell ) .then(text => { - const expectedValue = getFormattedCurrencyAmount( + const expectedValue = getCurrencyAndAmountInString( defaultChannelPrice, defaultChannel.currencyCode ); expect(text).to.be.eq(expectedValue); - selectChannelInHeader(createdChannel.name); + enterHomePageChangeChannelAndReturn(createdChannel.name); + waitForProgressBarToNotBeVisible(); + cy.get(SHARED_ELEMENTS.skeleton).should("not.exist"); }) .then(() => { cy.getTextFromElement( @@ -117,7 +124,7 @@ filterTests(["all"], () => { ); }) .then(text => { - const expectedValue = getFormattedCurrencyAmount( + const expectedValue = getCurrencyAndAmountInString( createdChannelPrice, createdChannelCurrency ); diff --git a/cypress/integration/orders/channelsInDraftOrders.js b/cypress/integration/orders/channelsInDraftOrders.js index ccfe34543..109e94ef1 100644 --- a/cypress/integration/orders/channelsInDraftOrders.js +++ b/cypress/integration/orders/channelsInDraftOrders.js @@ -63,6 +63,7 @@ filterTests(["all"], () => { } ); }); + it("Draft order channel should be taken from global channel picker when changed", () => { cy.visit(urlList.homePage); selectChannelInHeader(otherChannel.name); @@ -80,6 +81,7 @@ filterTests(["all"], () => { } ); }); + it("should create draft order with chosen channel", () => { cy.visit(urlList.homePage); selectChannelInHeader(defaultChannel.name); diff --git a/cypress/integration/orders/draftOrders.js b/cypress/integration/orders/draftOrders.js index 79c4e2ed1..472e5f7b6 100644 --- a/cypress/integration/orders/draftOrders.js +++ b/cypress/integration/orders/draftOrders.js @@ -5,6 +5,7 @@ import { createCustomer, deleteCustomersStartsWith } from "../../apiRequests/Customer"; +import { updateOrdersSettings } from "../../apiRequests/Order"; import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors"; import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors"; import { selectChannelInPicker } from "../../steps/channelsSteps"; @@ -33,6 +34,7 @@ filterTests(["all"], () => { deleteShippingStartsWith(startsWith); productsUtils.deleteProductsStartsWith(startsWith); + updateOrdersSettings(); getDefaultChannel() .then(channel => { defaultChannel = channel; diff --git a/cypress/integration/orders/orders.js b/cypress/integration/orders/orders.js index 0a67be907..03b6b8ceb 100644 --- a/cypress/integration/orders/orders.js +++ b/cypress/integration/orders/orders.js @@ -5,7 +5,7 @@ import { createCustomer, deleteCustomersStartsWith } from "../../apiRequests/Customer"; -import { getOrder } from "../../apiRequests/Order"; +import { getOrder, updateOrdersSettings } from "../../apiRequests/Order"; import { ONE_PERMISSION_USERS } from "../../Data/users"; import { ORDER_REFUND } from "../../elements/orders/order-refund"; import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors"; @@ -46,6 +46,7 @@ filterTests(["all"], () => { deleteShippingStartsWith(startsWith); productsUtils.deleteProductsStartsWith(startsWith); + updateOrdersSettings(); getDefaultChannel() .then(channel => { defaultChannel = channel; @@ -158,9 +159,6 @@ filterTests(["all"], () => { cy.contains(ORDERS_SELECTORS.orderRow, order.number).click(); cy.get(SHARED_ELEMENTS.skeleton) .should("not.exist") - .get(ORDERS_SELECTORS.orderFulfillmentFrame) - .find(BUTTON_SELECTORS.showMoreButton) - .click() .get(ORDERS_SELECTORS.cancelFulfillment) .click(); }) diff --git a/cypress/integration/products/productsList/filteringProducts.js b/cypress/integration/products/productsList/filteringProducts.js index eae0f1577..5a13f5b26 100644 --- a/cypress/integration/products/productsList/filteringProducts.js +++ b/cypress/integration/products/productsList/filteringProducts.js @@ -9,6 +9,7 @@ import { selectProductsOutOfStock } from "../../../steps/catalog/products/productsListSteps"; import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar"; +import { searchInTable } from "../../../steps/shared/tables"; import filterTests from "../../../support/filterTests"; import { urlList } from "../../../url/urlList"; import { getDefaultChannel } from "../../../utils/channelsUtils"; @@ -112,9 +113,10 @@ filterTests(["all"], () => { categoryId: category.id, price }); - waitForProgressBarToNotExist(); selectChannel(channel.slug); selectProductsOutOfStock(); + searchInTable(productOutOfStock); + cy.get(PRODUCTS_LIST.productsNames).should("have.length", 1); cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => { expect(product).to.includes(productOutOfStock); }); diff --git a/cypress/integration/products/productsVariants.js b/cypress/integration/products/productsVariants.js index 7ba27a078..4bd4e8f1f 100644 --- a/cypress/integration/products/productsVariants.js +++ b/cypress/integration/products/productsVariants.js @@ -11,7 +11,7 @@ import { createVariant, variantsShouldBeVisible } from "../../steps/catalog/products/VariantsSteps"; -import { selectChannelInHeader } from "../../steps/channelsSteps"; +import { enterHomePageChangeChannelAndReturn } from "../../steps/channelsSteps"; import filterTests from "../../support/filterTests"; import { urlList } from "../../url/urlList"; import { @@ -106,7 +106,7 @@ filterTests(["all", "critical"], () => { price, attribute: attributeValues[0] }); - selectChannelInHeader(defaultChannel.name); + enterHomePageChangeChannelAndReturn(defaultChannel.name); variantsShouldBeVisible({ name, price }); getProductVariants(createdProduct.id, defaultChannel.slug); }) @@ -144,7 +144,7 @@ filterTests(["all", "critical"], () => { }); }) .then(() => { - selectChannelInHeader(defaultChannel.name); + enterHomePageChangeChannelAndReturn(defaultChannel.name); variantsShouldBeVisible({ name: variants[1].name, price: variants[1].price @@ -189,9 +189,9 @@ filterTests(["all", "critical"], () => { price: variantsPrice, attribute: attributeValues[0] }); - selectChannelInHeader(defaultChannel.name); + enterHomePageChangeChannelAndReturn(defaultChannel.name); variantsShouldBeVisible({ name, price: variantsPrice }); - selectChannelInHeader(newChannel.name); + enterHomePageChangeChannelAndReturn(newChannel.name); variantsShouldBeVisible({ name, price: variantsPrice }); getProductVariants(createdProduct.id, defaultChannel.slug); }) diff --git a/cypress/integration/staffMembers.js b/cypress/integration/staffMembers.js index 7072ed4e9..3351797f2 100644 --- a/cypress/integration/staffMembers.js +++ b/cypress/integration/staffMembers.js @@ -10,6 +10,7 @@ import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetail import { STAFF_MEMBERS_LIST } from "../elements/staffMembers/staffMembersList"; import { expectWelcomeMessageIncludes } from "../steps/homePageSteps"; import { getDisplayedSelectors } from "../steps/permissions"; +import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages"; import { fillUpSetPassword, fillUpUserDetails, @@ -98,8 +99,9 @@ filterTests(["stagedOnly"], () => { .click() .addAliasToGraphRequest("StaffMemberUpdate") .get(BUTTON_SELECTORS.confirm) - .click() - .wait("@StaffMemberUpdate") + .click(); + confirmationMessageShouldDisappear(); + cy.wait("@StaffMemberUpdate") .clearSessionData() .loginUserViaRequest("auth", { email, password }) .visit(urlList.homePage); diff --git a/cypress/steps/attributesSteps.js b/cypress/steps/attributesSteps.js index 0faf266af..4b5c21536 100644 --- a/cypress/steps/attributesSteps.js +++ b/cypress/steps/attributesSteps.js @@ -2,6 +2,7 @@ import { ATTRIBUTES_DETAILS } from "../elements/attribute/attributes_details"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { attributeDetailsUrl } from "../url/urlList"; import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; +import { waitForProgressBarToNotBeVisible } from "./shared/progressBar"; export function createAttributeWithInputType({ name, @@ -86,8 +87,8 @@ export function selectNumericSystem({ unitSystem, unitsOf, unit }) { } export function enterAttributeAndChanegeIsFilterableInDashbord(attributeId) { - cy.visit(attributeDetailsUrl(attributeId)) - .get(ATTRIBUTES_DETAILS.dashboardProperties.useInFilteringCheckbox) - .click(); + cy.visit(attributeDetailsUrl(attributeId)); + waitForProgressBarToNotBeVisible(); + cy.get(ATTRIBUTES_DETAILS.dashboardProperties.useInFilteringCheckbox).click(); submitAttribute(); } diff --git a/cypress/steps/catalog/products/VariantsSteps.js b/cypress/steps/catalog/products/VariantsSteps.js index 9546f5ab8..06603a80b 100644 --- a/cypress/steps/catalog/products/VariantsSteps.js +++ b/cypress/steps/catalog/products/VariantsSteps.js @@ -8,11 +8,10 @@ import { waitForProgressBarToNotBeVisible } from "../../shared/progressBar"; import { fillUpPriceList } from "./priceList"; export function variantsShouldBeVisible({ name, price }) { - cy.contains(PRODUCT_DETAILS.variantRow, name) - .should("be.visible") - .find(PRODUCT_DETAILS.variantPrice) - .invoke("text") - .then(text => expect(text).to.includes(price)); + cy.contains(PRODUCT_DETAILS.variantRow, name).should("be.visible"); + cy.contains(PRODUCT_DETAILS.variantPrice, price); + // .invoke("text") + // .then(text => expect(text).to.includes(price)); } export function createFirstVariant({ sku, warehouseId, price, attribute }) { cy.get(PRODUCT_DETAILS.addVariantsButton).click(); diff --git a/cypress/steps/catalog/products/productSteps.js b/cypress/steps/catalog/products/productSteps.js index a005ee49c..bf8fa35a8 100644 --- a/cypress/steps/catalog/products/productSteps.js +++ b/cypress/steps/catalog/products/productSteps.js @@ -1,7 +1,7 @@ import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details"; import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; -import { fillAutocompleteSelect } from "../../shared/selects"; +import { fillAutocompleteSelect, fillMultiSelect } from "../../shared/selects"; import { addMetadataField } from "../metadataSteps"; import { editSeoSettings } from "../seoSteps"; @@ -105,7 +105,7 @@ export function fillUpCollectionAndCategory({ category, collection }) { return fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput, category) .then(selected => { organization.category = selected; - fillAutocompleteSelect(PRODUCT_DETAILS.collectionInput, collection); + fillMultiSelect(PRODUCT_DETAILS.collectionInput, collection); }) .then(selected => { organization.collection = selected; diff --git a/cypress/steps/categoriesSteps.js b/cypress/steps/categoriesSteps.js index 5cf7fdc0e..adeb27f0c 100644 --- a/cypress/steps/categoriesSteps.js +++ b/cypress/steps/categoriesSteps.js @@ -1,6 +1,6 @@ import { CATEGORY_DETAILS } from "../elements/catalog/categories/category-details"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; -import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; export function createCategory({ name, description }) { cy.get(CATEGORY_DETAILS.nameInput) diff --git a/cypress/steps/channelsSteps.js b/cypress/steps/channelsSteps.js index 04c528b4c..abeb593ed 100644 --- a/cypress/steps/channelsSteps.js +++ b/cypress/steps/channelsSteps.js @@ -6,13 +6,15 @@ import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels- import { HEADER_SELECTORS } from "../elements/header/header-selectors"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../elements/shared/sharedElements"; +import { urlList } from "../url/urlList"; import { fillAutocompleteSelect } from "./shared/selects"; export function createChannelByView({ name, currency, slug = name, - shippingZone + shippingZone, + defaultCountry = "Poland" }) { cy.addAliasToGraphRequest("Channel") .get(CHANNELS_SELECTORS.createChannelButton) @@ -31,6 +33,10 @@ export function createChannelByView({ cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyAutocompleteDropdown).click(); } }); + fillAutocompleteSelect( + ADD_CHANNEL_FORM_SELECTORS.countryAutocompleteInput, + defaultCountry + ); if (shippingZone) { addShippingZone(shippingZone); } @@ -96,3 +102,15 @@ export function selectChannelVariantInDetailsPage(channelName, attributeName) { .find(BUTTON_SELECTORS.submit) .click(); } + +export function enterHomePageAndChangeChannel(channelName) { + cy.visit(urlList.homePage); + selectChannelInHeader(channelName); +} + +export function enterHomePageChangeChannelAndReturn(channelName) { + cy.url().then(url => { + enterHomePageAndChangeChannel(channelName); + cy.visit(url); + }); +} diff --git a/cypress/steps/permissions.js b/cypress/steps/permissions.js index 95453678e..0ac9962c7 100644 --- a/cypress/steps/permissions.js +++ b/cypress/steps/permissions.js @@ -58,7 +58,8 @@ export function getDisplayedSelectors(selectors = LEFT_MENU_SELECTORS) { export function expectAllSelectorsPermitted(permissions, selectors) { Object.values(selectors).forEach(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) { diff --git a/cypress/steps/shared/selects.js b/cypress/steps/shared/selects.js index 2c7a1e35e..628f58611 100644 --- a/cypress/steps/shared/selects.js +++ b/cypress/steps/shared/selects.js @@ -1,5 +1,8 @@ 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) { cy.get(selectSelector) @@ -12,16 +15,26 @@ export function fillAutocompleteSelect(selectSelector, option) { cy.wrap(option).as("option"); } else { cy.get(BUTTON_SELECTORS.selectOption) + .wait(1000) .first() .invoke("text") - .as("option"); - cy.get(BUTTON_SELECTORS.selectOption) + .as("option") + .get(BUTTON_SELECTORS.selectOption) .first() .click(); } 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) { cy.get(selectSelector) .click() diff --git a/cypress/steps/shared/tables.js b/cypress/steps/shared/tables.js index a9481b239..0c5490204 100644 --- a/cypress/steps/shared/tables.js +++ b/cypress/steps/shared/tables.js @@ -1,5 +1,11 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; 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) { cy.getTextFromElement(SHARED_ELEMENTS.table).then(tableText => { diff --git a/cypress/steps/shippingMethodSteps.js b/cypress/steps/shippingMethodSteps.js index e901a92c3..f4118ff1a 100644 --- a/cypress/steps/shippingMethodSteps.js +++ b/cypress/steps/shippingMethodSteps.js @@ -31,16 +31,11 @@ export function createShippingZone( confirmationMessageShouldDisappear(); cy.get(SHIPPING_ZONE_DETAILS.warehouseSelector) .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) - .click() - // Remove this code between comments after fixing bug: SALEOR-3611 - .get(SHIPPING_ZONE_DETAILS.option) - .contains(warehouseName) + .type(warehouseName) + .get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog) + .scrollTo("bottom"); + cy.contains(SHIPPING_ZONE_DETAILS.option, warehouseName) .click({ force: true }) .get(SHIPPING_ZONE_DETAILS.channelSelector) .click() diff --git a/cypress/steps/user.js b/cypress/steps/user.js index 6fd6705c8..94bfc59de 100644 --- a/cypress/steps/user.js +++ b/cypress/steps/user.js @@ -3,6 +3,7 @@ import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm"; import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails"; import { userDetailsUrl } from "../url/urlList"; +import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; import { visitAndWaitForProgressBarToDisappear } from "./shared/progressBar"; import { fillAutocompleteSelect } from "./shared/selects"; @@ -26,6 +27,7 @@ export function fillUpUserDetails(firstName, lastName, email) { .type(email) .get(BUTTON_SELECTORS.submit) .click(); + confirmationMessageShouldDisappear(); fillAutocompleteSelect(STAFF_MEMBER_DETAILS.permissionsSelect); cy.addAliasToGraphRequest("StaffMemberUpdate"); cy.get(BUTTON_SELECTORS.confirm) diff --git a/cypress/support/format/formatCurrencyAmount.js b/cypress/support/format/formatCurrencyAmount.js index 6deeb7341..4a229ad34 100644 --- a/cypress/support/format/formatCurrencyAmount.js +++ b/cypress/support/format/formatCurrencyAmount.js @@ -6,3 +6,7 @@ export function getFormattedCurrencyAmount(amount, currency) { }); return formattedCurrencyAmount; } + +export function getCurrencyAndAmountInString(amount, currency) { + return `${currency}${amount.toFixed(2)}`; +}