Fix failing cypress tests (#1671)

* fix tests

* fix prorders & images

* change base url

* remove comment
This commit is contained in:
Karolina Rakoczy 2021-12-17 12:07:51 +01:00 committed by GitHub
parent 6e9b12b04e
commit 5a14884f9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 43 additions and 34 deletions

View file

@ -76,7 +76,7 @@ filterTests({ definedTags: ["all"] }, () => {
.waitForProgressBarToNotExist()
.get(PRODUCTS_LIST.emptyProductRow)
.should("not.exist")
.get(PRODUCTS_LIST.productsList)
.get(PRODUCTS_LIST.productsNames)
.first()
.click()
.get(AVAILABLE_CHANNELS_FORM.menageChannelsButton)

View file

@ -91,14 +91,7 @@ filterTests({ definedTags: ["all"] }, () => {
.should("be.visible")
.waitForProgressBarToNotExist()
.addAliasToGraphRequest("ShippingZone")
.getTextFromElement(SHARED_ELEMENTS.table);
})
.then(tableText => {
if (!tableText.includes(shippingZone.name)) {
cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
}
cy.contains(shippingZone.name)
.click()
.findElementOnTable(shippingZone.name, "ShippingZones")
.waitForRequestAndCheckIfNoErrors("@ShippingZone");
enterHomePageChangeChannelAndReturn(defaultChannel.name);
cy.waitForProgressBarToNotBeVisible()

View file

@ -37,7 +37,7 @@ filterTests({ definedTags: ["all"], version: "3.1.1" }, () => {
cy.visit(urlList.translations)
.get(LANGUAGES_LIST.polishLanguageButton)
.click()
.findElementOnTable(category.name);
.findElementOnTable(category.name, "CategoryTranslations");
cy.get(ELEMENT_TRANSLATION.editNameButton)
.click()
.get(SHARED_ELEMENTS.skeleton)

View file

@ -96,6 +96,7 @@ filterTests({ definedTags: ["all"] }, () => {
let variantOnSale;
productData.name = productName;
productData.sku = productName;
createProductInChannel(productData)
.then(({ product, variantsList }) => {
variantNotOnSale = variantsList;
@ -103,7 +104,7 @@ filterTests({ definedTags: ["all"] }, () => {
productData.sku = name;
productData.productId = product.id;
productData.quantityInWarehouse = 10;
productData.attributeValues = ["value2"];
productData.attributeName = "value2";
createVariant(productData);
})
.then(variantsList => {
@ -141,6 +142,7 @@ filterTests({ definedTags: ["all"] }, () => {
let variants;
let saleToDelete;
productData.name = name;
productData.sku = name;
createProductInChannel(productData)
.then(({ variantsList }) => {
variants = variantsList;
@ -183,6 +185,7 @@ filterTests({ definedTags: ["all"] }, () => {
let product;
let variants;
productData.name = name;
productData.sku = name;
createProductInChannel(productData)
.then(({ variantsList, product: productResp }) => {
product = productResp;

View file

@ -18,6 +18,7 @@ import {
createCheckoutWithVoucher
} from "../../support/api/utils/ordersUtils";
import * as productsUtils from "../../support/api/utils/products/productsUtils";
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
import filterTests from "../../support/filterTests";
import {
createVoucher,
@ -41,6 +42,7 @@ filterTests({ definedTags: ["all"] }, () => {
cy.clearSessionData().loginUserViaRequest();
channelsUtils.deleteChannelsStartsWith(startsWith);
deleteVouchersStartsWith(startsWith);
deleteShippingStartsWith(startsWith);
const name = `${startsWith}${faker.datatype.number()}`;
productsUtils
.createProductWithShipping({ name, productPrice, shippingPrice })

View file

@ -116,8 +116,6 @@ filterTests({ definedTags: ["all"] }, () => {
});
it("should create order with selected channel", () => {
// Remove login as admin after fixing SALEOR-3154
cy.clearSessionData().loginUserViaRequest();
cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder)
.click();
@ -131,7 +129,6 @@ filterTests({ definedTags: ["all"] }, () => {
});
});
// This test will pass after fixing SALEOR-3154
it("should not be possible to change channel in order", () => {
createOrder({
customerId: customer.id,

View file

@ -22,7 +22,7 @@ import {
} from "../../support/pages/catalog/products/VariantsPage";
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
describe("Creating variants", () => {
describe("Creating variants in preorder", () => {
const startsWith = "CreatePreOrder";
const attributeValues = ["value1", "value2", "value3"];
const threshold = 100;

View file

@ -13,8 +13,8 @@ import filterTests from "../../support/filterTests";
import { saveVariant } from "../../support/pages/catalog/products/VariantsPage";
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
describe("Creating variants", () => {
const startsWith = "CreatePreOrder";
describe("Stocks and threshold in preorder variants", () => {
const startsWith = "StocksThreshold";
const attributeValues = ["value1", "value2"];
const preorder = {
globalThreshold: 15

View file

@ -7,7 +7,7 @@ import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { demoProductsNames } from "../../fixtures/products";
import { productDetailsUrl, urlList } from "../../fixtures/urlList";
import { getFirstProducts } from "../../support/api/requests/Product";
import { loginDeleteProductsAndCreateNewOneWithNewDataAndDefaultChannel } from "../../support/api/utils/products/productsUtils";
import { deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel } from "../../support/api/utils/products/productsUtils";
import filterTests from "../../support/filterTests";
filterTests({ definedTags: ["all"] }, () => {
@ -26,7 +26,8 @@ filterTests({ definedTags: ["all"] }, () => {
element.data.hasOwnProperty("products")
).data;
const products = data.products.edges;
cy.get(PRODUCTS_LIST.productImage)
cy.get(PRODUCTS_LIST.productsList)
.find(PRODUCTS_LIST.productImage)
.each($image => {
cy.wrap($image)
.invoke("attr", "src")
@ -68,9 +69,10 @@ filterTests({ definedTags: ["all"] }, () => {
const name = "CyImages";
cy.clearSessionData().loginUserViaRequest();
loginDeleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ name })
.then(product => {
deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ name })
.then(({ product }) => {
cy.visit(productDetailsUrl(product.id))
.waitForProgressBarToNotBeVisible()
.get(PRODUCT_DETAILS.uploadImageButton)
.click()
.get(PRODUCT_DETAILS.uploadSavedImagesButton)

View file

@ -18,18 +18,20 @@ export function createCollection(name, slug = name) {
.sendRequestWithQuery(mutation)
.its("body.data.collectionCreate.collection");
}
export function getCollections(search) {
export function getCollections(first, search) {
const filter = search
? `, filter:{
search:""
}`
: "";
const query = `query{
collections(first:100 ${filter}){
collections(first:${first} ${filter}){
edges{
node{
id
name
slug
}
}
}

View file

@ -155,7 +155,6 @@ export function createVariant({
costPrice = 1,
trackInventory = true,
weight = 1,
attributeValues = ["value"],
attributeName = "value",
preorder
}) {
@ -205,7 +204,7 @@ export function createVariant({
id
name
}
bulkProductErrors{
errors{
field
message
}

View file

@ -1,5 +1,10 @@
import { deleteCollection, getCollections } from "../../requests/Collections";
export function deleteCollectionsStartsWith(startsWith) {
cy.deleteElementsStartsWith(deleteCollection, getCollections, startsWith);
cy.deleteElementsStartsWith(
deleteCollection,
getCollections,
startsWith,
"slug"
);
}

View file

@ -1,14 +1,17 @@
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
Cypress.Commands.add("findElementOnTable", elementName => {
Cypress.Commands.add("findElementOnTable", (elementName, alias) => {
cy.getTextFromElement(SHARED_ELEMENTS.table).then(tableText => {
if (tableText.includes(elementName)) {
cy.contains(SHARED_ELEMENTS.tableRow, elementName).click({ force: true });
} else {
cy.get(BUTTON_SELECTORS.nextPaginationButton)
.click()
.findElementOnTable(elementName);
cy.addAliasToGraphRequest(alias);
cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
if (alias) {
cy.wait(`@${alias}`);
}
cy.findElementOnTable(elementName, alias);
}
});
});

View file

@ -114,9 +114,10 @@ export function fillUpVariantAttributeAndSku({ attributeName, sku }) {
.click()
.get(VARIANTS_SELECTORS.attributeOption)
.contains(attributeName)
.click()
.get(VARIANTS_SELECTORS.skuInputInAddVariant)
.type(sku);
.click();
if (sku) {
cy.get(VARIANTS_SELECTORS.skuInputInAddVariant).type(sku);
}
}
export function selectChannelForVariantAndFillUpPrices({
@ -125,7 +126,9 @@ export function selectChannelForVariantAndFillUpPrices({
price,
costPrice = price
}) {
cy.addAliasToGraphRequest("ProductChannelListingUpdate");
cy.waitForProgressBarToNotBeVisible().addAliasToGraphRequest(
"ProductChannelListingUpdate"
);
selectChannelVariantInDetailsPage(channelName, attributeName);
cy.get(BUTTON_SELECTORS.confirm)
.click()