You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Defined in cart.spec.js test 'displays the correct product prices and totals' the totals calculations seem off, or likely don;t cater for USA locale price display format of x,xxx.xx
The tests as is always fail not being able to compare price values/totals are correct, and it seems it only uses the thousands as a single int. In example below '2' from a total of 2,254.97 is definitely not equal to 48 (2 + 46) of the line items totals
Describe the solution you'd like
I have created an alternative test block, that properly works out the totals, as is, not just the first digits of the toatls, as what seems to be happening.
I did not do a MR, as I am unsure if these will work for other locales, and shouls likely just be in some form of docs for others to be able to use, and tweak to their needs. No need for others to work this out as well. Also, i am not a JS expert, so my code could likely be refined.
it.only('displays the correct product prices and totals', () => {
cy.visit(cart.url.product1Url)
//check if product price matches with price in cart
cy.get(cart.product.productPrice).then(($productPrice) => {
const productPrice = Number($productPrice[0].textContent.replace(/[^0-9\.-]+/g, ""))
Cart.addProductToCart(cart.url.product2Url)
cy.visit(cart.url.cartUrl)
cy.wait(3000)
cy.get(cart.product1Price).then((itemPrice) => {
let cartItemPrice = Number(itemPrice.text().replace(/[^0-9\.-]+/g, ""));
cy.log(cartItemPrice)
expect(productPrice).to.eq(cartItemPrice)
})
//change the qty value
cy.get(cart.qtyInputField).eq(0).type('{backspace}2{enter}').then(($qty) => {
const qty = parseInt($qty.val())
cy.wait(3000)
//check if qty * product subtotal displays the correct amount
cy.get(cart.product1Subtotal).then(($subTotal) => {
const subTotal = Number($subTotal[0].textContent.replace(/[^0-9\.-]+/g, ""))
expect(productPrice * qty).to.equal(subTotal)
})
})
})
//check if the grand total is correct
cy.get(cart.product1Subtotal).then(($total1) => {
const subTotal1 = Number($total1[0].textContent.replace(/[^0-9\.-]+/g, "")).toFixed(2)
cy.log(subTotal1)
cy.get(cart.product2Subtotal).then(($total2) => {
const subTotal2 = Number($total2[0].textContent.replace(/[^0-9\.-]+/g, "")).toFixed(2)
cy.log(subTotal2)
const calcTotal = Number(subTotal1) + Number(subTotal2)
cy.log(calcTotal)
cy.get(cart.grandTotal).then(($grandTotal) => {
const grandTotal = Number($grandTotal[0].textContent.replace(/[^0-9\.-]+/g, "")).toFixed(2)
cy.log(grandTotal)
expect(grandTotal).to.equal(calcTotal.toFixed(2))
})
})
})
})
Describe alternatives you've considered
See above
Additional context
None, see above
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Defined in cart.spec.js test 'displays the correct product prices and totals' the totals calculations seem off, or likely don;t cater for USA locale price display format of x,xxx.xx
The tests as is always fail not being able to compare price values/totals are correct, and it seems it only uses the thousands as a single int. In example below '2' from a total of 2,254.97 is definitely not equal to 48 (2 + 46) of the line items totals
Describe the solution you'd like
I have created an alternative test block, that properly works out the totals, as is, not just the first digits of the toatls, as what seems to be happening.
I did not do a MR, as I am unsure if these will work for other locales, and shouls likely just be in some form of docs for others to be able to use, and tweak to their needs. No need for others to work this out as well. Also, i am not a JS expert, so my code could likely be refined.
Describe alternatives you've considered
See above
Additional context
None, see above
The text was updated successfully, but these errors were encountered: