diff --git a/cypress.json b/cypress.json index 9380de1ab..b05c315bd 100644 --- a/cypress.json +++ b/cypress.json @@ -1,5 +1,5 @@ { - "baseUrl": "http://localhost:9000/dashboard/", + "baseUrl": "http://localhost:9000/", "defaultCommandTimeout": 15000, "requestTimeout": 15000, "viewportWidth": 1400, diff --git a/cypress/apiRequests/Checkout.js b/cypress/apiRequests/Checkout.js index f471fab10..b3b219721 100644 --- a/cypress/apiRequests/Checkout.js +++ b/cypress/apiRequests/Checkout.js @@ -29,7 +29,7 @@ export function createCheckout({ ${shippingAddress} ${billingAddressLines} }){ - checkoutErrors{ + errors{ field message } @@ -44,8 +44,9 @@ export function createCheckout({ }`; return cy .sendRequestWithQuery(mutation, auth) - .its("body.data.checkoutCreate.checkout"); + .its("body.data.checkoutCreate"); } + export function addShippingMethod(checkoutId, shippingMethodId) { const mutation = `mutation{ checkoutShippingMethodUpdate(checkoutId:"${checkoutId}", diff --git a/cypress/integration/allEnv/checkout/warehouses.js b/cypress/integration/allEnv/checkout/warehouses.js new file mode 100644 index 000000000..79f69ed39 --- /dev/null +++ b/cypress/integration/allEnv/checkout/warehouses.js @@ -0,0 +1,68 @@ +import faker from "faker"; + +import { createCheckout } from "../../../apiRequests/Checkout"; +import { getDefaultChannel } from "../../../utils/channelsUtils"; +import { + createProductInChannel, + createTypeAttributeAndCategoryForProduct, + deleteProductsStartsWith +} from "../../../utils/products/productsUtils"; +import { + createShipping, + deleteShippingStartsWith +} from "../../../utils/shippingUtils"; + +describe("Warehouses in checkout", () => { + const startsWith = `CyWarehouseCheckout`; + let defaultChannel; + let usAddress; + let plAddress; + let warehouse; + + it("should not be possible to buy product for country not listed in warehouse", () => { + cy.clearSessionData().loginUserViaRequest(); + deleteShippingStartsWith(startsWith); + deleteProductsStartsWith(startsWith); + const name = `${startsWith}${faker.datatype.number()}`; + cy.fixture("addresses") + .then(addresses => { + usAddress = addresses.usAddress; + plAddress = addresses.plAddress; + getDefaultChannel(); + }) + .then(channelResp => { + defaultChannel = channelResp; + createShipping({ + channelId: defaultChannel.id, + name, + address: usAddress + }); + }) + .then(({ warehouse: warehouseResp }) => { + warehouse = warehouseResp; + createTypeAttributeAndCategoryForProduct(name); + }) + .then(({ attribute, productType, category }) => { + createProductInChannel({ + name, + attributeId: attribute.id, + categoryId: category.id, + channelId: defaultChannel.id, + productTypeId: productType.id, + warehouseId: warehouse.id, + quantityInWarehouse: 100 + }); + }) + .then(({ variantsList }) => { + createCheckout({ + channelSlug: defaultChannel.slug, + email: "example@example.com", + variantsList, + address: plAddress + }); + }) + .then(({ errors }) => { + expect(errors[0]).to.have.property("field", "quantity"); + }); + }); +}); diff --git a/cypress/integration/allEnv/configuration/purchaseWithProductTypes.js b/cypress/integration/allEnv/configuration/purchaseWithProductTypes.js deleted file mode 100644 index 9b3897989..000000000 --- a/cypress/integration/allEnv/configuration/purchaseWithProductTypes.js +++ /dev/null @@ -1,233 +0,0 @@ -import faker from "faker"; - -import { createAttribute } from "../../../apiRequests/Attribute"; -import { createCategory } from "../../../apiRequests/Category"; -import { - checkoutShippingAddressUpdate, - checkoutShippingMethodUpdate, - checkoutVariantsUpdate, - completeCheckout, - createCheckout -} from "../../../apiRequests/Checkout"; -import { getOrder } from "../../../apiRequests/Order"; -import { createTypeProduct } from "../../../apiRequests/Product"; -import { getDefaultChannel } from "../../../utils/channelsUtils"; -import { - addPayment, - createAndCompleteCheckoutWithoutShipping, - createWaitingForCaptureOrder -} from "../../../utils/ordersUtils"; -import { - createProductInChannel, - deleteProductsStartsWith -} from "../../../utils/products/productsUtils"; -import { - createShipping, - deleteShippingStartsWith -} from "../../../utils/shippingUtils"; - -describe("Purchase products with all products types", () => { - const startsWith = `CyPurchaseByType`; - const name = `${startsWith}${faker.datatype.number()}`; - const email = `${startsWith}@example.com`; - const testsMessage = "Check order status"; - const { softExpect } = chai; - - let defaultChannel; - let address; - let warehouse; - let attribute; - let category; - let shippingMethod; - let createProductData; - - before(() => { - cy.clearSessionData().loginUserViaRequest(); - deleteProductsStartsWith(startsWith); - deleteShippingStartsWith(startsWith); - getDefaultChannel().then(channelResp => (defaultChannel = channelResp)); - cy.fixture("addresses") - .then(addresses => { - address = addresses.usAddress; - createShipping({ - channelId: defaultChannel.id, - name, - address, - price: 10 - }); - }) - .then( - ({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => { - warehouse = warehouseResp; - shippingMethod = shippingMethodResp; - } - ); - createAttribute(name) - .then(attributeResp => { - attribute = attributeResp; - createCategory(name); - }) - .then(categoryResp => { - category = categoryResp; - }); - }); - - beforeEach(() => { - cy.clearSessionData().loginUserViaRequest(); - createProductData = { - channelId: defaultChannel.id, - warehouseId: warehouse.id, - quantityInWarehouse: 10, - attributeId: attribute.id, - categoryId: category.id, - price: 10 - }; - }); - - it("should purchase digital product", () => { - const digitalName = `${startsWith}${faker.datatype.number()}`; - createTypeProduct({ - name: digitalName, - attributeId: attribute.id, - shippable: false - }) - .then(productType => { - createProductData.name = digitalName; - createProductData.productTypeId = productType.id; - createProductInChannel(createProductData); - }) - .then(({ variantsList }) => { - createAndCompleteCheckoutWithoutShipping({ - channelSlug: defaultChannel.slug, - email, - billingAddress: address, - variantsList, - auth: "token" - }); - }) - .then(({ order }) => { - getOrder(order.id); - }) - .then(order => { - softExpect( - order.isShippingRequired, - "Check if is shipping required in order" - ).to.eq(false); - expect(order.status, testsMessage).to.be.eq("UNFULFILLED"); - }); - }); - - it("should purchase physical product", () => { - const physicalName = `${startsWith}${faker.datatype.number()}`; - createTypeProduct({ - name: physicalName, - attributeId: attribute.id, - shippable: true - }) - .then(productType => { - createProductData.name = physicalName; - createProductData.productTypeId = productType.id; - createProductInChannel(createProductData); - }) - .then(({ variantsList }) => { - createWaitingForCaptureOrder( - defaultChannel.slug, - email, - variantsList, - shippingMethod.id, - address - ); - }) - .then(({ order }) => { - getOrder(order.id); - }) - .then(order => { - softExpect( - order.isShippingRequired, - "Check if is shipping required in order" - ).to.eq(true); - expect(order.status, testsMessage).to.be.eq("UNFULFILLED"); - }); - }); - it("should purchase multiple products with all product types", () => { - const physicalName = `${startsWith}${faker.datatype.number()}`; - const digitalName = `${startsWith}${faker.datatype.number()}`; - let digitalProductVariantsList; - let checkout; - createTypeProduct({ - name: digitalName, - attributeId: attribute.id, - shippable: false - }) - .then(productType => { - createProductData.name = digitalName; - createProductData.productTypeId = productType.id; - createProductInChannel(createProductData); - }) - .then(({ variantsList }) => { - digitalProductVariantsList = variantsList; - createCheckout({ - channelSlug: defaultChannel.slug, - email, - variantsList: digitalProductVariantsList, - billingAddress: address, - auth: "token" - }); - }) - .then(checkoutResp => { - checkout = checkoutResp; - addPayment(checkout.id); - }) - .then(() => { - createTypeProduct({ - name: physicalName, - attributeId: attribute.id, - shippable: true - }); - }) - .then(productType => { - createProductData.name = physicalName; - createProductData.productTypeId = productType.id; - createProductInChannel(createProductData); - }) - .then(({ variantsList }) => { - checkoutVariantsUpdate(checkout.id, variantsList); - }) - .then(() => { - checkoutShippingMethodUpdate(checkout.id, shippingMethod.id); - }) - .then(({ checkoutErrors }) => { - expect( - checkoutErrors, - "Should be not possible to add shipping method without shipping address" - ).to.have.lengthOf(1); - checkoutShippingAddressUpdate(checkout.id, address); - }) - .then(() => { - addPayment(checkout.id); - }) - .then(({ paymentErrors }) => { - expect( - paymentErrors, - "Should be not possible to add payment without shipping" - ).to.have.lengthOf(1); - checkoutShippingMethodUpdate(checkout.id, shippingMethod.id); - }) - .then(() => { - addPayment(checkout.id); - }) - .then(() => { - completeCheckout(checkout.id); - }) - .then(({ order }) => { - getOrder(order.id); - }) - .then(order => { - softExpect( - order.isShippingRequired, - "Check if is shipping required in order" - ).to.eq(true); - expect(order.status, testsMessage).to.be.eq("UNFULFILLED"); - }); - }); -}); diff --git a/cypress/integration/allEnv/configuration/shippingMethod.js b/cypress/integration/allEnv/configuration/shippingMethod.js index 87aea03de..79cf2af39 100644 --- a/cypress/integration/allEnv/configuration/shippingMethod.js +++ b/cypress/integration/allEnv/configuration/shippingMethod.js @@ -173,7 +173,7 @@ describe("Shipping methods", () => { variantsList, address: plAddress, auth: "token" - }).then(checkout => { + }).then(({ checkout }) => { const isShippingAvailable = isShippingAvailableInCheckout( checkout, shippingName @@ -198,7 +198,7 @@ describe("Shipping methods", () => { variantsList, address: plAddress, auth: "token" - }).then(checkout => { + }).then(({ checkout }) => { const isShippingAvailable = isShippingAvailableInCheckout( checkout, shippingName diff --git a/cypress/integration/allEnv/homePage/homePageAnalitics.js b/cypress/integration/allEnv/homePage/homePageAnalitics.js index 41110c169..cbff052ba 100644 --- a/cypress/integration/allEnv/homePage/homePageAnalitics.js +++ b/cypress/integration/allEnv/homePage/homePageAnalitics.js @@ -95,7 +95,9 @@ describe("Homepage analytics", () => { }); it("should all elements be visible on the dashboard", () => { - cy.visit(urlList.homePage) + cy.pause(); + cy.visit(urlList.homePage); + cy.pause() .softAssertVisibility(HOMEPAGE_SELECTORS.sales) .softAssertVisibility(HOMEPAGE_SELECTORS.orders) .softAssertVisibility(HOMEPAGE_SELECTORS.activity) diff --git a/cypress/integration/allEnv/productTypes/purchaseWithProductTypes.js b/cypress/integration/allEnv/productTypes/purchaseWithProductTypes.js index 9b3897989..3b325d573 100644 --- a/cypress/integration/allEnv/productTypes/purchaseWithProductTypes.js +++ b/cypress/integration/allEnv/productTypes/purchaseWithProductTypes.js @@ -174,7 +174,7 @@ describe("Purchase products with all products types", () => { auth: "token" }); }) - .then(checkoutResp => { + .then(({ checkout: checkoutResp }) => { checkout = checkoutResp; addPayment(checkout.id); }) diff --git a/cypress/integration/stagedOnly/adyen.js b/cypress/integration/stagedOnly/adyen.js index 5b7962f17..3ade32aeb 100644 --- a/cypress/integration/stagedOnly/adyen.js +++ b/cypress/integration/stagedOnly/adyen.js @@ -93,7 +93,7 @@ describe("Adyen payments", () => { billingAddress: address, auth: "token" }) - .then(checkoutResp => { + .then(({ checkout: checkoutResp }) => { checkout = checkoutResp; addShippingMethod(checkout.id, shippingMethod.id); }) diff --git a/cypress/utils/ordersUtils.js b/cypress/utils/ordersUtils.js index 4ebc19022..9d06ba7cd 100644 --- a/cypress/utils/ordersUtils.js +++ b/cypress/utils/ordersUtils.js @@ -13,7 +13,7 @@ export function createWaitingForCaptureOrder( cy.loginInShop(); return checkoutRequest .createCheckout({ channelSlug, email, variantsList, address, auth }) - .then(checkoutResp => { + .then(({ checkout: checkoutResp }) => { checkout = checkoutResp; checkoutRequest.addShippingMethod(checkout.id, shippingMethodId); }) @@ -34,7 +34,7 @@ export function createCheckoutWithVoucher({ let checkout; return checkoutRequest .createCheckout({ channelSlug, email, variantsList, address, auth }) - .then(checkoutResp => { + .then(({ checkout: checkoutResp }) => { checkout = checkoutResp; checkoutRequest.addShippingMethod(checkout.id, shippingMethodId); }) @@ -137,7 +137,7 @@ export function createAndCompleteCheckoutWithoutShipping({ let checkout; return checkoutRequest .createCheckout({ channelSlug, email, variantsList, billingAddress, auth }) - .then(checkoutResp => { + .then(({ checkout: checkoutResp }) => { checkout = checkoutResp; addPayment(checkout.id); })