diff --git a/cypress/apiRequests/Attribute.js b/cypress/apiRequests/Attribute.js
index 5cd8ef9d2..1c05d8c19 100644
--- a/cypress/apiRequests/Attribute.js
+++ b/cypress/apiRequests/Attribute.js
@@ -1,12 +1,11 @@
-class Attribute {
- createAttribute(name, attributeValues = ["value"]) {
- attributeValues = attributeValues.map(element => `{name:"${element}"}`);
- const mutation = `mutation{
+export function createAttribute(name, attributeValues = ["value"]) {
+ const values = attributeValues.map(element => `{name:"${element}"}`);
+ const mutation = `mutation{
attributeCreate(input:{
name:"${name}"
valueRequired:false
type:PRODUCT_TYPE
- values: [${attributeValues}]
+ values: [${values}]
}){
attribute{
id
@@ -19,11 +18,11 @@ class Attribute {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- getAttributes(first, search) {
- const mutation = `query{
+export function getAttributes(first, search) {
+ const mutation = `query{
attributes(first:${first}, filter:{
search:"${search}"
}){
@@ -35,13 +34,13 @@ class Attribute {
}
}
}`;
- return cy
- .sendRequestWithQuery(mutation)
- .then(resp => resp.body.data.attributes.edges);
- }
+ return cy
+ .sendRequestWithQuery(mutation)
+ .then(resp => resp.body.data.attributes.edges);
+}
- deleteAttribute(attributeId) {
- const mutation = `mutation{
+export function deleteAttribute(attributeId) {
+ const mutation = `mutation{
attributeDelete(id:"${attributeId}"){
attributeErrors{
field
@@ -49,7 +48,5 @@ class Attribute {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Attribute;
diff --git a/cypress/apiRequests/Category.js b/cypress/apiRequests/Category.js
index ad5d4f0dd..096e45a8b 100644
--- a/cypress/apiRequests/Category.js
+++ b/cypress/apiRequests/Category.js
@@ -1,6 +1,5 @@
-class Category {
- createCategory(name, slug = name) {
- const mutation = `mutation{
+export function createCategory(name, slug = name) {
+ const mutation = `mutation{
categoryCreate(input:{name:"${name}", slug: "${slug}"}){
productErrors{
field
@@ -11,10 +10,10 @@ class Category {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
- getCategories(first, search) {
- const mutation = `query{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function getCategories(first, search) {
+ const mutation = `query{
categories(first:${first}, filter:{
search:"${search}"
}){
@@ -26,12 +25,12 @@ class Category {
}
}
}`;
- return cy
- .sendRequestWithQuery(mutation)
- .then(resp => resp.body.data.categories.edges);
- }
- deleteCategory(categoryId) {
- const mutation = `mutation{
+ return cy
+ .sendRequestWithQuery(mutation)
+ .then(resp => resp.body.data.categories.edges);
+}
+export function deleteCategory(categoryId) {
+ const mutation = `mutation{
categoryDelete(id:"${categoryId}"){
productErrors{
field
@@ -39,7 +38,5 @@ class Category {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Category;
diff --git a/cypress/apiRequests/Channels.js b/cypress/apiRequests/Channels.js
index 6d8872798..436d9f479 100644
--- a/cypress/apiRequests/Channels.js
+++ b/cypress/apiRequests/Channels.js
@@ -1,6 +1,5 @@
-class Channels {
- createChannel(isActive, name, slug, currencyCode) {
- const createChannelMutation = `mutation{
+export function createChannel(isActive, name, slug, currencyCode) {
+ const createChannelMutation = `mutation{
channelCreate(input: {
isActive: ${isActive}
name: "${name}"
@@ -18,10 +17,10 @@ class Channels {
}
}
}`;
- return cy.sendRequestWithQuery(createChannelMutation);
- }
- getChannels() {
- const getChannelsInfoQuery = `query{
+ return cy.sendRequestWithQuery(createChannelMutation);
+}
+export function getChannels() {
+ const getChannelsInfoQuery = `query{
channels{
name
id
@@ -31,11 +30,11 @@ class Channels {
}
}
`;
- return cy.sendRequestWithQuery(getChannelsInfoQuery);
- }
+ return cy.sendRequestWithQuery(getChannelsInfoQuery);
+}
- deleteChannel(channelId, targetChannelId) {
- const deleteChannelMutation = `mutation{
+export function deleteChannel(channelId, targetChannelId) {
+ const deleteChannelMutation = `mutation{
channelDelete(id: "${channelId}", input:{
targetChannel: "${targetChannelId}"
}){
@@ -47,7 +46,5 @@ class Channels {
}
}
}`;
- return cy.sendRequestWithQuery(deleteChannelMutation);
- }
+ return cy.sendRequestWithQuery(deleteChannelMutation);
}
-export default Channels;
diff --git a/cypress/apiRequests/Checkout.js b/cypress/apiRequests/Checkout.js
index 28f9fbf69..5315d82f6 100644
--- a/cypress/apiRequests/Checkout.js
+++ b/cypress/apiRequests/Checkout.js
@@ -1,10 +1,14 @@
-class Checkout {
- createCheckout(channelSlug, email, productQuantity, variantsList) {
- const lines = variantsList.map(
- variant => `{quantity:${productQuantity}
+export function createCheckout(
+ channelSlug,
+ email,
+ productQuantity,
+ variantsList
+) {
+ const lines = variantsList.map(
+ variant => `{quantity:${productQuantity}
variantId:"${variant.id}"}`
- );
- const mutation = `mutation{
+ );
+ const mutation = `mutation{
checkoutCreate(input:{
channel:"${channelSlug}"
email:"${email}"
@@ -20,10 +24,10 @@ class Checkout {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
- addShippingMethod(checkoutId, shippingMethodId) {
- const mutation = `mutation{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function addShippingMethod(checkoutId, shippingMethodId) {
+ const mutation = `mutation{
checkoutShippingMethodUpdate(checkoutId:"${checkoutId}",
shippingMethodId:"${shippingMethodId}"){
checkoutErrors{
@@ -32,10 +36,10 @@ class Checkout {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
- addPayment(checkoutId, gateway, token) {
- const mutation = `mutation{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function addPayment(checkoutId, gateway, token) {
+ const mutation = `mutation{
checkoutPaymentCreate(checkoutId:"${checkoutId}",
input:{
gateway: "${gateway}"
@@ -47,10 +51,10 @@ class Checkout {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
- completeCheckout(checkoutId) {
- const mutation = `mutation{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function completeCheckout(checkoutId) {
+ const mutation = `mutation{
checkoutComplete(checkoutId:"${checkoutId}"){
order{
id
@@ -63,7 +67,5 @@ class Checkout {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Checkout;
diff --git a/cypress/apiRequests/Collections.js b/cypress/apiRequests/Collections.js
index 8a9e1aa87..b982f0808 100644
--- a/cypress/apiRequests/Collections.js
+++ b/cypress/apiRequests/Collections.js
@@ -1,11 +1,10 @@
-class Collections {
- getCollections(search) {
- const filter = search
- ? `, filter:{
+export function getCollections(search) {
+ const filter = search
+ ? `, filter:{
search:""
}`
- : "";
- const query = `query{
+ : "";
+ const query = `query{
collections(first:100 ${filter}){
edges{
node{
@@ -15,12 +14,12 @@ class Collections {
}
}
}`;
- return cy
- .sendRequestWithQuery(query)
- .then(resp => resp.body.data.collections.edges);
- }
- deleteCollection(collectionId) {
- const mutation = `mutation{
+ return cy
+ .sendRequestWithQuery(query)
+ .then(resp => resp.body.data.collections.edges);
+}
+export function deleteCollection(collectionId) {
+ const mutation = `mutation{
collectionDelete(id:"${collectionId}"){
collection{
id
@@ -31,7 +30,5 @@ class Collections {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Collections;
diff --git a/cypress/apiRequests/Customer.js b/cypress/apiRequests/Customer.js
index 336dbf698..011110631 100644
--- a/cypress/apiRequests/Customer.js
+++ b/cypress/apiRequests/Customer.js
@@ -1,6 +1,5 @@
-export class Customer {
- createCustomer(email, customerName, address, isActive = false) {
- const mutation = `
+export function createCustomer(email, customerName, address, isActive = false) {
+ const mutation = `
mutation{
customerCreate(input:{
firstName: "${customerName}"
@@ -37,24 +36,24 @@ export class Customer {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- deleteCustomers(startsWith) {
- this.getCustomers(startsWith).then(resp => {
- if (resp.body.data.customers) {
- const customers = resp.body.data.customers.edges;
- customers.forEach(element => {
- if (element.node.email.includes(startsWith)) {
- this.deleteCustomer(element.node.id);
- }
- });
- }
- });
- }
+export function deleteCustomers(startsWith) {
+ getCustomers(startsWith).then(resp => {
+ if (resp.body.data.customers) {
+ const customers = resp.body.data.customers.edges;
+ customers.forEach(element => {
+ if (element.node.email.includes(startsWith)) {
+ deleteCustomer(element.node.id);
+ }
+ });
+ }
+ });
+}
- deleteCustomer(customerId) {
- const mutation = `mutation{
+export function deleteCustomer(customerId) {
+ const mutation = `mutation{
customerDelete(id:"${customerId}"){
accountErrors{
code
@@ -62,11 +61,11 @@ export class Customer {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- getCustomers(startsWith) {
- const query = `query{
+export function getCustomers(startsWith) {
+ const query = `query{
customers(first:100, filter: {
search: "${startsWith}"
}){
@@ -79,7 +78,5 @@ export class Customer {
}
}
`;
- return cy.sendRequestWithQuery(query);
- }
+ return cy.sendRequestWithQuery(query);
}
-export default Customer;
diff --git a/cypress/apiRequests/HomePage.js b/cypress/apiRequests/HomePage.js
index 09026cc03..36e2f2eb5 100644
--- a/cypress/apiRequests/HomePage.js
+++ b/cypress/apiRequests/HomePage.js
@@ -1,37 +1,34 @@
-class HomePage {
- getSalesForChannel(channelSlug, period) {
- const query = `query{
+export function getSalesForChannel(channelSlug, period) {
+ const query = `query{
ordersTotal(period: ${period}, channel:"${channelSlug}"){
gross{
amount
}
}
}`;
- return cy.sendRequestWithQuery(query);
- }
- getOrdersForChannel(channelSlug, created) {
- const query = `query{
+ return cy.sendRequestWithQuery(query);
+}
+export function getOrdersForChannel(channelSlug, created) {
+ const query = `query{
orders(created: ${created}, channel:"${channelSlug}"){
totalCount
}
}`;
- return cy.sendRequestWithQuery(query);
- }
- getOrdersWithStatus(status, channelSlug) {
- const query = `query{
+ return cy.sendRequestWithQuery(query);
+}
+export function getOrdersWithStatus(status, channelSlug) {
+ const query = `query{
orders(status: ${status}, channel:"${channelSlug}"){
totalCount
}
}`;
- return cy.sendRequestWithQuery(query);
- }
- getProductsOutOfStock(channelSlug) {
- const query = `query{
+ return cy.sendRequestWithQuery(query);
+}
+export function getProductsOutOfStock(channelSlug) {
+ const query = `query{
products(stockAvailability: OUT_OF_STOCK, channel:"${channelSlug}"){
totalCount
}
}`;
- return cy.sendRequestWithQuery(query);
- }
+ return cy.sendRequestWithQuery(query);
}
-export default HomePage;
diff --git a/cypress/apiRequests/Order.js b/cypress/apiRequests/Order.js
index 0005d344a..05d46173f 100644
--- a/cypress/apiRequests/Order.js
+++ b/cypress/apiRequests/Order.js
@@ -1,17 +1,16 @@
-class Order {
- markOrderAsPaid(orderId) {
- const mutation = `mutation{
+export function markOrderAsPaid(orderId) {
+ const mutation = `mutation{
orderMarkAsPaid(id:"${orderId}"){
orderErrors{
message
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- addProductToOrder(orderId, variantId, quantity = 1) {
- const mutation = `mutation{
+export function addProductToOrder(orderId, variantId, quantity = 1) {
+ const mutation = `mutation{
draftOrderLinesCreate(id:"${orderId}", input:{
quantity:${quantity}
variantId: "${variantId}"
@@ -21,11 +20,11 @@ class Order {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- createDraftOrder(customerId, shippingMethodId, channelId) {
- const mutation = `
+export function createDraftOrder(customerId, shippingMethodId, channelId) {
+ const mutation = `
mutation{
draftOrderCreate(input:{
user:"${customerId}"
@@ -41,10 +40,10 @@ class Order {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
- completeOrder(orderId) {
- const mutation = `mutation{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function completeOrder(orderId) {
+ const mutation = `mutation{
draftOrderComplete(id:"${orderId}"){
order{
id
@@ -54,7 +53,5 @@ class Order {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Order;
diff --git a/cypress/apiRequests/Product.js b/cypress/apiRequests/Product.js
index 77f665755..ca4407536 100644
--- a/cypress/apiRequests/Product.js
+++ b/cypress/apiRequests/Product.js
@@ -1,13 +1,12 @@
import { getValueWithDefault } from "./utils/Utils";
-class Product {
- getFirstProducts(first, search) {
- const filter = search
- ? `, filter:{
+export function getFirstProducts(first, search) {
+ const filter = search
+ ? `, filter:{
search:"${search}"
}`
- : "";
- const query = `query{
+ : "";
+ const query = `query{
products(first:${first}${filter}){
edges{
node{
@@ -20,19 +19,19 @@ class Product {
}
}
`;
- return cy
- .sendRequestWithQuery(query)
- .then(resp => resp.body.data.products.edges);
- }
+ return cy
+ .sendRequestWithQuery(query)
+ .then(resp => resp.body.data.products.edges);
+}
- updateChannelInProduct({
- productId,
- channelId,
- isPublished = true,
- isAvailableForPurchase = true,
- visibleInListings = true
- }) {
- const mutation = `mutation{
+export function updateChannelInProduct({
+ productId,
+ channelId,
+ isPublished = true,
+ isAvailableForPurchase = true,
+ visibleInListings = true
+}) {
+ const mutation = `mutation{
productChannelListingUpdate(id:"${productId}",
input:{
addChannels:{
@@ -48,11 +47,11 @@ class Product {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- updateChannelPriceInVariant(variantId, channelId) {
- const mutation = `mutation{
+export function updateChannelPriceInVariant(variantId, channelId) {
+ const mutation = `mutation{
productVariantChannelListingUpdate(id: "${variantId}", input: {
channelId: "${channelId}"
price: 10
@@ -63,10 +62,10 @@ class Product {
}
}
} `;
- return cy.sendRequestWithQuery(mutation);
- }
- createProduct(attributeId, name, productType, category) {
- const mutation = `mutation{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function createProduct(attributeId, name, productType, category) {
+ const mutation = `mutation{
productCreate(input:{
attributes:[{
id:"${attributeId}"
@@ -84,36 +83,36 @@ class Product {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- createVariant({
- productId,
- sku,
- warehouseId,
- quantity,
+export function createVariant({
+ productId,
+ sku,
+ warehouseId,
+ quantity,
+ channelId,
+ price = 1,
+ costPrice = 1
+}) {
+ const channelListings = getValueWithDefault(
channelId,
- price = 1,
- costPrice = 1
- }) {
- const channelListings = getValueWithDefault(
- channelId,
- `channelListings:{
+ `channelListings:{
channelId:"${channelId}"
price:"${price}"
costPrice:"${costPrice}"
}`
- );
+ );
- const stocks = getValueWithDefault(
- warehouseId,
- `stocks:{
+ const stocks = getValueWithDefault(
+ warehouseId,
+ `stocks:{
warehouse:"${warehouseId}"
quantity:${quantity}
}`
- );
+ );
- const mutation = `mutation{
+ const mutation = `mutation{
productVariantBulkCreate(product: "${productId}", variants: {
attributes: []
sku: "${sku}"
@@ -130,11 +129,11 @@ class Product {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- createTypeProduct(name, attributeId, slug = name) {
- const mutation = `mutation{
+export function createTypeProduct(name, attributeId, slug = name) {
+ const mutation = `mutation{
productTypeCreate(input: {
name: "${name}"
slug: "${slug}"
@@ -151,11 +150,11 @@ class Product {
}
}
} `;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- deleteProduct(productId) {
- const mutation = `mutation{
+export function deleteProduct(productId) {
+ const mutation = `mutation{
productDelete(id: "${productId}"){
productErrors{
field
@@ -163,11 +162,11 @@ class Product {
}
}
} `;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- getProductTypes(first, search) {
- const query = `query{
+export function getProductTypes(first, search) {
+ const query = `query{
productTypes(first:${first}, filter:{
search:"${search}"
}){
@@ -179,13 +178,13 @@ class Product {
}
}
}`;
- return cy
- .sendRequestWithQuery(query)
- .then(resp => resp.body.data.productTypes.edges);
- }
+ return cy
+ .sendRequestWithQuery(query)
+ .then(resp => resp.body.data.productTypes.edges);
+}
- deleteProductType(productTypeId) {
- const mutation = `mutation{
+export function deleteProductType(productTypeId) {
+ const mutation = `mutation{
productTypeDelete(id:"${productTypeId}"){
productErrors{
field
@@ -193,8 +192,5 @@ class Product {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-
-export default Product;
diff --git a/cypress/apiRequests/ShippingMethod.js b/cypress/apiRequests/ShippingMethod.js
index 6c9deb3de..ee05f2774 100644
--- a/cypress/apiRequests/ShippingMethod.js
+++ b/cypress/apiRequests/ShippingMethod.js
@@ -1,6 +1,5 @@
-class ShippingMethod {
- createShippingRate(name, shippingZone) {
- const mutation = `
+export function createShippingRate(name, shippingZone) {
+ const mutation = `
mutation{
shippingPriceCreate(input:{
name: "${name}"
@@ -13,11 +12,11 @@ class ShippingMethod {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- createShippingZone(name, country) {
- const mutation = `
+export function createShippingZone(name, country) {
+ const mutation = `
mutation{
shippingZoneCreate(input:{
name: "${name}"
@@ -29,11 +28,11 @@ class ShippingMethod {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- addChannelToShippingMethod(shippingRateId, channelId, price) {
- const mutation = `
+export function addChannelToShippingMethod(shippingRateId, channelId, price) {
+ const mutation = `
mutation{
shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{
addChannels: {
@@ -51,11 +50,11 @@ class ShippingMethod {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- deleteShippingZone(shippingZoneId) {
- const mutation = `mutation{
+export function deleteShippingZone(shippingZoneId) {
+ const mutation = `mutation{
shippingZoneDelete(id:"${shippingZoneId}"){
shippingErrors{
message
@@ -63,11 +62,11 @@ class ShippingMethod {
}
}
`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
+}
- getShippingZones() {
- const query = `query{
+export function getShippingZones() {
+ const query = `query{
shippingZones(first:100){
edges{
node{
@@ -78,9 +77,7 @@ class ShippingMethod {
}
}
`;
- return cy
- .sendRequestWithQuery(query)
- .then(resp => resp.body.data.shippingZones.edges);
- }
+ return cy
+ .sendRequestWithQuery(query)
+ .then(resp => resp.body.data.shippingZones.edges);
}
-export default ShippingMethod;
diff --git a/cypress/apiRequests/Warehouse.js b/cypress/apiRequests/Warehouse.js
index 2bbf18c15..8dd60a198 100644
--- a/cypress/apiRequests/Warehouse.js
+++ b/cypress/apiRequests/Warehouse.js
@@ -1,6 +1,5 @@
-class Warehouse {
- createWarehouse(name, shippingZone, address, slug = name) {
- const mutation = `mutation{
+export function createWarehouse(name, shippingZone, address, slug = name) {
+ const mutation = `mutation{
createWarehouse(input:{
name:"${name}"
slug:"${slug}"
@@ -24,10 +23,10 @@ class Warehouse {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
- getWarehouses(first, search) {
- const query = `query{
+ return cy.sendRequestWithQuery(mutation);
+}
+export function getWarehouses(first, search) {
+ const query = `query{
warehouses(first:${first}, filter:{
search:"${search}"
}){
@@ -39,12 +38,12 @@ class Warehouse {
}
}
}`;
- return cy
- .sendRequestWithQuery(query)
- .then(resp => resp.body.data.warehouses.edges);
- }
- deleteWarehouse(warehouseId) {
- const mutation = `mutation{
+ return cy
+ .sendRequestWithQuery(query)
+ .then(resp => resp.body.data.warehouses.edges);
+}
+export function deleteWarehouse(warehouseId) {
+ const mutation = `mutation{
deleteWarehouse(id:"${warehouseId}"){
warehouseErrors{
field
@@ -52,7 +51,5 @@ class Warehouse {
}
}
}`;
- return cy.sendRequestWithQuery(mutation);
- }
+ return cy.sendRequestWithQuery(mutation);
}
-export default Warehouse;
diff --git a/cypress/apiRequests/storeFront/Collections.js b/cypress/apiRequests/storeFront/Collections.js
index 54770701e..500d59898 100644
--- a/cypress/apiRequests/storeFront/Collections.js
+++ b/cypress/apiRequests/storeFront/Collections.js
@@ -1,6 +1,5 @@
-class Collections {
- getCollection(collectionId, channelSlug) {
- const query = `query Collection{
+export function getCollection(collectionId, channelSlug) {
+ const query = `query Collection{
collection(id: "${collectionId}", channel: "${channelSlug}") {
id
slug
@@ -16,7 +15,5 @@ class Collections {
}
}
}`;
- return cy.sendRequestWithQuery(query, "token");
- }
+ return cy.sendRequestWithQuery(query, "token");
}
-export default Collections;
diff --git a/cypress/apiRequests/storeFront/ProductDetails.js b/cypress/apiRequests/storeFront/ProductDetails.js
index dc1c3fa30..ddc69d628 100644
--- a/cypress/apiRequests/storeFront/ProductDetails.js
+++ b/cypress/apiRequests/storeFront/ProductDetails.js
@@ -1,6 +1,5 @@
-class ProductDetails {
- getProductDetails(productId, channelId) {
- const query = `fragment BasicProductFields on Product {
+export function getProductDetails(productId, channelId) {
+ const query = `fragment BasicProductFields on Product {
id
name
}
@@ -34,7 +33,5 @@ class ProductDetails {
availableForPurchase
}
}`;
- return cy.sendRequestWithQuery(query, "token");
- }
+ return cy.sendRequestWithQuery(query, "token");
}
-export default ProductDetails;
diff --git a/cypress/apiRequests/storeFront/Search.js b/cypress/apiRequests/storeFront/Search.js
index 776ba2860..5184cecda 100644
--- a/cypress/apiRequests/storeFront/Search.js
+++ b/cypress/apiRequests/storeFront/Search.js
@@ -1,6 +1,5 @@
-class Search {
- searchInShop(searchQuery) {
- const query = `query SearchProducts {
+export function searchInShop(searchQuery) {
+ const query = `query SearchProducts {
products(channel: "default-channel", filter:{
search: "${searchQuery}"
}, first:10){
@@ -14,7 +13,5 @@ class Search {
}
}`;
- return cy.sendRequestWithQuery(query, "token");
- }
+ return cy.sendRequestWithQuery(query, "token");
}
-export default Search;
diff --git a/cypress/integration/channels.js b/cypress/integration/channels.js
index 9f5e97a38..e382cbf47 100644
--- a/cypress/integration/channels.js
+++ b/cypress/integration/channels.js
@@ -1,7 +1,7 @@
//
import faker from "faker";
-import Channels from "../apiRequests/Channels";
+import { createChannel } from "../apiRequests/Channels";
import { LEFT_MENU_SELECTORS } from "../elements/account/left-menu/left-menu-selectors";
import { PRODUCTS_SELECTORS } from "../elements/catalog/products/product-selectors";
import { ADD_CHANNEL_FORM_SELECTORS } from "../elements/channels/add-channel-form-selectors";
@@ -12,20 +12,17 @@ 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";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
-import ChannelsSteps from "../steps/channelsSteps";
+import { createChannelByView } from "../steps/channelsSteps";
import { urlList } from "../url/urlList";
-import ChannelsUtils from "../utils/channelsUtils";
+import { deleteChannelsStartsWith } from "../utils/channelsUtils";
describe("Channels", () => {
const channelStartsWith = "Cypress:";
const currency = "PLN";
- const channels = new Channels();
- const channelsUtils = new ChannelsUtils();
- const channelsSteps = new ChannelsSteps();
before(() => {
cy.clearSessionData().loginUserViaRequest();
- channelsUtils.deleteChannels(channelStartsWith);
+ deleteChannelsStartsWith(channelStartsWith);
});
beforeEach(() => {
@@ -48,7 +45,7 @@ describe("Channels", () => {
cy.visit(urlList.channels);
cy.wait("@Channels");
cy.addAliasToGraphRequest("Channel");
- channelsSteps.createChannelByView(randomChannel, currency);
+ createChannelByView(randomChannel, currency);
// New channel should be visible in channels list
cy.wait("@Channel")
.get(ADD_CHANNEL_FORM_SELECTORS.backToChannelsList)
@@ -79,22 +76,18 @@ describe("Channels", () => {
it("should validate slug name", () => {
const randomChannel = `${channelStartsWith} ${faker.random.number()}`;
- channels.createChannel(false, randomChannel, randomChannel, currency);
+ createChannel(false, randomChannel, randomChannel, currency);
cy.visit(urlList.channels);
- channelsSteps.createChannelByView(randomChannel, currency);
+ createChannelByView(randomChannel, currency);
cy.get(ADD_CHANNEL_FORM_SELECTORS.slugValidationMessage).should(
"be.visible"
);
});
- it("should validate currency", () => {
+ it("should validate duplicated currency", () => {
const randomChannel = `${channelStartsWith} ${faker.random.number()}`;
cy.visit(urlList.channels);
- channelsSteps.createChannelByView(
- randomChannel,
- currency,
- "notExistingCurrency"
- );
+ createChannelByView(randomChannel, "notExistingCurrency");
cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyValidationMessage).should(
"be.visible"
);
@@ -102,7 +95,7 @@ describe("Channels", () => {
it("should delete channel", () => {
const randomChannelToDelete = `${channelStartsWith} ${faker.random.number()}`;
- channels.createChannel(
+ createChannel(
false,
randomChannelToDelete,
randomChannelToDelete,
@@ -126,7 +119,7 @@ describe("Channels", () => {
it("should not be possible to add products to order with inactive channel", () => {
const randomChannel = `${channelStartsWith} ${faker.random.number()}`;
- channels.createChannel(false, randomChannel, randomChannel, currency);
+ createChannel(false, randomChannel, randomChannel, currency);
cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder)
.click()
diff --git a/cypress/integration/collections.js b/cypress/integration/collections.js
index 8b854822f..5c64a75dd 100644
--- a/cypress/integration/collections.js
+++ b/cypress/integration/collections.js
@@ -1,15 +1,18 @@
//
import faker from "faker";
-import Product from "../apiRequests/Product";
-import Collections from "../apiRequests/storeFront/Collections";
-import Search from "../apiRequests/storeFront/Search";
-import CollectionsSteps from "../steps/collectionsSteps";
+import { updateChannelInProduct } from "../apiRequests/Product";
+import { getCollection } from "../apiRequests/storeFront/Collections";
+import { searchInShop } from "../apiRequests/storeFront/Search";
+import {
+ assignProductsToCollection,
+ createCollection
+} from "../steps/collectionsSteps";
import { urlList } from "../url/urlList";
-import ChannelsUtils from "../utils/channelsUtils";
-import CollectionsUtils from "../utils/collectionsUtils";
-import ProductsUtils from "../utils/productsUtils";
-import ShippingUtils from "../utils/shippingUtils";
+import * as channelsUtils from "../utils/channelsUtils";
+import { deleteCollectionsStartsWith } from "../utils/collectionsUtils";
+import * as productsUtils from "../utils/productsUtils";
+import { deleteShippingStartsWith } from "../utils/shippingUtils";
import {
isCollectionVisible,
isProductInCollectionVisible
@@ -17,29 +20,21 @@ import {
import { isProductVisibleInSearchResult } from "../utils/storeFront/storeFrontProductUtils";
describe("Collections", () => {
- const productRequest = new Product();
- const collectionsRequest = new Collections();
- const search = new Search();
- const channelsUtils = new ChannelsUtils();
- const productsUtils = new ProductsUtils();
- const collectionsUtils = new CollectionsUtils();
- const shippingUtils = new ShippingUtils();
- const collectionsSteps = new CollectionsSteps();
-
const startsWith = "Cy-";
const name = `${startsWith}${faker.random.number()}`;
let attribute;
let productType;
let category;
+ let product;
let defaultChannel;
before(() => {
cy.clearSessionData().loginUserViaRequest();
- productsUtils.deleteProperProducts(startsWith);
- collectionsUtils.deleteProperCollections(startsWith);
- shippingUtils.deleteShipping(startsWith);
+ productsUtils.deleteProductsStartsWith(startsWith);
+ deleteCollectionsStartsWith(startsWith);
+ deleteShippingStartsWith(startsWith);
channelsUtils
.getDefaultChannel()
@@ -47,18 +42,25 @@ describe("Collections", () => {
defaultChannel = channel;
productsUtils.createTypeAttributeAndCategoryForProduct(name);
})
- .then(() => {
- attribute = productsUtils.getAttribute();
- productType = productsUtils.getProductType();
- category = productsUtils.getCategory();
- productsUtils.createProductInChannel({
- name,
- channelId: defaultChannel.id,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id
- });
- });
+ .then(
+ ({
+ attribute: attributeResp,
+ productType: productTypeResp,
+ category: categoryResp
+ }) => {
+ attribute = attributeResp;
+ productType = productTypeResp;
+ category = categoryResp;
+ productsUtils.createProductInChannel({
+ name,
+ channelId: defaultChannel.id,
+ productTypeId: productType.id,
+ attributeId: attribute.id,
+ categoryId: category.id
+ });
+ }
+ )
+ .then(({ product: productResp }) => (product = productResp));
});
beforeEach(() => {
@@ -70,14 +72,13 @@ describe("Collections", () => {
cy.visit(urlList.collections);
let collection;
- collectionsSteps
- .createCollection(collectionName, false, defaultChannel)
+ createCollection(collectionName, false, defaultChannel)
.then(collectionResp => {
collection = collectionResp;
- collectionsSteps.assignProductsToCollection(name);
+ assignProductsToCollection(name);
})
.then(() => {
- collectionsRequest.getCollection(collection.id, defaultChannel.slug);
+ getCollection(collection.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isCollectionVisible(resp, collection.id);
@@ -89,12 +90,12 @@ describe("Collections", () => {
const collectionName = `${startsWith}${faker.random.number()}`;
let collection;
cy.visit(urlList.collections);
- collectionsSteps
- .createCollection(collectionName, true, defaultChannel)
+
+ createCollection(collectionName, true, defaultChannel)
.then(collectionResp => {
collection = collectionResp;
- collectionsSteps.assignProductsToCollection(name);
- collectionsRequest.getCollection(collection.id, defaultChannel.slug);
+ assignProductsToCollection(name);
+ getCollection(collection.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isCollectionVisible(resp, collection.id);
@@ -104,27 +105,22 @@ describe("Collections", () => {
it("should not display collection not set as available in channel", () => {
const collectionName = `${startsWith}${faker.random.number()}`;
let collection;
+ let channel;
channelsUtils
.createChannel({ name: collectionName })
- .then(() => {
- productRequest.updateChannelInProduct(
- productsUtils.getCreatedProduct().id,
- channelsUtils.getCreatedChannel().id
- );
+ .then(channelResp => {
+ channel = channelResp;
+ updateChannelInProduct(product.id, channel.id);
})
.then(() => {
cy.visit(urlList.collections);
- collectionsSteps.createCollection(
- collectionName,
- true,
- channelsUtils.getCreatedChannel()
- );
+ createCollection(collectionName, true, channel);
})
.then(collectionResp => {
collection = collectionResp;
- collectionsSteps.assignProductsToCollection(name);
- collectionsRequest.getCollection(collection.id, defaultChannel.slug);
+ assignProductsToCollection(name);
+ getCollection(collection.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isCollectionVisible(resp, collection.id);
@@ -135,41 +131,39 @@ describe("Collections", () => {
// Products "hidden in listings" are not displayed in Category listings or search results,
// but are listed on Collections
const randomName = `${startsWith}${faker.random.number()}`;
- const hiddenProductUtils = new ProductsUtils();
let collection;
+ let createdProduct;
- hiddenProductUtils.createProductInChannel({
- name: randomName,
- channelId: defaultChannel.id,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id,
- visibleInListings: false
- });
+ productsUtils
+ .createProductInChannel({
+ name: randomName,
+ channelId: defaultChannel.id,
+ productTypeId: productType.id,
+ attributeId: attribute.id,
+ categoryId: category.id,
+ visibleInListings: false
+ })
+ .then(({ product: productResp }) => (createdProduct = productResp));
cy.visit(urlList.collections);
- collectionsSteps
- .createCollection(randomName, true, defaultChannel)
+ createCollection(randomName, true, defaultChannel)
.then(collectionResp => {
collection = collectionResp;
- collectionsSteps.assignProductsToCollection(randomName);
+ assignProductsToCollection(randomName);
})
.then(() => {
- collectionsRequest.getCollection(collection.id, defaultChannel.slug);
+ getCollection(collection.id, defaultChannel.slug);
})
.then(resp => {
- const isVisible = isProductInCollectionVisible(
- resp,
- hiddenProductUtils.getCreatedProduct().id
- );
+ const isVisible = isProductInCollectionVisible(resp, createdProduct.id);
expect(isVisible).to.equal(true);
})
.then(() => {
- search.searchInShop(hiddenProductUtils.getCreatedProduct().name);
+ searchInShop(createdProduct.name);
})
.then(resp => {
const isVisible = isProductVisibleInSearchResult(
resp,
- hiddenProductUtils.getCreatedProduct().name
+ createdProduct.name
);
expect(isVisible).to.equal(false);
});
diff --git a/cypress/integration/homePage.js b/cypress/integration/homePage.js
index 3712afd56..f9aadd4ef 100644
--- a/cypress/integration/homePage.js
+++ b/cypress/integration/homePage.js
@@ -1,29 +1,31 @@
import faker from "faker";
-import Customer from "../apiRequests/Customer";
+import { createCustomer, deleteCustomers } from "../apiRequests/Customer";
import { HOMEPAGE_SELECTORS } from "../elements/homePage/homePage-selectors";
-import HomePageSteps from "../steps/homePageSteps";
+import { changeChannel } from "../steps/homePageSteps";
import { urlList } from "../url/urlList";
-import ChannelsUtils from "../utils/channelsUtils";
-import HomePageUtils from "../utils/homePageUtils";
-import OrdersUtils from "../utils/ordersUtils";
-import ProductsUtils from "../utils/productsUtils";
-import ShippingUtils from "../utils/shippingUtils";
+import { getDefaultChannel } from "../utils/channelsUtils";
+import * as homePageUtils from "../utils/homePageUtils";
+import {
+ createReadyToFulfillOrder,
+ createWaitingForCaptureOrder
+} from "../utils/ordersUtils";
+import * as productsUtils from "../utils/productsUtils";
+import * as shippingUtils from "../utils/shippingUtils";
//
describe("Homepage analytics", () => {
const startsWith = "Cy-";
- const customer = new Customer();
- const productsUtils = new ProductsUtils();
- const shippingUtils = new ShippingUtils();
- const ordersUtils = new OrdersUtils();
- const channelsUtils = new ChannelsUtils();
- const homePageUtils = new HomePageUtils();
- const homePageSteps = new HomePageSteps();
-
let customerId;
let defaultChannel;
+ let createdVariants;
+ let productType;
+ let attribute;
+ let category;
+ let warehouse;
+ let shippingMethod;
+
const productPrice = 22;
const shippingPrice = 12;
const randomName = startsWith + faker.random.number();
@@ -31,21 +33,18 @@ describe("Homepage analytics", () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
- productsUtils.deleteProperProducts(startsWith);
- customer.deleteCustomers(startsWith);
- shippingUtils.deleteShipping(startsWith);
+ productsUtils.deleteProductsStartsWith(startsWith);
+ deleteCustomers(startsWith);
+ shippingUtils.deleteShippingStartsWith(startsWith);
let addresses;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
})
.then(addressesFixture => (addresses = addressesFixture))
- .then(() =>
- customer.createCustomer(randomEmail, randomName, addresses.plAddress)
- )
+ .then(() => createCustomer(randomEmail, randomName, addresses.plAddress))
.then(resp => {
customerId = resp.body.data.customerCreate.user.id;
shippingUtils.createShipping({
@@ -55,24 +54,36 @@ describe("Homepage analytics", () => {
price: shippingPrice
});
})
- .then(() => {
- productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
- })
- .then(() => {
- const warehouse = shippingUtils.getWarehouse();
- const productType = productsUtils.getProductType();
- const attribute = productsUtils.getAttribute();
- const category = productsUtils.getCategory();
- productsUtils.createProductInChannel({
- name: randomName,
- channelId: defaultChannel.id,
- warehouseId: warehouse.id,
- quantityInWarehouse: 20,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id,
- price: productPrice
- });
+ .then(
+ ({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
+ warehouse = warehouseResp;
+ shippingMethod = shippingMethodResp;
+ productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
+ }
+ )
+ .then(
+ ({
+ productType: productTypeResp,
+ attribute: attributeResp,
+ category: categoryResp
+ }) => {
+ productType = productTypeResp;
+ attribute = attributeResp;
+ category = categoryResp;
+ productsUtils.createProductInChannel({
+ name: randomName,
+ channelId: defaultChannel.id,
+ warehouseId: warehouse.id,
+ quantityInWarehouse: 20,
+ productTypeId: productType.id,
+ attributeId: attribute.id,
+ categoryId: category.id,
+ price: productPrice
+ });
+ }
+ )
+ .then(({ variants: variantsResp }) => {
+ createdVariants = variantsResp;
});
});
@@ -96,11 +107,11 @@ describe("Homepage analytics", () => {
.getOrdersReadyToFulfill(defaultChannel.slug)
.as("ordersReadyToFulfill");
- ordersUtils.createReadyToFulfillOrder(
+ createReadyToFulfillOrder(
customerId,
- shippingUtils.getShippingMethod().id,
+ shippingMethod.id,
defaultChannel.id,
- productsUtils.getCreatedVariants()
+ createdVariants
);
cy.get("@ordersReadyToFulfill").then(ordersReadyToFulfillBefore => {
const allOrdersReadyToFulfill = ordersReadyToFulfillBefore + 1;
@@ -109,7 +120,7 @@ describe("Homepage analytics", () => {
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`
);
cy.visit(urlList.homePage);
- homePageSteps.changeChannel(defaultChannel.name);
+ changeChannel(defaultChannel.name);
cy.contains(
HOMEPAGE_SELECTORS.ordersReadyToFulfill,
ordersReadyToFulfillRegexp
@@ -120,13 +131,12 @@ describe("Homepage analytics", () => {
homePageUtils
.getOrdersReadyForCapture(defaultChannel.slug)
.as("ordersReadyForCapture");
- const variantsList = productsUtils.getCreatedVariants();
- ordersUtils.createWaitingForCaptureOrder(
+ createWaitingForCaptureOrder(
defaultChannel.slug,
randomEmail,
- variantsList,
- shippingUtils.getShippingMethod().id
+ createdVariants,
+ shippingMethod.id
);
cy.get("@ordersReadyForCapture").then(ordersReadyForCaptureBefore => {
@@ -136,7 +146,7 @@ describe("Homepage analytics", () => {
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`
);
cy.visit(urlList.homePage);
- homePageSteps.changeChannel(defaultChannel.name);
+ changeChannel(defaultChannel.name);
cy.contains(
HOMEPAGE_SELECTORS.ordersReadyForCapture,
ordersReadyForCaptureRegexp
@@ -148,13 +158,8 @@ describe("Homepage analytics", () => {
.getProductsOutOfStock(defaultChannel.slug)
.as("productsOutOfStock");
const productOutOfStockRandomName = startsWith + faker.random.number();
- const productsOutOfStockUtils = new ProductsUtils();
- const warehouse = shippingUtils.getWarehouse();
- const productType = productsUtils.getProductType();
- const attribute = productsUtils.getAttribute();
- const category = productsUtils.getCategory();
- productsOutOfStockUtils.createProductInChannel({
+ productsUtils.createProductInChannel({
name: productOutOfStockRandomName,
channelId: defaultChannel.id,
warehouseId: warehouse.id,
@@ -172,7 +177,7 @@ describe("Homepage analytics", () => {
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`
);
cy.visit(urlList.homePage);
- homePageSteps.changeChannel(defaultChannel.name);
+ changeChannel(defaultChannel.name);
cy.contains(
HOMEPAGE_SELECTORS.productsOutOfStock,
productsOutOfStockRegexp
@@ -182,11 +187,11 @@ describe("Homepage analytics", () => {
it("should correct amount of sales be displayed", () => {
homePageUtils.getSalesAmount(defaultChannel.slug).as("salesAmount");
- ordersUtils.createReadyToFulfillOrder(
+ createReadyToFulfillOrder(
customerId,
- shippingUtils.getShippingMethod().id,
+ shippingMethod.id,
defaultChannel.id,
- productsUtils.getCreatedVariants()
+ createdVariants
);
cy.get("@salesAmount").then(salesAmount => {
@@ -205,7 +210,7 @@ describe("Homepage analytics", () => {
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`
);
cy.visit(urlList.homePage);
- homePageSteps.changeChannel(defaultChannel.name);
+ changeChannel(defaultChannel.name);
cy.contains(HOMEPAGE_SELECTORS.sales, salesAmountRegexp).should(
"be.visible"
);
@@ -214,11 +219,11 @@ describe("Homepage analytics", () => {
it("should correct amount of orders be displayed", () => {
homePageUtils.getTodaysOrders(defaultChannel.slug).as("todaysOrders");
- ordersUtils.createReadyToFulfillOrder(
+ createReadyToFulfillOrder(
customerId,
- shippingUtils.getShippingMethod().id,
+ shippingMethod.id,
defaultChannel.id,
- productsUtils.getCreatedVariants()
+ createdVariants
);
cy.get("@todaysOrders").then(ordersBefore => {
@@ -228,7 +233,7 @@ describe("Homepage analytics", () => {
`${notANumberRegex}${allOrders}${notANumberRegex}`
);
cy.visit(urlList.homePage);
- homePageSteps.changeChannel(defaultChannel.name);
+ changeChannel(defaultChannel.name);
cy.contains(HOMEPAGE_SELECTORS.orders, ordersRegexp).should("be.visible");
});
});
diff --git a/cypress/integration/products/menageProducts/availableForPurchaseProducts.js b/cypress/integration/products/menageProducts/availableForPurchaseProducts.js
index d7a86e084..2bfc475d7 100644
--- a/cypress/integration/products/menageProducts/availableForPurchaseProducts.js
+++ b/cypress/integration/products/menageProducts/availableForPurchaseProducts.js
@@ -1,20 +1,15 @@
import faker from "faker";
-import ProductDetails from "../../../apiRequests/storeFront/ProductDetails";
-import ProductSteps from "../../../steps/products/productSteps";
+import { getProductDetails } from "../../../apiRequests/storeFront/ProductDetails";
+import { updateProductIsAvailableForPurchase } from "../../../steps/products/productSteps";
import { productDetailsUrl } from "../../../url/urlList";
-import ChannelsUtils from "../../../utils/channelsUtils";
-import ProductsUtils from "../../../utils/productsUtils";
-import ShippingUtils from "../../../utils/shippingUtils";
+import { getDefaultChannel } from "../../../utils/channelsUtils";
+import * as productsUtils from "../../../utils/productsUtils";
+import * as shippingUtils from "../../../utils/shippingUtils";
import { isProductAvailableForPurchase } from "../../../utils/storeFront/storeFrontProductUtils";
//
describe("Products available in listings", () => {
- const productDetails = new ProductDetails();
- const shippingUtils = new ShippingUtils();
- const channelsUtils = new ChannelsUtils();
- const productsUtils = new ProductsUtils();
- const productSteps = new ProductSteps();
const startsWith = "Cy-";
const name = `${startsWith}${faker.random.number()}`;
let productType;
@@ -25,11 +20,10 @@ describe("Products available in listings", () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
- shippingUtils.deleteShipping(startsWith);
- productsUtils.deleteProperProducts(startsWith);
+ shippingUtils.deleteShippingStartsWith(startsWith);
+ productsUtils.deleteProductsStartsWith(startsWith);
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
@@ -41,15 +35,23 @@ describe("Products available in listings", () => {
address: addressesFixture.plAddress
});
})
- .then(() => {
- warehouse = shippingUtils.getWarehouse();
+ .then(({ warehouse: warehouseResp }) => {
+ warehouse = warehouseResp;
});
- productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
- productType = productsUtils.getProductType();
- attribute = productsUtils.getAttribute();
- category = productsUtils.getCategory();
- });
+ productsUtils
+ .createTypeAttributeAndCategoryForProduct(name)
+ .then(
+ ({
+ attribute: attributeResp,
+ productType: productTypeResp,
+ category: categoryResp
+ }) => {
+ productType = productTypeResp;
+ attribute = attributeResp;
+ category = categoryResp;
+ }
+ );
});
beforeEach(() => {
@@ -58,6 +60,8 @@ describe("Products available in listings", () => {
it("should update product to available for purchase", () => {
const productName = `${startsWith}${faker.random.number()}`;
+ let product;
+
productsUtils
.createProductInChannel({
name: productName,
@@ -68,17 +72,13 @@ describe("Products available in listings", () => {
categoryId: category.id,
isAvailableForPurchase: false
})
- .then(() => {
- const productUrl = productDetailsUrl(
- productsUtils.getCreatedProduct().id
- );
- productSteps.updateProductIsAvailableForPurchase(productUrl, true);
+ .then(({ product: productResp }) => {
+ product = productResp;
+ const productUrl = productDetailsUrl(product.id);
+ updateProductIsAvailableForPurchase(productUrl, true);
})
.then(() => {
- productDetails.getProductDetails(
- productsUtils.getCreatedProduct().id,
- defaultChannel.slug
- );
+ getProductDetails(product.id, defaultChannel.slug);
})
.then(resp => {
expect(isProductAvailableForPurchase(resp)).to.be.eq(true);
@@ -86,6 +86,8 @@ describe("Products available in listings", () => {
});
it("should update product to not available for purchase", () => {
const productName = `${startsWith}${faker.random.number()}`;
+ let product;
+
productsUtils
.createProductInChannel({
name: productName,
@@ -95,17 +97,13 @@ describe("Products available in listings", () => {
attributeId: attribute.id,
categoryId: category.id
})
- .then(() => {
- const productUrl = productDetailsUrl(
- productsUtils.getCreatedProduct().id
- );
- productSteps.updateProductIsAvailableForPurchase(productUrl, false);
+ .then(({ product: productResp }) => {
+ product = productResp;
+ const productUrl = productDetailsUrl(product.id);
+ updateProductIsAvailableForPurchase(productUrl, false);
})
.then(() => {
- productDetails.getProductDetails(
- productsUtils.getCreatedProduct().id,
- defaultChannel.slug
- );
+ getProductDetails(product.id, defaultChannel.slug);
})
.then(resp => {
expect(isProductAvailableForPurchase(resp)).to.be.eq(false);
diff --git a/cypress/integration/products/menageProducts/publishedProducts.js b/cypress/integration/products/menageProducts/publishedProducts.js
index ab5548a93..0b7efe5b8 100644
--- a/cypress/integration/products/menageProducts/publishedProducts.js
+++ b/cypress/integration/products/menageProducts/publishedProducts.js
@@ -1,19 +1,14 @@
import faker from "faker";
-import ProductDetails from "../../../apiRequests/storeFront/ProductDetails";
-import ProductSteps from "../../../steps/products/productSteps";
+import { getProductDetails } from "../../../apiRequests/storeFront/ProductDetails";
+import { updateProductPublish } from "../../../steps/products/productSteps";
import { productDetailsUrl } from "../../../url/urlList";
-import ChannelsUtils from "../../../utils/channelsUtils";
-import ProductsUtils from "../../../utils/productsUtils";
+import { getDefaultChannel } from "../../../utils/channelsUtils";
+import * as productsUtils from "../../../utils/productsUtils";
import { isProductVisible } from "../../../utils/storeFront/storeFrontProductUtils";
//
describe("Published products", () => {
- const productDetails = new ProductDetails();
- const channelsUtils = new ChannelsUtils();
- const productsUtils = new ProductsUtils();
- const productSteps = new ProductSteps();
-
const startsWith = "Cy-";
const name = `${startsWith}${faker.random.number()}`;
let productType;
@@ -22,12 +17,20 @@ describe("Published products", () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
- productsUtils.deleteProperProducts(startsWith);
- productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
- productType = productsUtils.getProductType();
- attribute = productsUtils.getAttribute();
- category = productsUtils.getCategory();
- });
+ productsUtils.deleteProductsStartsWith(startsWith);
+ productsUtils
+ .createTypeAttributeAndCategoryForProduct(name)
+ .then(
+ ({
+ attribute: attributeResp,
+ productType: productTypeResp,
+ category: categoryResp
+ }) => {
+ productType = productTypeResp;
+ attribute = attributeResp;
+ category = categoryResp;
+ }
+ );
});
beforeEach(() => {
@@ -36,8 +39,7 @@ describe("Published products", () => {
it("should update product to published", () => {
const productName = `${startsWith}${faker.random.number()}`;
let defaultChannel;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
productsUtils.createProductInChannel({
@@ -50,11 +52,11 @@ describe("Published products", () => {
isAvailableForPurchase: false
});
})
- .then(() => {
- const product = productsUtils.getCreatedProduct();
+ .then(({ product: productResp }) => {
+ const product = productResp;
const productUrl = productDetailsUrl(product.id);
- productSteps.updateProductPublish(productUrl, true);
- productDetails.getProductDetails(product.id, defaultChannel.slug);
+ updateProductPublish(productUrl, true);
+ getProductDetails(product.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isProductVisible(resp, productName);
@@ -66,8 +68,7 @@ describe("Published products", () => {
let defaultChannel;
let product;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
productsUtils.createProductInChannel({
@@ -78,11 +79,11 @@ describe("Published products", () => {
categoryId: category.id
});
})
- .then(() => {
- product = productsUtils.getCreatedProduct();
+ .then(({ product: productResp }) => {
+ product = productResp;
const productUrl = productDetailsUrl(product.id);
- productSteps.updateProductPublish(productUrl, false);
- productDetails.getProductDetails(product.id, defaultChannel.slug);
+ updateProductPublish(productUrl, false);
+ getProductDetails(product.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isProductVisible(resp, productName);
@@ -90,7 +91,7 @@ describe("Published products", () => {
cy.loginInShop();
})
.then(() => {
- productDetails.getProductDetails(product.id, defaultChannel.slug);
+ getProductDetails(product.id, defaultChannel.slug);
})
.then(resp => {
const isVisible = isProductVisible(resp, productName);
diff --git a/cypress/integration/products/menageProducts/visibleInListingsProducts.js b/cypress/integration/products/menageProducts/visibleInListingsProducts.js
index 9d5d06c54..aa65df728 100644
--- a/cypress/integration/products/menageProducts/visibleInListingsProducts.js
+++ b/cypress/integration/products/menageProducts/visibleInListingsProducts.js
@@ -1,19 +1,14 @@
import faker from "faker";
-import Search from "../../../apiRequests/storeFront/Search";
-import ProductSteps from "../../../steps/products/productSteps";
+import { searchInShop } from "../../../apiRequests/storeFront/Search";
+import { updateProductVisibleInListings } from "../../../steps/products/productSteps";
import { productDetailsUrl } from "../../../url/urlList";
-import ChannelsUtils from "../../../utils/channelsUtils";
-import ProductsUtils from "../../../utils/productsUtils";
+import { getDefaultChannel } from "../../../utils/channelsUtils";
+import * as productsUtils from "../../../utils/productsUtils";
import { isProductVisibleInSearchResult } from "../../../utils/storeFront/storeFrontProductUtils";
//
describe("Products displayed in listings", () => {
- const search = new Search();
- const channelsUtils = new ChannelsUtils();
- const productsUtils = new ProductsUtils();
- const productSteps = new ProductSteps();
-
const startsWith = "Cy-";
const name = `${startsWith}${faker.random.number()}`;
let productType;
@@ -22,12 +17,20 @@ describe("Products displayed in listings", () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
- productsUtils.deleteProperProducts(startsWith);
- productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
- productType = productsUtils.getProductType();
- attribute = productsUtils.getAttribute();
- category = productsUtils.getCategory();
- });
+ productsUtils.deleteProductsStartsWith(startsWith);
+ productsUtils
+ .createTypeAttributeAndCategoryForProduct(name)
+ .then(
+ ({
+ attribute: attributeResp,
+ productType: productTypeResp,
+ category: categoryResp
+ }) => {
+ productType = productTypeResp;
+ attribute = attributeResp;
+ category = categoryResp;
+ }
+ );
});
beforeEach(() => {
@@ -36,8 +39,7 @@ describe("Products displayed in listings", () => {
it("should update product to visible in listings", () => {
const productName = `${startsWith}${faker.random.number()}`;
let defaultChannel;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
productsUtils.createProductInChannel({
@@ -50,11 +52,11 @@ describe("Products displayed in listings", () => {
isAvailableForPurchase: false
});
})
- .then(() => {
- const product = productsUtils.getCreatedProduct();
+ .then(({ product: productResp }) => {
+ const product = productResp;
const productUrl = productDetailsUrl(product.id);
- productSteps.updateProductVisibleInListings(productUrl);
- search.searchInShop(productName);
+ updateProductVisibleInListings(productUrl);
+ searchInShop(productName);
})
.then(resp => {
const isProductVisible = isProductVisibleInSearchResult(
@@ -67,8 +69,7 @@ describe("Products displayed in listings", () => {
it("should update product to not visible in listings", () => {
const productName = `${startsWith}${faker.random.number()}`;
let defaultChannel;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
productsUtils.createProductInChannel({
@@ -80,12 +81,12 @@ describe("Products displayed in listings", () => {
visibleInListings: true
});
})
- .then(() => {
- const product = productsUtils.getCreatedProduct();
+ .then(({ product: productResp }) => {
+ const product = productResp;
const productUrl = productDetailsUrl(product.id);
- productSteps.updateProductVisibleInListings(productUrl);
+ updateProductVisibleInListings(productUrl);
- search.searchInShop(productName).then(resp => {
+ searchInShop(productName).then(resp => {
const isProductVisible = isProductVisibleInSearchResult(
resp,
productName
@@ -95,7 +96,7 @@ describe("Products displayed in listings", () => {
cy.loginInShop();
})
.then(() => {
- search.searchInShop(productName);
+ searchInShop(productName);
})
.then(resp => {
const isProductVisible = isProductVisibleInSearchResult(
diff --git a/cypress/integration/products/productsVariants.js b/cypress/integration/products/productsVariants.js
index 7c28eb999..8c40c7567 100644
--- a/cypress/integration/products/productsVariants.js
+++ b/cypress/integration/products/productsVariants.js
@@ -1,27 +1,28 @@
import faker from "faker";
-import Channels from "../../apiRequests/Channels";
-import Product from "../../apiRequests/Product";
-import VariantsSteps from "../../steps/products/VariantsSteps";
+import { createChannel } from "../../apiRequests/Channels";
+import {
+ createProduct,
+ updateChannelInProduct
+} from "../../apiRequests/Product";
+import {
+ createFirstVariant,
+ createVariant
+} from "../../steps/products/VariantsSteps";
import { urlList } from "../../url/urlList";
-import ChannelsUtils from "../../utils/channelsUtils";
-import ProductsUtils from "../../utils/productsUtils";
-import ShippingUtils from "../../utils/shippingUtils";
+import {
+ deleteChannelsStartsWith,
+ getDefaultChannel
+} from "../../utils/channelsUtils";
+import * as productUtils from "../../utils/productsUtils";
+import * as shippingUtils from "../../utils/shippingUtils";
import { getProductVariants } from "../../utils/storeFront/storeFrontProductUtils";
//
-describe("creating variants", () => {
+describe("Creating variants", () => {
const startsWith = "Cy-";
const attributeValues = ["value1", "value2"];
- const productUtils = new ProductsUtils();
- const channelsUtils = new ChannelsUtils();
- const shippingUtils = new ShippingUtils();
- const product = new Product();
- const channels = new Channels();
-
- const variantsSteps = new VariantsSteps();
-
let defaultChannel;
let warehouse;
let attribute;
@@ -30,13 +31,12 @@ describe("creating variants", () => {
before(() => {
cy.clearSessionData().loginUserViaRequest();
- shippingUtils.deleteShipping(startsWith);
- productUtils.deleteProperProducts(startsWith);
- channelsUtils.deleteChannels(startsWith);
+ shippingUtils.deleteShippingStartsWith(startsWith);
+ productUtils.deleteProductsStartsWith(startsWith);
+ deleteChannelsStartsWith(startsWith);
const name = `${startsWith}${faker.random.number()}`;
- channelsUtils
- .getDefaultChannel()
+ getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
@@ -48,15 +48,21 @@ describe("creating variants", () => {
address: fixtureAddresses.plAddress
})
)
- .then(() => (warehouse = shippingUtils.getWarehouse()));
+ .then(({ warehouse: warehouseResp }) => (warehouse = warehouseResp));
productUtils
.createTypeAttributeAndCategoryForProduct(name, attributeValues)
- .then(() => {
- attribute = productUtils.getAttribute();
- productType = productUtils.getProductType();
- category = productUtils.getCategory();
- });
+ .then(
+ ({
+ attribute: attributeResp,
+ productType: productTypeResp,
+ category: categoryResp
+ }) => {
+ attribute = attributeResp;
+ productType = productTypeResp;
+ category = categoryResp;
+ }
+ );
});
beforeEach(() => {
@@ -68,16 +74,15 @@ describe("creating variants", () => {
const price = 10;
let createdProduct;
- product
- .createProduct(attribute.id, name, productType.id, category.id)
+ createProduct(attribute.id, name, productType.id, category.id)
.then(resp => {
createdProduct = resp.body.data.productCreate.product;
- product.updateChannelInProduct({
+ updateChannelInProduct({
productId: createdProduct.id,
channelId: defaultChannel.id
});
cy.visit(`${urlList.products}${createdProduct.id}`);
- variantsSteps.createFirstVariant({
+ createFirstVariant({
sku: name,
warehouseId: warehouse.id,
price,
@@ -106,10 +111,10 @@ describe("creating variants", () => {
categoryId: category.id,
price: variants[0].price
})
- .then(() => {
- createdProduct = productUtils.getCreatedProduct();
+ .then(({ product: productResp }) => {
+ createdProduct = productResp;
cy.visit(`${urlList.products}${createdProduct.id}`);
- variantsSteps.createVariant({
+ createVariant({
sku: secondVariantSku,
warehouseName: warehouse.name,
attributeName: variants[1].name,
@@ -128,8 +133,7 @@ describe("creating variants", () => {
const variantsPrice = 10;
let newChannel;
let createdProduct;
- channels
- .createChannel(true, name, name, "PLN")
+ createChannel(true, name, name, "PLN")
.then(resp => {
newChannel = resp.body.data.channelCreate.channel;
productUtils.createProduct(
@@ -139,22 +143,22 @@ describe("creating variants", () => {
category.id
);
})
- .then(() => {
- createdProduct = productUtils.getCreatedProduct();
- product.updateChannelInProduct({
+ .then(productResp => {
+ createdProduct = productResp;
+ updateChannelInProduct({
productId: createdProduct.id,
channelId: defaultChannel.id
});
})
.then(() => {
- product.updateChannelInProduct({
+ updateChannelInProduct({
productId: createdProduct.id,
channelId: newChannel.id
});
})
.then(() => {
cy.visit(`${urlList.products}${createdProduct.id}`);
- variantsSteps.createFirstVariant({
+ createFirstVariant({
sku: name,
warehouseId: warehouse.id,
price: variantsPrice,
diff --git a/cypress/steps/channelsSteps.js b/cypress/steps/channelsSteps.js
index 0993496b1..0c79c56bd 100644
--- a/cypress/steps/channelsSteps.js
+++ b/cypress/steps/channelsSteps.js
@@ -1,26 +1,22 @@
import { ADD_CHANNEL_FORM_SELECTORS } from "../elements/channels/add-channel-form-selectors";
import { CHANNELS_SELECTORS } from "../elements/channels/channels-selectors";
-class ChannelsSteps {
- createChannelByView(name, currency, otherCurrency, slug = name) {
- cy.get(CHANNELS_SELECTORS.createChannelButton)
- .click()
- .get(ADD_CHANNEL_FORM_SELECTORS.channelName)
- .type(name)
- .get(ADD_CHANNEL_FORM_SELECTORS.slug)
- .type(slug)
- .get(ADD_CHANNEL_FORM_SELECTORS.currency)
- .click();
- if (!otherCurrency) {
- cy.get(ADD_CHANNEL_FORM_SELECTORS.currency).type(currency);
- cy.get(`[data-test-value=${currency}]`).click();
+export function createChannelByView(name, currency, slug = name) {
+ cy.get(CHANNELS_SELECTORS.createChannelButton)
+ .click()
+ .get(ADD_CHANNEL_FORM_SELECTORS.channelName)
+ .type(name)
+ .get(ADD_CHANNEL_FORM_SELECTORS.slug)
+ .type(slug)
+ .get(ADD_CHANNEL_FORM_SELECTORS.currency)
+ .click();
+ cy.get(ADD_CHANNEL_FORM_SELECTORS.currency).type(currency);
+ cy.get("body").then($body => {
+ if ($body.find(currency).length) {
+ cy.contains(ADD_CHANNEL_FORM_SELECTORS.currencyOptions, currency).click();
} else {
- cy.get(ADD_CHANNEL_FORM_SELECTORS.currency)
- .type(otherCurrency)
- .get(ADD_CHANNEL_FORM_SELECTORS.currencyAutocompleteDropdown)
- .click();
+ cy.get(ADD_CHANNEL_FORM_SELECTORS.currencyAutocompleteDropdown).click();
}
- cy.get(ADD_CHANNEL_FORM_SELECTORS.saveButton).click();
- }
+ });
+ cy.get(ADD_CHANNEL_FORM_SELECTORS.saveButton).click();
}
-export default ChannelsSteps;
diff --git a/cypress/steps/collectionsSteps.js b/cypress/steps/collectionsSteps.js
index ca0f72e9b..5ebdff12c 100644
--- a/cypress/steps/collectionsSteps.js
+++ b/cypress/steps/collectionsSteps.js
@@ -2,48 +2,46 @@ import { COLLECTION_SELECTORS } from "../elements/catalog/collection-selectors";
import { ASSIGN_PRODUCTS_SELECTORS } from "../elements/catalog/products/assign-products-selectors";
import { MENAGE_CHANNEL_AVAILABILITY_FORM } from "../elements/channels/menage-channel-availability-form";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
-class CollectionsSteps {
- createCollection(collectionName, isPublished, channel) {
- const publishedSelector = isPublished
- ? MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueTrue
- : MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse;
- cy.get(COLLECTION_SELECTORS.createCollectionButton)
- .click()
- .get(COLLECTION_SELECTORS.nameInput)
- .type(collectionName)
- .get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsMenageButton)
- .click()
- .get(MENAGE_CHANNEL_AVAILABILITY_FORM.allChannelsCheckbox)
- .click();
- cy.contains(MENAGE_CHANNEL_AVAILABILITY_FORM.channelRow, channel.name)
- .find(MENAGE_CHANNEL_AVAILABILITY_FORM.channelCheckbox)
- .click()
- .get(BUTTON_SELECTORS.submit)
- .click()
- .get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsAvailabilityItem)
- .click()
- .get(
- `${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${publishedSelector}`
- )
- .click();
- cy.addAliasToGraphRequest("CreateCollection");
- cy.get(COLLECTION_SELECTORS.saveButton).click();
- return cy
- .wait("@CreateCollection")
- .its("response.body.data.collectionCreate.collection");
- }
- assignProductsToCollection(productName) {
- cy.get(COLLECTION_SELECTORS.addProductButton)
- .click()
- .get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
- .type(productName);
- cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, productName)
- .find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
- .click();
- cy.addAliasToGraphRequest("CollectionAssignProduct");
- cy.get(ASSIGN_PRODUCTS_SELECTORS.submitButton).click();
- cy.wait("@CollectionAssignProduct");
- }
+export function createCollection(collectionName, isPublished, channel) {
+ const publishedSelector = isPublished
+ ? MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueTrue
+ : MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse;
+
+ cy.get(COLLECTION_SELECTORS.createCollectionButton)
+ .click()
+ .get(COLLECTION_SELECTORS.nameInput)
+ .type(collectionName)
+ .get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsMenageButton)
+ .click()
+ .get(MENAGE_CHANNEL_AVAILABILITY_FORM.allChannelsCheckbox)
+ .click();
+ cy.contains(MENAGE_CHANNEL_AVAILABILITY_FORM.channelRow, channel.name)
+ .find(MENAGE_CHANNEL_AVAILABILITY_FORM.channelCheckbox)
+ .click()
+ .get(BUTTON_SELECTORS.submit)
+ .click()
+ .get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsAvailabilityItem)
+ .click()
+ .get(
+ `${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${publishedSelector}`
+ )
+ .click();
+ cy.addAliasToGraphRequest("CreateCollection");
+ cy.get(COLLECTION_SELECTORS.saveButton).click();
+ return cy
+ .wait("@CreateCollection")
+ .its("response.body.data.collectionCreate.collection");
+}
+export function assignProductsToCollection(productName) {
+ cy.get(COLLECTION_SELECTORS.addProductButton)
+ .click()
+ .get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
+ .type(productName);
+ cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, productName)
+ .find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
+ .click();
+ cy.addAliasToGraphRequest("CollectionAssignProduct");
+ cy.get(ASSIGN_PRODUCTS_SELECTORS.submitButton).click();
+ cy.wait("@CollectionAssignProduct");
}
-export default CollectionsSteps;
diff --git a/cypress/steps/homePageSteps.js b/cypress/steps/homePageSteps.js
index 72b9c6d96..d9f2ee2eb 100644
--- a/cypress/steps/homePageSteps.js
+++ b/cypress/steps/homePageSteps.js
@@ -1,12 +1,9 @@
import { HEADER_SELECTORS } from "../elements/header/header-selectors";
-class HomePageSteps {
- changeChannel(channelName) {
- cy.get(HEADER_SELECTORS.channelSelect).click();
- cy.addAliasToGraphRequest("Home");
- cy.get(HEADER_SELECTORS.channelSelectList)
- .contains(channelName)
- .click();
- cy.wait("@Home");
- }
+export function changeChannel(channelName) {
+ cy.get(HEADER_SELECTORS.channelSelect).click();
+ cy.addAliasToGraphRequest("Home");
+ cy.get(HEADER_SELECTORS.channelSelectList)
+ .contains(channelName)
+ .click();
+ cy.wait("@Home");
}
-export default HomePageSteps;
diff --git a/cypress/steps/products/VariantsSteps.js b/cypress/steps/products/VariantsSteps.js
index 0234d5faf..3b7d8924c 100644
--- a/cypress/steps/products/VariantsSteps.js
+++ b/cypress/steps/products/VariantsSteps.js
@@ -1,55 +1,52 @@
import { PRODUCTS_SELECTORS } from "../../elements/catalog/products/product-selectors";
import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
-class VariantsSteps {
- createFirstVariant({ sku, warehouseId, price, attribute }) {
- cy.get(PRODUCTS_SELECTORS.addVariantsButton).click();
- cy.get(VARIANTS_SELECTORS.valueContainer)
- .contains(attribute)
- .find(VARIANTS_SELECTORS.attributeCheckbox)
- .click()
- .get(VARIANTS_SELECTORS.nextButton)
- .click()
- .get(VARIANTS_SELECTORS.priceInput)
- .each($priceInput => {
- cy.wrap($priceInput).type(price);
- });
- cy.get(`[name*='${warehouseId}']`)
- .click()
- .get(VARIANTS_SELECTORS.nextButton)
- .click()
- .get(VARIANTS_SELECTORS.skuInput)
- .type(sku);
- cy.addAliasToGraphRequest("ProductVariantBulkCreate");
- cy.get(VARIANTS_SELECTORS.nextButton).click();
- cy.wait("@ProductVariantBulkCreate");
- }
- createVariant({
- sku,
- warehouseName,
- attributeName,
- price,
- costPrice = price
- }) {
- cy.get(PRODUCTS_SELECTORS.addVariantsButton)
- .click()
- .get(VARIANTS_SELECTORS.attributeSelector)
- .click()
- .get(VARIANTS_SELECTORS.attributeOption)
- .contains(attributeName)
- .click()
- .get(VARIANTS_SELECTORS.priceInput)
- .type(price)
- .get(VARIANTS_SELECTORS.costPriceInput)
- .type(costPrice)
- .get(VARIANTS_SELECTORS.skuInputInAddVariant)
- .type(sku)
- .get(VARIANTS_SELECTORS.addWarehouseButton)
- .click();
- cy.contains(VARIANTS_SELECTORS.warehouseOption, warehouseName).click();
- cy.addAliasToGraphRequest("ProductVariantDetails");
- cy.get(VARIANTS_SELECTORS.saveButton).click();
- cy.wait("@ProductVariantDetails");
- }
+export function createFirstVariant({ sku, warehouseId, price, attribute }) {
+ cy.get(PRODUCTS_SELECTORS.addVariantsButton).click();
+ cy.get(VARIANTS_SELECTORS.valueContainer)
+ .contains(attribute)
+ .find(VARIANTS_SELECTORS.attributeCheckbox)
+ .click()
+ .get(VARIANTS_SELECTORS.nextButton)
+ .click()
+ .get(VARIANTS_SELECTORS.priceInput)
+ .each($priceInput => {
+ cy.wrap($priceInput).type(price);
+ });
+ cy.get(`[name*='${warehouseId}']`)
+ .click()
+ .get(VARIANTS_SELECTORS.nextButton)
+ .click()
+ .get(VARIANTS_SELECTORS.skuInput)
+ .type(sku);
+ cy.addAliasToGraphRequest("ProductVariantBulkCreate");
+ cy.get(VARIANTS_SELECTORS.nextButton).click();
+ cy.wait("@ProductVariantBulkCreate");
+}
+export function createVariant({
+ sku,
+ warehouseName,
+ attributeName,
+ price,
+ costPrice = price
+}) {
+ cy.get(PRODUCTS_SELECTORS.addVariantsButton)
+ .click()
+ .get(VARIANTS_SELECTORS.attributeSelector)
+ .click()
+ .get(VARIANTS_SELECTORS.attributeOption)
+ .contains(attributeName)
+ .click()
+ .get(VARIANTS_SELECTORS.priceInput)
+ .type(price)
+ .get(VARIANTS_SELECTORS.costPriceInput)
+ .type(costPrice)
+ .get(VARIANTS_SELECTORS.skuInputInAddVariant)
+ .type(sku)
+ .get(VARIANTS_SELECTORS.addWarehouseButton)
+ .click();
+ cy.contains(VARIANTS_SELECTORS.warehouseOption, warehouseName).click();
+ cy.addAliasToGraphRequest("ProductVariantDetails");
+ cy.get(VARIANTS_SELECTORS.saveButton).click();
+ cy.wait("@ProductVariantDetails");
}
-export default VariantsSteps;
diff --git a/cypress/steps/products/productSteps.js b/cypress/steps/products/productSteps.js
index 78d5870d1..28b1b7128 100644
--- a/cypress/steps/products/productSteps.js
+++ b/cypress/steps/products/productSteps.js
@@ -1,37 +1,37 @@
import { PRODUCTS_SELECTORS } from "../../elements/catalog/products/product-selectors";
-class ProductSteps {
- valueTrue = PRODUCTS_SELECTORS.radioButtonsValueTrue;
- valueFalse = PRODUCTS_SELECTORS.radioButtonsValueFalse;
+const valueTrue = PRODUCTS_SELECTORS.radioButtonsValueTrue;
+const valueFalse = PRODUCTS_SELECTORS.radioButtonsValueFalse;
- updateProductIsAvailableForPurchase(productUrl, isAvailableForPurchase) {
- const isAvailableForPurchaseSelector = isAvailableForPurchase
- ? this.valueTrue
- : this.valueFalse;
- const availableForPurchaseSelector = `${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`;
- this.updateProductMenageInChannel(productUrl, availableForPurchaseSelector);
- }
- updateProductPublish(productUrl, isPublished) {
- const isPublishedSelector = isPublished ? this.valueTrue : this.valueFalse;
- const publishedSelector = `${PRODUCTS_SELECTORS.publishedRadioButtons}${isPublishedSelector}`;
- this.updateProductMenageInChannel(productUrl, publishedSelector);
- }
- updateProductVisibleInListings(productUrl) {
- this.updateProductMenageInChannel(
- productUrl,
- PRODUCTS_SELECTORS.visibleInListingsButton
- );
- }
- updateProductMenageInChannel(productUrl, menageSelector) {
- cy.visit(productUrl)
- .get(PRODUCTS_SELECTORS.assignedChannels)
- .click()
- .get(menageSelector)
- .click();
- cy.addAliasToGraphRequest("ProductChannelListingUpdate");
- cy.get(PRODUCTS_SELECTORS.saveBtn)
- .click()
- .wait("@ProductChannelListingUpdate");
- }
+export function updateProductIsAvailableForPurchase(
+ productUrl,
+ isAvailableForPurchase
+) {
+ const isAvailableForPurchaseSelector = isAvailableForPurchase
+ ? valueTrue
+ : valueFalse;
+ const availableForPurchaseSelector = `${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`;
+ updateProductMenageInChannel(productUrl, availableForPurchaseSelector);
+}
+export function updateProductPublish(productUrl, isPublished) {
+ const isPublishedSelector = isPublished ? valueTrue : valueFalse;
+ const publishedSelector = `${PRODUCTS_SELECTORS.publishedRadioButtons}${isPublishedSelector}`;
+ updateProductMenageInChannel(productUrl, publishedSelector);
+}
+export function updateProductVisibleInListings(productUrl) {
+ updateProductMenageInChannel(
+ productUrl,
+ PRODUCTS_SELECTORS.visibleInListingsButton
+ );
+}
+function updateProductMenageInChannel(productUrl, menageSelector) {
+ cy.visit(productUrl)
+ .get(PRODUCTS_SELECTORS.assignedChannels)
+ .click()
+ .get(menageSelector)
+ .click();
+ cy.addAliasToGraphRequest("ProductChannelListingUpdate");
+ cy.get(PRODUCTS_SELECTORS.saveBtn)
+ .click()
+ .wait("@ProductChannelListingUpdate");
}
-export default ProductSteps;
diff --git a/cypress/support/deleteElement/index.js b/cypress/support/deleteElement/index.js
index ff15bd8b3..03ad58c8e 100644
--- a/cypress/support/deleteElement/index.js
+++ b/cypress/support/deleteElement/index.js
@@ -7,7 +7,7 @@ Cypress.Commands.add(
}
);
Cypress.Commands.add(
- "deleteProperElements",
+ "deleteElementsStartsWith",
(deleteFunction, getFunction, startsWith, name) => {
getFunction(100, startsWith).then(elements => {
elements.forEach(element => {
diff --git a/cypress/utils/channelsUtils.js b/cypress/utils/channelsUtils.js
index a67a1b404..c9bf434aa 100644
--- a/cypress/utils/channelsUtils.js
+++ b/cypress/utils/channelsUtils.js
@@ -1,52 +1,44 @@
-import Channels from "../apiRequests/Channels";
+import * as channels from "../apiRequests/Channels";
-class ChannelsUtils {
- channels = new Channels();
- createdChannel;
-
- deleteChannels(nameStartsWith) {
- this.channels.getChannels().then(resp => {
- const channelsArray = new Set(resp.body.data.channels);
- if (!channelsArray) {
- return;
- }
- channelsArray.forEach(element => {
- if (element.name.startsWith(nameStartsWith)) {
- const targetChannels = Array.from(channelsArray).filter(function(
- channelElement
- ) {
- return (
- element.currencyCode === channelElement.currencyCode &&
- element.id !== channelElement.id
- );
- });
- if (targetChannels[0]) {
- this.channels.deleteChannel(element.id, targetChannels[0].id);
- channelsArray.delete(element);
- }
+export function deleteChannelsStartsWith(nameStartsWith) {
+ channels.getChannels().then(resp => {
+ const channelsArray = new Set(resp.body.data.channels);
+ if (!channelsArray) {
+ return;
+ }
+ channelsArray.forEach(element => {
+ if (element.name.startsWith(nameStartsWith)) {
+ const targetChannels = Array.from(channelsArray).filter(function(
+ channelElement
+ ) {
+ return (
+ element.currencyCode === channelElement.currencyCode &&
+ element.id !== channelElement.id
+ );
+ });
+ if (targetChannels[0]) {
+ channels.deleteChannel(element.id, targetChannels[0].id);
+ channelsArray.delete(element);
}
- });
+ }
});
- }
- getDefaultChannel() {
- return this.channels.getChannels().then(resp => {
- const channelsArray = resp.body.data.channels;
- return (this.defaultChannel = channelsArray.find(function(
- channelElement
- ) {
- return channelElement.slug === "default-channel";
- }));
- });
- }
- createChannel({ isActive = true, name, slug = name, currencyCode = "PLN" }) {
- return this.channels
- .createChannel(isActive, name, slug, currencyCode)
- .then(
- resp => (this.createdChannel = resp.body.data.channelCreate.channel)
- );
- }
- getCreatedChannel() {
- return this.createdChannel;
- }
+ });
+}
+export function getDefaultChannel() {
+ return channels.getChannels().then(resp => {
+ const channelsArray = resp.body.data.channels;
+ return channelsArray.find(function(channelElement) {
+ return channelElement.slug === "default-channel";
+ });
+ });
+}
+export function createChannel({
+ isActive = true,
+ name,
+ slug = name,
+ currencyCode = "PLN"
+}) {
+ return channels
+ .createChannel(isActive, name, slug, currencyCode)
+ .its("body.data.channelCreate.channel");
}
-export default ChannelsUtils;
diff --git a/cypress/utils/collectionsUtils.js b/cypress/utils/collectionsUtils.js
index bf80f36ec..cfe3694b0 100644
--- a/cypress/utils/collectionsUtils.js
+++ b/cypress/utils/collectionsUtils.js
@@ -1,15 +1,10 @@
-import Collections from "../apiRequests/Collections";
+import { deleteCollection, getCollections } from "../apiRequests/Collections";
-class CollectionsUtils {
- collectionsRequest = new Collections();
-
- deleteProperCollections(startsWith) {
- cy.deleteProperElements(
- this.collectionsRequest.deleteCollection,
- this.collectionsRequest.getCollections,
- startsWith,
- "collection"
- );
- }
+export function deleteCollectionsStartsWith(startsWith) {
+ cy.deleteElementsStartsWith(
+ deleteCollection,
+ getCollections,
+ startsWith,
+ "collection"
+ );
}
-export default CollectionsUtils;
diff --git a/cypress/utils/homePageUtils.js b/cypress/utils/homePageUtils.js
index 27d298105..a6befe554 100644
--- a/cypress/utils/homePageUtils.js
+++ b/cypress/utils/homePageUtils.js
@@ -1,30 +1,27 @@
-import HomePage from "../apiRequests/HomePage";
-class HomePageUtils {
- homePage = new HomePage();
- getOrdersReadyToFulfill(channelSlug) {
- return this.homePage
- .getOrdersWithStatus("READY_TO_FULFILL", channelSlug)
- .then(resp => resp.body.data.orders.totalCount);
- }
- getOrdersReadyForCapture(channelSlug) {
- return this.homePage
- .getOrdersWithStatus("READY_TO_CAPTURE", channelSlug)
- .then(resp => resp.body.data.orders.totalCount);
- }
- getProductsOutOfStock(channelSlug) {
- return this.homePage
- .getProductsOutOfStock(channelSlug)
- .then(resp => resp.body.data.products.totalCount);
- }
- getSalesAmount(channelSlug) {
- return this.homePage
- .getSalesForChannel(channelSlug, "TODAY")
- .then(resp => resp.body.data.ordersTotal.gross.amount);
- }
- getTodaysOrders(channelSlug) {
- return this.homePage
- .getOrdersForChannel(channelSlug, "TODAY")
- .then(resp => resp.body.data.orders.totalCount);
- }
+import * as homePage from "../apiRequests/HomePage";
+
+export function getOrdersReadyToFulfill(channelSlug) {
+ return homePage
+ .getOrdersWithStatus("READY_TO_FULFILL", channelSlug)
+ .its("body.data.orders.totalCount");
+}
+export function getOrdersReadyForCapture(channelSlug) {
+ return homePage
+ .getOrdersWithStatus("READY_TO_CAPTURE", channelSlug)
+ .its("body.data.orders.totalCount");
+}
+export function getProductsOutOfStock(channelSlug) {
+ return homePage
+ .getProductsOutOfStock(channelSlug)
+ .its("body.data.products.totalCount");
+}
+export function getSalesAmount(channelSlug) {
+ return homePage
+ .getSalesForChannel(channelSlug, "TODAY")
+ .its("body.data.ordersTotal.gross.amount");
+}
+export function getTodaysOrders(channelSlug) {
+ return homePage
+ .getOrdersForChannel(channelSlug, "TODAY")
+ .its("body.data.orders.totalCount");
}
-export default HomePageUtils;
diff --git a/cypress/utils/ordersUtils.js b/cypress/utils/ordersUtils.js
index e535624d9..a9124e553 100644
--- a/cypress/utils/ordersUtils.js
+++ b/cypress/utils/ordersUtils.js
@@ -1,60 +1,53 @@
-import Checkout from "../apiRequests/Checkout";
-import Order from "../apiRequests/Order";
+import * as checkoutRequest from "../apiRequests/Checkout";
+import * as orderRequest from "../apiRequests/Order";
-class OrdersUtils {
- checkoutRequest = new Checkout();
- orderRequest = new Order();
-
- checkout;
- order;
-
- createWaitingForCaptureOrder(
- channelSlug,
- email,
- variantsList,
- shippingMethodId
- ) {
- return this.createCheckout(channelSlug, email, variantsList)
- .then(() =>
- this.checkoutRequest.addShippingMethod(
- this.checkout.id,
- shippingMethodId
- )
- )
- .then(() => this.addPayment(this.checkout.id))
- .then(() => this.checkoutRequest.completeCheckout(this.checkout.id));
- }
- createReadyToFulfillOrder(
- customerId,
- shippingMethodId,
- channelId,
- variantsList
- ) {
- return this.createDraftOrder(customerId, shippingMethodId, channelId)
- .then(() => {
- variantsList.forEach(variantElement => {
- this.orderRequest.addProductToOrder(this.order.id, variantElement.id);
- });
- })
- .then(() => this.orderRequest.markOrderAsPaid(this.order.id))
- .then(() => this.orderRequest.completeOrder(this.order.id));
- }
- createDraftOrder(customerId, shippingMethodId, channelId) {
- return this.orderRequest
- .createDraftOrder(customerId, shippingMethodId, channelId)
- .then(resp => (this.order = resp.body.data.draftOrderCreate.order));
- }
- createCheckout(channelSlug, email, variantsList) {
- return this.checkoutRequest
- .createCheckout(channelSlug, email, 1, variantsList)
- .then(resp => (this.checkout = resp.body.data.checkoutCreate.checkout));
- }
- addPayment(checkoutId) {
- return this.checkoutRequest.addPayment(
- checkoutId,
- "mirumee.payments.dummy",
- "not-charged"
- );
- }
+export function createWaitingForCaptureOrder(
+ channelSlug,
+ email,
+ variantsList,
+ shippingMethodId
+) {
+ let checkout;
+ return createCheckout(channelSlug, email, variantsList)
+ .then(checkoutResp => {
+ checkout = checkoutResp;
+ checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
+ })
+ .then(() => addPayment(checkout.id))
+ .then(() => checkoutRequest.completeCheckout(checkout.id))
+ .then(() => checkout);
+}
+export function createReadyToFulfillOrder(
+ customerId,
+ shippingMethodId,
+ channelId,
+ variantsList
+) {
+ let order;
+ return createDraftOrder(customerId, shippingMethodId, channelId)
+ .then(orderResp => {
+ order = orderResp;
+ variantsList.forEach(variantElement => {
+ orderRequest.addProductToOrder(order.id, variantElement.id);
+ });
+ })
+ .then(() => orderRequest.markOrderAsPaid(order.id))
+ .then(() => orderRequest.completeOrder(order.id));
+}
+export function createDraftOrder(customerId, shippingMethodId, channelId) {
+ return orderRequest
+ .createDraftOrder(customerId, shippingMethodId, channelId)
+ .its("body.data.draftOrderCreate.order");
+}
+export function createCheckout(channelSlug, email, variantsList) {
+ return checkoutRequest
+ .createCheckout(channelSlug, email, 1, variantsList)
+ .its("body.data.checkoutCreate.checkout");
+}
+export function addPayment(checkoutId) {
+ return checkoutRequest.addPayment(
+ checkoutId,
+ "mirumee.payments.dummy",
+ "not-charged"
+ );
}
-export default OrdersUtils;
diff --git a/cypress/utils/productsUtils.js b/cypress/utils/productsUtils.js
index d14b5b715..cadced175 100644
--- a/cypress/utils/productsUtils.js
+++ b/cypress/utils/productsUtils.js
@@ -1,152 +1,127 @@
-import Attribute from "../apiRequests/Attribute";
-import Category from "../apiRequests/Category";
-import Product from "../apiRequests/Product";
+import * as attributeRequest from "../apiRequests/Attribute";
+import * as categoryRequest from "../apiRequests/Category";
+import * as productRequest from "../apiRequests/Product";
-class ProductsUtils {
- productRequest = new Product();
- attributeRequest = new Attribute();
- categoryRequest = new Category();
-
- product;
- variants;
- productType;
- attribute;
- category;
-
- createProductWithVariant(name, attributeId, productTypeId, categoryId) {
- return this.createProduct(
- attributeId,
- name,
- productTypeId,
- categoryId
- ).then(() => this.createVariant(this.product.id, name, attributeId));
- }
-
- createProductInChannel({
- name,
- channelId,
- warehouseId = null,
- quantityInWarehouse = 10,
- productTypeId,
- attributeId,
- categoryId,
- price = 1,
- isPublished = true,
- isAvailableForPurchase = true,
- visibleInListings = true
- }) {
- return this.createProduct(attributeId, name, productTypeId, categoryId)
- .then(() =>
- this.productRequest.updateChannelInProduct({
- productId: this.product.id,
- channelId,
- isPublished,
- isAvailableForPurchase,
- visibleInListings
- })
- )
- .then(() => {
- this.createVariant({
- productId: this.product.id,
- sku: name,
- warehouseId,
- quantityInWarehouse,
- channelId,
- price
- });
+export function createProductInChannel({
+ name,
+ channelId,
+ warehouseId = null,
+ quantityInWarehouse = 10,
+ productTypeId,
+ attributeId,
+ categoryId,
+ price = 1,
+ isPublished = true,
+ isAvailableForPurchase = true,
+ visibleInListings = true
+}) {
+ let product;
+ let variants;
+ return createProduct(attributeId, name, productTypeId, categoryId)
+ .then(productResp => {
+ product = productResp;
+ productRequest.updateChannelInProduct({
+ productId: product.id,
+ channelId,
+ isPublished,
+ isAvailableForPurchase,
+ visibleInListings
});
- }
-
- createTypeAttributeAndCategoryForProduct(name, attributeValues) {
- return this.createAttribute(name, attributeValues)
- .then(() => this.createTypeProduct(name, this.attribute.id))
- .then(() => this.createCategory(name));
- }
- createAttribute(name, attributeValues) {
- return this.attributeRequest
- .createAttribute(name, attributeValues)
- .then(
- resp => (this.attribute = resp.body.data.attributeCreate.attribute)
- );
- }
- createTypeProduct(name, attributeId) {
- return this.productRequest
- .createTypeProduct(name, attributeId)
- .then(
- resp =>
- (this.productType = resp.body.data.productTypeCreate.productType)
- );
- }
- createCategory(name) {
- return this.categoryRequest
- .createCategory(name)
- .then(resp => (this.category = resp.body.data.categoryCreate.category));
- }
- createProduct(attributeId, name, productTypeId, categoryId) {
- return this.productRequest
- .createProduct(attributeId, name, productTypeId, categoryId)
- .then(resp => (this.product = resp.body.data.productCreate.product));
- }
- createVariant({
- productId,
- sku,
- warehouseId,
- quantityInWarehouse,
- channelId,
- price
- }) {
- return this.productRequest
- .createVariant({
- productId,
- sku,
+ })
+ .then(() => {
+ createVariant({
+ productId: product.id,
+ sku: name,
warehouseId,
- quantity: quantityInWarehouse,
+ quantityInWarehouse,
channelId,
price
- })
- .then(
- resp =>
- (this.variants =
- resp.body.data.productVariantBulkCreate.productVariants)
- );
- }
- getCreatedProduct() {
- return this.product;
- }
- getCreatedVariants() {
- return this.variants;
- }
- getProductType() {
- return this.productType;
- }
- getAttribute() {
- return this.attribute;
- }
- getCategory() {
- return this.category;
- }
- deleteProperProducts(startsWith) {
- const product = new Product();
- const attribute = new Attribute();
- const category = new Category();
- cy.deleteProperElements(
- product.deleteProductType,
- product.getProductTypes,
- startsWith,
- "productType"
- );
- cy.deleteProperElements(
- attribute.deleteAttribute,
- attribute.getAttributes,
- startsWith,
- "attributes"
- );
- cy.deleteProperElements(
- category.deleteCategory,
- category.getCategories,
- startsWith,
- "categories"
- );
- }
+ });
+ })
+ .then(variantsResp => {
+ variants = variantsResp;
+ return { product, variants };
+ });
+}
+
+export function createTypeAttributeAndCategoryForProduct(
+ name,
+ attributeValues
+) {
+ let attribute;
+ let productType;
+ let category;
+ return createAttribute(name, attributeValues)
+ .then(attributeResp => {
+ attribute = attributeResp;
+ createTypeProduct(name, attributeResp.id);
+ })
+ .then(productTypeResp => {
+ productType = productTypeResp;
+ createCategory(name);
+ })
+ .then(categoryResp => {
+ category = categoryResp;
+ return { attribute, category, productType };
+ });
+}
+export function createAttribute(name, attributeValues) {
+ return attributeRequest
+ .createAttribute(name, attributeValues)
+ .its("body.data.attributeCreate.attribute");
+}
+export function createTypeProduct(name, attributeId) {
+ return productRequest
+ .createTypeProduct(name, attributeId)
+ .its("body.data.productTypeCreate.productType");
+}
+export function createCategory(name) {
+ return categoryRequest
+ .createCategory(name)
+ .its("body.data.categoryCreate.category");
+}
+export function createProduct(attributeId, name, productTypeId, categoryId) {
+ return productRequest
+ .createProduct(attributeId, name, productTypeId, categoryId)
+ .its("body.data.productCreate.product");
+}
+export function createVariant({
+ productId,
+ sku,
+ warehouseId,
+ quantityInWarehouse,
+ channelId,
+ price
+}) {
+ return productRequest
+ .createVariant({
+ productId,
+ sku,
+ warehouseId,
+ quantity: quantityInWarehouse,
+ channelId,
+ price
+ })
+ .its("body.data.productVariantBulkCreate.productVariants");
+}
+
+export function deleteProductsStartsWith(startsWith) {
+ cy.deleteElementsStartsWith(
+ productRequest.deleteProductType,
+ productRequest.getProductTypes,
+ startsWith,
+ "productType"
+ );
+ cy.deleteElementsStartsWith(
+ attributeRequest.deleteAttribute,
+ attributeRequest.getAttributes,
+ startsWith,
+ "attributes"
+ );
+ cy.deleteElementsStartsWith(
+ categoryRequest.deleteCategory,
+ categoryRequest.getCategories,
+ startsWith,
+ "categories"
+ );
}
-export default ProductsUtils;
diff --git a/cypress/utils/shippingUtils.js b/cypress/utils/shippingUtils.js
index 75eb7501f..d297e3f8d 100644
--- a/cypress/utils/shippingUtils.js
+++ b/cypress/utils/shippingUtils.js
@@ -1,77 +1,58 @@
-import ShippingMethod from "../apiRequests/ShippingMethod";
-import Warehouse from "../apiRequests/Warehouse";
-class ShippingUtils {
- shippingMethodRequest = new ShippingMethod();
- warehouseRequest = new Warehouse();
+import * as shippingMethodRequest from "../apiRequests/ShippingMethod";
+import * as warehouseRequest from "../apiRequests/Warehouse";
- shippingMethod;
- shippingZone;
- warehouse;
+export function createShipping({ channelId, name, address, price = 1 }) {
+ let shippingMethod;
+ let shippingZone;
+ let warehouse;
- createShipping({ channelId, name, address, price = 1 }) {
- return this.createShippingZone(name, address.country)
- .then(() => this.createWarehouse(name, this.shippingZone.id, address))
- .then(() => this.createShippingRate(name, this.shippingZone.id))
- .then(() =>
- this.shippingMethodRequest.addChannelToShippingMethod(
- this.shippingMethod.id,
- channelId,
- price
- )
+ return createShippingZone(name, address.country)
+ .then(shippingZoneResp => {
+ shippingZone = shippingZoneResp;
+ createWarehouse(name, shippingZone.id, address);
+ })
+ .then(warehouseResp => {
+ warehouse = warehouseResp;
+ createShippingRate(name, shippingZone.id);
+ })
+ .then(sippingMethodResp => {
+ shippingMethod = sippingMethodResp;
+ shippingMethodRequest.addChannelToShippingMethod(
+ shippingMethod.id,
+ channelId,
+ price
);
- }
-
- createShippingZone(name, country) {
- return this.shippingMethodRequest
- .createShippingZone(name, country)
- .then(resp => {
- this.shippingZone = resp.body.data.shippingZoneCreate.shippingZone;
- });
- }
- createWarehouse(name, shippingZoneId, address) {
- return this.warehouseRequest
- .createWarehouse(name, shippingZoneId, address)
- .then(resp => {
- this.warehouse = resp.body.data.createWarehouse.warehouse;
- });
- }
- createShippingRate(name, shippingZoneId) {
- return this.shippingMethodRequest
- .createShippingRate(name, shippingZoneId)
- .then(
- resp =>
- (this.shippingMethod =
- resp.body.data.shippingPriceCreate.shippingMethod)
- );
- }
-
- getShippingMethod() {
- return this.shippingMethod;
- }
-
- getShippingZone() {
- return this.shippingZone;
- }
-
- getWarehouse() {
- return this.warehouse;
- }
-
- deleteShipping(startsWith) {
- const shippingMethod = new ShippingMethod();
- const warehouse = new Warehouse();
- cy.deleteProperElements(
- shippingMethod.deleteShippingZone,
- shippingMethod.getShippingZones,
- startsWith,
- "shippingZONE"
- );
- cy.deleteProperElements(
- warehouse.deleteWarehouse,
- warehouse.getWarehouses,
- startsWith,
- "Warehouse"
- );
- }
+ })
+ .then(() => ({ shippingMethod, shippingZone, warehouse }));
+}
+
+export function createShippingZone(name, country) {
+ return shippingMethodRequest
+ .createShippingZone(name, country)
+ .its("body.data.shippingZoneCreate.shippingZone");
+}
+export function createWarehouse(name, shippingZoneId, address) {
+ return warehouseRequest
+ .createWarehouse(name, shippingZoneId, address)
+ .its("body.data.createWarehouse.warehouse");
+}
+export function createShippingRate(name, shippingZoneId) {
+ return shippingMethodRequest
+ .createShippingRate(name, shippingZoneId)
+ .its("body.data.shippingPriceCreate.shippingMethod");
+}
+
+export function deleteShippingStartsWith(startsWith) {
+ cy.deleteElementsStartsWith(
+ shippingMethodRequest.deleteShippingZone,
+ shippingMethodRequest.getShippingZones,
+ startsWith,
+ "shippingZONE"
+ );
+ cy.deleteElementsStartsWith(
+ warehouseRequest.deleteWarehouse,
+ warehouseRequest.getWarehouses,
+ startsWith,
+ "Warehouse"
+ );
}
-export default ShippingUtils;
diff --git a/cypress/utils/storeFront/storeFrontProductUtils.js b/cypress/utils/storeFront/storeFrontProductUtils.js
index 54c3a1205..2d6fde7fa 100644
--- a/cypress/utils/storeFront/storeFrontProductUtils.js
+++ b/cypress/utils/storeFront/storeFrontProductUtils.js
@@ -1,4 +1,4 @@
-import ProductDetails from "../../apiRequests/storeFront/ProductDetails";
+import { getProductDetails } from "../../apiRequests/storeFront/ProductDetails";
export const isProductVisible = (resp, name) => {
const product = resp.body.data.product;
@@ -18,13 +18,11 @@ export const isProductVisibleInSearchResult = (resp, productName) => {
);
};
-export const getProductVariants = (productId, channelSlug) => {
- const productDetails = new ProductDetails();
- return productDetails.getProductDetails(productId, channelSlug).then(resp => {
+export const getProductVariants = (productId, channelSlug) =>
+ getProductDetails(productId, channelSlug).then(resp => {
const variantsList = resp.body.data.product.variants;
return variantsList.map(element => ({
name: element.name,
price: element.pricing.price.gross.amount
}));
});
-};