Skip to content

Commit

Permalink
Update README + added emptyCart() (#121)
Browse files Browse the repository at this point in the history
* Update README.md

Update "If you only need the Hyvä tests" section.

* Add emptyCart() function to the cart page-object.

* Fix typo in the emptyCart() method.

* Add general spec to test logo and favicon.

* Update cart spec, 'Cart tests', empty cart before each test.

* Update luma cart spec - add selectors.
  • Loading branch information
knospe- authored Dec 22, 2023
1 parent ff795e6 commit e9841ce
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
/node_modules
/cypress/videos
/cypress/screenshots
Expand Down
2 changes: 2 additions & 0 deletions cypress/fixtures/luma/selectors/cart.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"product": {
"addToCartButton": "#product-addtocart-button",
"messageToast": "div.message-success",
"product1SuccessMessage": "You added Didi Sport Watch to your shopping cart.",
"productPrice": ".price"
},
"cartSummaryTable": ".totals .title",
"qtyInputField": ".input-text.qty",
"deleteProductButton": ".cart.item .action.action-delete",
"emptyCartText": "You have no items in your shopping cart.",
"emptyCartTextField": ".cart-empty",
"couponCode": "H20",
"couponDropdownSelector": "#block-discount > .title",
Expand Down
4 changes: 3 additions & 1 deletion cypress/fixtures/luma/selectors/homepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"successMessage": ".message-success",
"failedMessage": ".message-error",
"headerNavCategory": "div.lg\\:block > nav > div:nth-child(2) > span > a[title=\"Women\"]",
"headerNavSubCategory": ".navigation > ul > li:nth-child(2) > ul > li:nth-child(1) > a:nth-child(1)"
"headerNavSubCategory": ".navigation > ul > li:nth-child(2) > ul > li:nth-child(1) > a:nth-child(1)",
"logoImage": ".header.content .logo > img",
"favicon": "head link[rel=\"shortcut icon\"]"
}
6 changes: 4 additions & 2 deletions cypress/integration/luma/cart/cart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ describe('Isolated test for adding a product to the cart', () => {
cy.get(cartLuma.product.messageToast)
.should(
'include.text',
'You added Didi Sport Watch to your shopping cart.'
cartLuma.product.product1SuccessMessage
)
.should('be.visible');
});
});

describe('Cart tests', () => {
beforeEach(() => {
Cart.emptyCart();
cy.wait(3000);
Cart.addProductToCart(cartLuma.url.product1Url);
cy.visit(cartLuma.url.cartUrl);
cy.wait(3000);
Expand All @@ -29,7 +31,7 @@ describe('Cart tests', () => {
it('Can remove a product from the cart', () => {
cy.get(cartLuma.deleteProductButton).click();
cy.get(cartLuma.emptyCartTextField)
.should('include.text', 'You have no items in your shopping cart.')
.should('include.text', cartLuma.emptyCartText)
.should('be.visible');
});

Expand Down
17 changes: 17 additions & 0 deletions cypress/integration/luma/general.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import homepage from "../../fixtures/luma/homepage.json";
import selectors from "../../fixtures/luma/selectors/homepage";

describe(['cx'], 'General page tests', function () {
beforeEach(() => {
cy.visit(homepage.homePageUrl)
cy.wait(2000)
})

it('Check if the logo has title attribute set', function () {
cy.get(selectors.logoImage).invoke('attr', 'title').should('not.be.empty');
})

it('Check if the favicon exists', function () {
cy.get(selectors.favicon).should('exist');
})
})
2 changes: 1 addition & 1 deletion cypress/page-objects/luma/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Cart {
cy.visit(cart.url.cartUrl)
cy.wait(3000)

cy.log('Check of the cart is already empty.')
cy.log('Check if the cart is already empty.')

cy.get('body').then((body) => {
if (body.find(cart.emptyCartTextField).length === 0) {
Expand Down

0 comments on commit e9841ce

Please sign in to comment.