From 29c7f785c0ed9ee854234e384c11e804be9d5ec0 Mon Sep 17 00:00:00 2001 From: Ewa Czerniak Date: Tue, 16 Aug 2022 13:27:37 +0200 Subject: [PATCH] Saleor 7780 fix for collection tests (#2227) * fix fox tests in collection * removing then() in tests * fixing failing collection tests and add stable tag to run will all tests --- cypress/e2e/catalog/collections.js | 659 +++++++++--------- cypress/support/api/requests/Collections.js | 34 + .../api/requests/storeFront/Collections.js | 13 +- .../api/requests/storeFront/ProductDetails.js | 6 +- .../api/utils/storeFront/collectionsUtils.js | 9 - .../support/pages/catalog/collectionsPage.js | 3 +- 6 files changed, 370 insertions(+), 354 deletions(-) delete mode 100644 cypress/support/api/utils/storeFront/collectionsUtils.js diff --git a/cypress/e2e/catalog/collections.js b/cypress/e2e/catalog/collections.js index 1f36aa209..a22350750 100644 --- a/cypress/e2e/catalog/collections.js +++ b/cypress/e2e/catalog/collections.js @@ -8,6 +8,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { collectionDetailsUrl, urlList } from "../../fixtures/urlList"; import { createChannel } from "../../support/api/requests/Channels"; import { + addChannelToCollection, addProductToCollection, createCollection as createCollectionRequest, } from "../../support/api/requests/Collections"; @@ -19,12 +20,6 @@ import { deleteCollectionsStartsWith } from "../../support/api/utils/catalog/col import * as channelsUtils from "../../support/api/utils/channelsUtils"; import * as productsUtils from "../../support/api/utils/products/productsUtils"; import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils"; -import { - isCollectionVisible, - isProductInCollectionVisible, -} from "../../support/api/utils/storeFront/collectionsUtils"; -import { isProductVisibleInSearchResult } from "../../support/api/utils/storeFront/storeFrontProductUtils"; -import filterTests from "../../support/filterTests"; import { assignProductsToCollection, createCollection, @@ -32,368 +27,366 @@ import { updateCollection, } from "../../support/pages/catalog/collectionsPage"; -filterTests({ definedTags: ["all"] }, () => { - describe("As an admin I want to manage collections.", () => { - const startsWith = "CyCollections-"; - const name = `${startsWith}${faker.datatype.number()}`; +describe("As an admin I want to manage collections.", () => { + const startsWith = "CyCollections-"; + const productName = `${startsWith}${faker.datatype.number()}`; - let attribute; - let productType; - let category; - let product; + let attribute; + let productType; + let category; + let product; + let defaultChannel; - let defaultChannel; + before(() => { + cy.clearSessionData().loginUserViaRequest(); + productsUtils.deleteProductsStartsWith(startsWith); + deleteCollectionsStartsWith(startsWith); + deleteShippingStartsWith(startsWith); + channelsUtils.deleteChannelsStartsWith(startsWith); - before(() => { - cy.clearSessionData().loginUserViaRequest(); - productsUtils.deleteProductsStartsWith(startsWith); - deleteCollectionsStartsWith(startsWith); - deleteShippingStartsWith(startsWith); - channelsUtils.deleteChannelsStartsWith(startsWith); + channelsUtils + .getDefaultChannel() + .then(channel => { + defaultChannel = channel; + productsUtils.createTypeAttributeAndCategoryForProduct({ + name: productName, + }); + }) + .then( + ({ + attribute: attributeResp, + productType: productTypeResp, + category: categoryResp, + }) => { + attribute = attributeResp; + productType = productTypeResp; + category = categoryResp; + productsUtils.createProductInChannel({ + name: productName, + channelId: defaultChannel.id, + productTypeId: productType.id, + attributeId: attribute.id, + categoryId: category.id, + }); + }, + ) + .then(({ product: productResp }) => (product = productResp)); + }); - channelsUtils - .getDefaultChannel() - .then(channel => { - defaultChannel = channel; - productsUtils.createTypeAttributeAndCategoryForProduct({ name }); - }) - .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, - }); + beforeEach(() => { + cy.clearSessionData().loginUserViaRequest(); + }); + + it( + "should create hidden collection. TC: SALEOR_0301", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `${startsWith}${faker.datatype.number()}`; + let collection; + + cy.visit(urlList.collections).expectSkeletonIsVisible(); + createCollection(collectionName, false, defaultChannel).then( + collectionResp => { + collection = collectionResp; + + assignProductsToCollection(productName); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection.channelListings.0.isPublished") + .should("eq", false); + }, + ); + }, + ); + + it( + "should create published collection. TC: SALEOR_0302", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `${startsWith}${faker.datatype.number()}`; + let collection; + + cy.visit(urlList.collections).expectSkeletonIsVisible(); + createCollection(collectionName, true, defaultChannel).then( + collectionResp => { + collection = collectionResp; + + assignProductsToCollection(productName); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection.channelListings.0.isPublished") + .should("eq", true); + }, + ); + }, + ); + + it( + "should create collection not available for channel. TC: SALEOR_0303", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `${startsWith}${faker.datatype.number()}`; + let collection; + let channel; + + createChannel({ name: collectionName }).then(channelResp => { + channel = channelResp; + + updateChannelInProduct(product.id, channel.id); + cy.visit(urlList.collections).expectSkeletonIsVisible(); + createCollection(collectionName, false, channel).then( + collectionResp => { + collection = collectionResp; + + assignProductsToCollection(productName); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection") + .should("be.null"); }, - ) - .then(({ product: productResp }) => (product = productResp)); - }); + ); + }); + }, + ); - beforeEach(() => { - cy.clearSessionData().loginUserViaRequest(); - }); + it( + "should create published collection with products hidden in listings. TC: SALEOR_0304", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + // Products "hidden in listings" are not displayed in Category listings or search results, + // but are listed on Collections + const collectionName = `${startsWith}${faker.datatype.number()}`; + let collection; + let createdProduct; - xit( - "should create hidden collection. TC: SALEOR_0301", - { tags: ["@collection", "@allEnv"] }, - () => { - const collectionName = `${startsWith}${faker.datatype.number()}`; - let collection; + productsUtils + .createProductInChannel({ + name: collectionName, + channelId: defaultChannel.id, + productTypeId: productType.id, + attributeId: attribute.id, + categoryId: category.id, + visibleInListings: false, + }) + .then(({ product: productResp }) => (createdProduct = productResp)); - cy.visit(urlList.collections); - cy.expectSkeletonIsVisible(); + cy.visit(urlList.collections).expectSkeletonIsVisible(); + createCollection(collectionName, true, defaultChannel).then( + collectionResp => { + collection = collectionResp; - createCollection(collectionName, false, defaultChannel) - .then(collectionResp => { - collection = collectionResp; - assignProductsToCollection(name); + assignProductsToCollection(collectionName); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, }) - .then(() => { - getCollection({ - collectionId: collection.id, - channelSlug: defaultChannel.slug, - }); - }) - .then(({ collection: resp }) => { - const isVisible = isCollectionVisible(resp, collection.id); - expect(isVisible).to.equal(false); - }); - }, - ); + .its("collection.products.edges.0.node.id") + .should("eq", createdProduct.id); + searchInShop(createdProduct.name) + .its("body.data.products.edges") + .should("be.empty"); + }, + ); + }, + ); - it( - "should create published collection. TC: SALEOR_0302", - { tags: ["@collection", "@allEnv", "@stable"] }, - () => { - const collectionName = `${startsWith}${faker.datatype.number()}`; - let collection; + it( + "should delete collection. TC: SALEOR_0305", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `${startsWith}${faker.datatype.number()}`; - cy.visit(urlList.collections); - cy.expectSkeletonIsVisible(); + createCollectionRequest(collectionName).then(collectionResp => { + cy.visit(collectionDetailsUrl(collectionResp.id)) + .get(BUTTON_SELECTORS.deleteButton) + .click() + .addAliasToGraphRequest("RemoveCollection") + .get(BUTTON_SELECTORS.submit) + .click() + .waitForRequestAndCheckIfNoErrors("@RemoveCollection"); + getCollection({ collectionId: collectionResp.id }) + .its("collection") + .should("be.null"); + }); + }, + ); - createCollection(collectionName, true, defaultChannel) - .then(collectionResp => { - collection = collectionResp; - assignProductsToCollection(name); - getCollection({ - collectionId: collection.id, - channelSlug: defaultChannel.slug, - }); - }) - .then(({ collection: resp }) => { - const isVisible = isCollectionVisible(resp, collection.id); - expect(isVisible).to.equal(true); - }); - }, - ); + it( + "should update collection. TC: SALEOR_0306", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `${startsWith}${faker.datatype.number()}`; + const updatedName = `${startsWith}updatedCollection`; - it( - "create collection not available for channel. TC: SALEOR_0303", - { tags: ["@collection", "@allEnv", "@stable"] }, - () => { - const collectionName = `${startsWith}${faker.datatype.number()}`; - let collection; - let channel; + let collection; - createChannel({ name: collectionName }) - .then(channelResp => { - channel = channelResp; - updateChannelInProduct(product.id, channel.id); - }) - .then(() => { - cy.visit(urlList.collections); - cy.expectSkeletonIsVisible(); - createCollection(collectionName, true, channel); - }) - .then(collectionResp => { - collection = collectionResp; - assignProductsToCollection(name); - getCollection({ - collectionId: collection.id, - channelSlug: defaultChannel.slug, - }); - }) - .then(({ collection: resp }) => { - const isVisible = isCollectionVisible(resp, collection.id); - expect(isVisible).to.equal(false); - }); - }, - ); + createCollectionRequest(collectionName).then(collectionResp => { + collection = collectionResp; - it( - "create published collection with products hidden in listings. TC: SALEOR_0304", - { tags: ["@collection", "@allEnv", "@stable"] }, - () => { - // Products "hidden in listings" are not displayed in Category listings or search results, - // but are listed on Collections - const collectionName = `${startsWith}${faker.datatype.number()}`; - let collection; - let createdProduct; + cy.visitAndWaitForProgressBarToDisappear( + collectionDetailsUrl(collection.id), + ); + addChannelToCollection({ + collectionId: collection.id, + channelId: defaultChannel.id, + }); + updateCollection({ name: updatedName, description: updatedName }); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection") + .should("include", { name: updatedName }) + .its("description") + .should("have.string", `{"text": "${updatedName}"}`); + }); + }, + ); + it( + "should assign product to collection. TC: SALEOR_0307", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `Assign-${startsWith}${faker.datatype.number()}`; + const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`; + + let collection; + let productToAssign; + + createCollectionRequest(collectionName).then(collectionResp => { + collection = collectionResp; + + addChannelToCollection({ + collectionId: collection.id, + channelId: defaultChannel.id, + }); productsUtils .createProductInChannel({ - name: collectionName, + name: productName, channelId: defaultChannel.id, productTypeId: productType.id, attributeId: attribute.id, categoryId: category.id, visibleInListings: false, }) - .then(({ product: productResp }) => (createdProduct = productResp)); - cy.visit(urlList.collections); - cy.expectSkeletonIsVisible(); - createCollection(collectionName, true, defaultChannel) - .then(collectionResp => { - collection = collectionResp; - assignProductsToCollection(collectionName); - }) - .then(() => { + .then(({ product: productResp }) => { + productToAssign = productResp; + + cy.visitAndWaitForProgressBarToDisappear( + collectionDetailsUrl(collection.id), + ); + cy.reload(); + assignProductsToCollection(productToAssign.name); getCollection({ collectionId: collection.id, channelSlug: defaultChannel.slug, - }); - }) - .then(({ collection: resp }) => { - const isVisible = isProductInCollectionVisible( - resp, - createdProduct.id, - ); - expect(isVisible).to.equal(true); - }) - .then(() => { - searchInShop(createdProduct.name); - }) - .then(resp => { - const isVisible = isProductVisibleInSearchResult( - resp, - createdProduct.name, - ); - expect(isVisible).to.equal(false); + }) + .its("collection.products.edges.0.node.id") + .should("include", productToAssign.id); }); - }, - ); + }); + }, + ); - it( - "should delete collection. TC: SALEOR_0305", - { tags: ["@collection", "@allEnv", "@stable"] }, - () => { - const collectionName = `${startsWith}${faker.datatype.number()}`; + it( + "should remove product from collection. TC: SALEOR_0308", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const collectionName = `Remove-With-Assigned-Product-${startsWith}${faker.datatype.number()}`; + const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`; + let collection; + let productToAssign; - createCollectionRequest(collectionName).then(collectionResp => { - cy.visit(collectionDetailsUrl(collectionResp.id)) - .get(BUTTON_SELECTORS.deleteButton) - .click() - .addAliasToGraphRequest("RemoveCollection") - .get(BUTTON_SELECTORS.submit) - .click() - .waitForRequestAndCheckIfNoErrors("@RemoveCollection"); - getCollection({ collectionId: collectionResp.id, auth: "auth" }) - .its("collection") - .should("be.null"); + createCollectionRequest(collectionName).then(collectionResp => { + collection = collectionResp; + + addChannelToCollection({ + collectionId: collection.id, + channelId: defaultChannel.id, }); - }, - ); + productsUtils + .createProductInChannel({ + name: productName, + channelId: defaultChannel.id, + productTypeId: productType.id, + attributeId: attribute.id, + categoryId: category.id, + visibleInListings: false, + }) + .then(({ product: productResp }) => { + productToAssign = productResp; - it( - "delete several collections on collections list page. TC: SALEOR_0309", - { tags: ["@collection", "@allEnv"] }, - () => { - const deleteSeveral = "delete-several-"; - const firstCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`; - const secondCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`; - let firstCollection; - let secondCollection; - - createCollectionRequest(firstCollectionName).then(collectionResp => { - firstCollection = collectionResp; - }); - - createCollectionRequest(secondCollectionName).then(collectionResp => { - secondCollection = collectionResp; - cy.visit(urlList.collections) - .searchInTable(deleteSeveral) - .get(collectionRow(firstCollection.id)) - .find(BUTTON_SELECTORS.checkbox) - .click() - .get(collectionRow(secondCollection.id)) - .find(BUTTON_SELECTORS.checkbox) - .click() - .get(BUTTON_SELECTORS.deleteIcon) - .click() - .addAliasToGraphRequest("CollectionBulkDelete") - .get(BUTTON_SELECTORS.submit) - .click() - .waitForRequestAndCheckIfNoErrors("@CollectionBulkDelete"); - - getCollection({ collectionId: firstCollection.id, auth: "auth" }) - .its("collection") - .should("be.null"); - getCollection({ collectionId: secondCollection.id, auth: "auth" }) - .its("collection") - .should("be.null"); - }); - }, - ); - - xit( - "should assign product to collection. TC: SALEOR_0307", - { tags: ["@collection", "@allEnv"] }, - () => { - const collectionName = `Assign-${startsWith}${faker.datatype.number()}`; - const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`; - - let collection; - let productToAssign; - - createCollectionRequest(collectionName).then(collectionResp => { - collection = collectionResp; - - productsUtils - .createProductInChannel({ - name: productName, - channelId: defaultChannel.id, - productTypeId: productType.id, - attributeId: attribute.id, - categoryId: category.id, - visibleInListings: false, - }) - .then(({ product: productResp }) => { - productToAssign = productResp; - - cy.visit(collectionDetailsUrl(collection.id)); - assignProductsToCollection(productToAssign.name); - - getCollection({ collectionId: collection.id, auth: "auth" }) - .its("collection.products.edges") - .should("have.length", 1) - .then(productArray => { - expect(productArray[0].node.id).to.equal(productToAssign.id); - }); + addProductToCollection({ + collectionId: collection.id, + productId: productToAssign.id, }); - }); - }, - ); - - it( - "remove product from collection. TC: SALEOR_0308", - { tags: ["@collection", "@allEnv"] }, - () => { - const collectionName = `Remove-With-Assigned-Product-${startsWith}${faker.datatype.number()}`; - const productName = `Product-To-Assign-${startsWith}${faker.datatype.number()}`; - let collection; - let productToAssign; - - createCollectionRequest(collectionName).then(collectionResp => { - collection = collectionResp; - - productsUtils - .createProductInChannel({ - name: productName, - channelId: defaultChannel.id, - productTypeId: productType.id, - attributeId: attribute.id, - categoryId: category.id, - visibleInListings: false, - }) - .then(({ product: productResp }) => { - productToAssign = productResp; - - addProductToCollection({ - collectionId: collection.id, - productId: productToAssign.id, - }); - - cy.visit(collectionDetailsUrl(collection.id)); - - getProductDetails(productToAssign.id, defaultChannel.slug, "auth") - .its("body.data.product.collections") - .should("have.length", 1); - - getCollection({ collectionId: collection.id, auth: "auth" }) - .its("collection.products.edges") - .should("have.length", 1); - - removeProductsFromCollection(productToAssign.name); - - getCollection({ collectionId: collection.id, auth: "auth" }) - .its("collection.products.edges") - .should("be.empty"); - }); - }); - }, - ); - - it( - "should update collection. TC: SALEOR_0306", - { tags: ["@collection", "@allEnv"] }, - () => { - const collectionName = `${startsWith}${faker.datatype.number()}`; - const updatedName = `${startsWith}updatedCollection`; - - createCollectionRequest(collectionName) - .then(collectionResp => { cy.visitAndWaitForProgressBarToDisappear( - collectionDetailsUrl(collectionResp.id), + collectionDetailsUrl(collection.id), ); - updateCollection({ name: updatedName, description: updatedName }); - getCollection({ collectionId: collectionResp.id, auth: "auth" }); - }) - .then(({ collection: collectionResp }) => { - expect(collectionResp.name).to.eq(updatedName); - const descriptionJson = JSON.parse(collectionResp.description); - const descriptionText = descriptionJson.blocks[0].data.text; - expect(descriptionText).to.eq(updatedName); + getProductDetails(productToAssign.id, defaultChannel.slug) + .its("body.data.product.collections") + .should("have.length", 1); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection.products.edges") + .should("have.length", 1); + removeProductsFromCollection(productToAssign.name); + getCollection({ + collectionId: collection.id, + channelSlug: defaultChannel.slug, + }) + .its("collection.products.edges") + .should("be.empty"); }); - }, - ); - }); + }); + }, + ); + + it( + "delete several collections on collections list page. TC: SALEOR_0309", + { tags: ["@collection", "@allEnv", "@stable"] }, + () => { + const deleteSeveral = "delete-several-"; + const firstCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`; + const secondCollectionName = `${deleteSeveral}${startsWith}${faker.datatype.number()}`; + let firstCollection; + let secondCollection; + + createCollectionRequest(firstCollectionName).then(collectionResp => { + firstCollection = collectionResp; + }); + createCollectionRequest(secondCollectionName).then(collectionResp => { + secondCollection = collectionResp; + + cy.visit(urlList.collections) + .searchInTable(deleteSeveral) + .get(collectionRow(firstCollection.id)) + .find(BUTTON_SELECTORS.checkbox) + .click() + .get(collectionRow(secondCollection.id)) + .find(BUTTON_SELECTORS.checkbox) + .click() + .get(BUTTON_SELECTORS.deleteIcon) + .click() + .addAliasToGraphRequest("CollectionBulkDelete") + .get(BUTTON_SELECTORS.submit) + .click() + .waitForRequestAndCheckIfNoErrors("@CollectionBulkDelete"); + getCollection({ collectionId: firstCollection.id }) + .its("collection") + .should("be.null"); + getCollection({ collectionId: secondCollection.id }) + .its("collection") + .should("be.null"); + }); + }, + ); }); diff --git a/cypress/support/api/requests/Collections.js b/cypress/support/api/requests/Collections.js index 95193e333..bf7ac23b7 100644 --- a/cypress/support/api/requests/Collections.js +++ b/cypress/support/api/requests/Collections.js @@ -61,6 +61,17 @@ export function addProductToCollection({ collectionId, productId }) { collectionId: "${collectionId}" products: ["${productId}"] ) { + collection{ + products(first:100){ + totalCount + edges{ + node{ + id + name + } + } + } + } errors { message } @@ -68,3 +79,26 @@ export function addProductToCollection({ collectionId, productId }) { }`; return cy.sendRequestWithQuery(mutation); } + +export function addChannelToCollection({ + collectionId, + channelId, + isPublished = true, +}) { + const mutation = `mutation collectionChannelListingUpdate { + collectionChannelListingUpdate( + id: "${collectionId}", + input: { + addChannels: { + channelId: "${channelId}" + isPublished: ${isPublished} + } + }) { + errors { + field + message + } + } + }`; + return cy.sendRequestWithQuery(mutation); +} diff --git a/cypress/support/api/requests/storeFront/Collections.js b/cypress/support/api/requests/storeFront/Collections.js index 8a14eeea9..7fd4245c4 100644 --- a/cypress/support/api/requests/storeFront/Collections.js +++ b/cypress/support/api/requests/storeFront/Collections.js @@ -1,16 +1,13 @@ -import { getValueWithDefault } from "../utils/Utils"; - -export function getCollection({ collectionId, channelSlug, auth = "token" }) { - const channelLine = getValueWithDefault( - channelSlug, - `channel: "${channelSlug}"` - ); +export function getCollection({ collectionId, channelSlug, auth }) { const query = `query Collection{ - collection(id: "${collectionId}" ${channelLine}) { + collection(id: "${collectionId}" channel: "${channelSlug}") { id slug name description + channelListings{ + isPublished + } products(first:100){ totalCount edges{ diff --git a/cypress/support/api/requests/storeFront/ProductDetails.js b/cypress/support/api/requests/storeFront/ProductDetails.js index 91f9c0bfc..f5b125191 100644 --- a/cypress/support/api/requests/storeFront/ProductDetails.js +++ b/cypress/support/api/requests/storeFront/ProductDetails.js @@ -3,7 +3,7 @@ import { getValueWithDefault } from "../utils/Utils"; export function getProductDetails(productId, channelSlug, auth = "token") { const privateMetadataLine = getValueWithDefault( auth === "auth", - `privateMetadata{key value}` + `privateMetadata{key value}`, ); const query = `fragment BasicProductFields on Product { @@ -80,14 +80,14 @@ export function getProductMetadata({ productId, channelSlug, auth, - withPrivateMetadata + withPrivateMetadata, }) { const privateMetadata = getValueWithDefault( withPrivateMetadata, `privateMetadata{ key value - }` + }`, ); const query = `query{ diff --git a/cypress/support/api/utils/storeFront/collectionsUtils.js b/cypress/support/api/utils/storeFront/collectionsUtils.js deleted file mode 100644 index 11265b470..000000000 --- a/cypress/support/api/utils/storeFront/collectionsUtils.js +++ /dev/null @@ -1,9 +0,0 @@ -export const isCollectionVisible = (collection, collectionId) => - collection !== null && collection.id === collectionId; - -export const isProductInCollectionVisible = (collection, productId) => { - const productsList = collection.products; - return ( - productsList.totalCount !== 0 && productsList.edges[0].node.id === productId - ); -}; diff --git a/cypress/support/pages/catalog/collectionsPage.js b/cypress/support/pages/catalog/collectionsPage.js index a8eb89c5b..a0efb05b5 100644 --- a/cypress/support/pages/catalog/collectionsPage.js +++ b/cypress/support/pages/catalog/collectionsPage.js @@ -50,7 +50,8 @@ export function updateCollection({ name, description }) { } export function assignProductsToCollection(productName) { - cy.get(COLLECTION_SELECTORS.addProductButton) + cy.waitForProgressBarToNotBeVisible() + .get(COLLECTION_SELECTORS.addProductButton) .click() .addAliasToGraphRequest("SearchProducts") .get(ASSIGN_ELEMENTS_SELECTORS.searchInput)