-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
home page e2e update - cypress (#4488)
- Loading branch information
1 parent
a2549a0
commit e70720c
Showing
3 changed files
with
16 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
update old versions and new home page e2e test - cypress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,170 +1,30 @@ | ||
/// <reference types="cypress"/> | ||
/// <reference types="../../support"/> | ||
|
||
import faker from "faker"; | ||
|
||
import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors"; | ||
import { urlList } from "../../fixtures/urlList"; | ||
import { createCustomer } from "../../support/api/requests/Customer"; | ||
import * as homePageUtils from "../../support/api/utils/homePageUtils"; | ||
import { | ||
createReadyToFulfillOrder, | ||
createWaitingForCaptureOrder, | ||
} from "../../support/api/utils/ordersUtils"; | ||
import * as productsUtils from "../../support/api/utils/products/productsUtils"; | ||
import { | ||
changeChannel, | ||
getOrdersReadyForCaptureRegex, | ||
getOrdersReadyToFulfillRegex, | ||
getProductsOutOfStockRegex, | ||
getSalesAmountRegex, | ||
getTodaysOrdersRegex, | ||
} from "../../support/pages/homePage"; | ||
|
||
describe("As an admin I want to see correct information on dashboard home page", () => { | ||
const startsWith = "CyHomeAnalytics"; | ||
const productPrice = 22; | ||
const shippingPrice = 12; | ||
const randomName = startsWith + faker.datatype.number(); | ||
const randomEmail = `${startsWith}${randomName}@example.com`; | ||
|
||
let customer; | ||
let defaultChannel; | ||
let createdVariants; | ||
let productType; | ||
let attribute; | ||
let category; | ||
let warehouse; | ||
let shippingMethod; | ||
let address; | ||
let ordersReadyToFulfillRegexp; | ||
let ordersReadyForCaptureRegexp; | ||
let productsOutOfStockRegexp; | ||
let salesAmountRegexp; | ||
let ordersRegexp; | ||
|
||
before(() => { | ||
cy.loginUserViaRequest(); | ||
productsUtils | ||
.createProductWithShipping({ | ||
name: randomName, | ||
productPrice, | ||
shippingPrice, | ||
newChannel: true, | ||
}) | ||
.then(resp => { | ||
createdVariants = resp.variantsList; | ||
address = resp.address; | ||
warehouse = resp.warehouse; | ||
defaultChannel = resp.defaultChannel; | ||
shippingMethod = resp.shippingMethod; | ||
attribute = resp.attribute; | ||
category = resp.category; | ||
productType = resp.productType; | ||
|
||
createCustomer(randomEmail, randomName, address).then( | ||
customerResp => (customer = customerResp), | ||
); | ||
|
||
homePageUtils | ||
.getOrdersReadyToFulfill(defaultChannel.slug) | ||
.then(ordersReadyToFulfillBefore => { | ||
ordersReadyToFulfillRegexp = getOrdersReadyToFulfillRegex( | ||
ordersReadyToFulfillBefore, | ||
1, | ||
); | ||
}); | ||
|
||
homePageUtils | ||
.getOrdersReadyForCapture(defaultChannel.slug) | ||
.then(ordersReadyForCaptureBefore => { | ||
ordersReadyForCaptureRegexp = getOrdersReadyForCaptureRegex( | ||
ordersReadyForCaptureBefore, | ||
1, | ||
); | ||
}); | ||
|
||
homePageUtils | ||
.getProductsOutOfStock(defaultChannel.slug) | ||
.then(productsOutOfStockBefore => { | ||
productsOutOfStockRegexp = getProductsOutOfStockRegex( | ||
productsOutOfStockBefore, | ||
1, | ||
); | ||
}); | ||
|
||
homePageUtils.getSalesAmount(defaultChannel.slug).then(salesAmount => { | ||
salesAmountRegexp = getSalesAmountRegex( | ||
salesAmount, | ||
(productPrice + shippingPrice) * 2, | ||
); | ||
}); | ||
|
||
homePageUtils | ||
.getTodaysOrders(defaultChannel.slug) | ||
.then(ordersBefore => { | ||
ordersRegexp = getTodaysOrdersRegex(ordersBefore, 2); | ||
}); | ||
}) | ||
.then(() => { | ||
createReadyToFulfillOrder({ | ||
customerId: customer.id, | ||
shippingMethod, | ||
channelId: defaultChannel.id, | ||
variantsList: createdVariants, | ||
address, | ||
}); | ||
|
||
createWaitingForCaptureOrder({ | ||
channelSlug: defaultChannel.slug, | ||
email: randomEmail, | ||
variantsList: createdVariants, | ||
shippingMethodName: shippingMethod.name, | ||
address, | ||
}); | ||
|
||
const productOutOfStockRandomName = | ||
startsWith + faker.datatype.number(); | ||
|
||
productsUtils.createProductInChannel({ | ||
name: productOutOfStockRandomName, | ||
channelId: defaultChannel.id, | ||
warehouseId: warehouse.id, | ||
quantityInWarehouse: 0, | ||
productTypeId: productType.id, | ||
attributeId: attribute.id, | ||
categoryId: category.id, | ||
price: productPrice, | ||
}); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.loginUserViaRequest(); | ||
}); | ||
|
||
it( | ||
"should display correct information on dashboard home page. SALEOR_2004 - migration in progress - to delete when done", | ||
{ tags: ["@homePage", "@allEnv", "@critical"] }, | ||
() => { | ||
cy.visit(urlList.homePage); | ||
changeChannel(defaultChannel.name); | ||
cy.contains(HOMEPAGE_SELECTORS.orders, ordersRegexp).should("be.visible"); | ||
cy.contains( | ||
HOMEPAGE_SELECTORS.ordersReadyToFulfill, | ||
ordersReadyToFulfillRegexp, | ||
).should("be.visible"); | ||
cy.contains( | ||
HOMEPAGE_SELECTORS.paymentsWaitingForCapture, | ||
ordersReadyForCaptureRegexp, | ||
).should("be.visible"); | ||
cy.contains(HOMEPAGE_SELECTORS.sales, salesAmountRegexp).should( | ||
"be.visible", | ||
); | ||
cy.contains( | ||
HOMEPAGE_SELECTORS.productsOutOfStock, | ||
productsOutOfStockRegexp, | ||
).should("be.visible"); | ||
cy.get(HOMEPAGE_SELECTORS.activity).should("be.visible"); | ||
cy.get(HOMEPAGE_SELECTORS.activity) | ||
.find("ul") | ||
.find("li") | ||
.should("have.length.above", 1); | ||
cy.get(HOMEPAGE_SELECTORS.sales).should("be.visible"); | ||
cy.get(HOMEPAGE_SELECTORS.productsOutOfStock).should("be.visible"); | ||
|
||
cy.get(HOMEPAGE_SELECTORS.topProducts).should("be.visible"); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters