-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from MixDrinks/cypress/add-accessibility-ids
Added new attributes and page objects
- Loading branch information
Showing
15 changed files
with
422 additions
and
122 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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
const defaultSizes = ['iphone-6', 'ipad-2', 'macbook-13']; | ||
|
||
function forEverySize(options) { | ||
let tests; | ||
let sizes; | ||
if (typeof options === 'function') { | ||
tests = options; | ||
sizes = defaultSizes; | ||
} else { | ||
({ sizes = defaultSizes, tests } = options); | ||
} | ||
sizes.forEach((size) => { | ||
context(`for ${size} screen size`, () => { | ||
beforeEach(() => { | ||
cy.viewport(size); | ||
}); | ||
tests({ viewport: size }); | ||
}); | ||
}); | ||
} | ||
|
||
export default forEverySize; |
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,11 @@ | ||
export default { | ||
name: 'cocktail', | ||
vertical: { | ||
selector: { | ||
title: '.cocktail-header-title', | ||
recipeItem: '[data-cy="recipe_step"]', | ||
component: '[data-cy="goods"]', | ||
tools: '[data-cy="tools"]' | ||
} | ||
} | ||
} |
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,19 @@ | ||
|
||
export default { | ||
name: 'home', | ||
vertical: { | ||
selector: { | ||
sorting: { | ||
popular: '[data-cy="sorting 1"]', | ||
byRate: '[data-cy="sorting 2"]', | ||
}, | ||
filters: { | ||
lowalcohol: '[title="слабоалкогольні"]', | ||
lowalcoholTag: '[data-cy="filterTag 1"]' | ||
}, | ||
cocktailCard: '[data-cy="cocktailCard"]', | ||
search: '.search', | ||
searchSuggestions: '.search-result-list-item' | ||
} | ||
} | ||
} |
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
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,60 @@ | ||
import { default as homePage } from '../support/page_objects/homePage'; | ||
import { default as cocktailPage } from '../support/page_objects/cocktailPage'; | ||
import forEverySize from '../helpers/for-every-size' | ||
|
||
describe("Home screen elements on the different screen resolutions", () => { | ||
forEverySize(({ viewport }) => { | ||
|
||
beforeEach("Open home screen", () => { | ||
cy.viewport(viewport); | ||
cy.visit("/"); | ||
}); | ||
|
||
it("can view the cocktails list and open the detailed cocktail screen", () => { | ||
cy.intercept({ | ||
method: "GET", | ||
url: "/v2/cocktails/full*", | ||
}).as("cocktail"); | ||
cy.request({ | ||
method: 'GET', | ||
url: 'https://whale-app-iz3av.ondigitalocean.app/v2/search/cocktails?page=0', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then((cocktailsList) => { | ||
const cocktails = cocktailsList.body.cocktails | ||
cy.get(homePage.vertical.selector.sorting.byRate).should("be.visible") | ||
cy.get(homePage.vertical.selector.search).should("be.visible") | ||
cy.get(homePage.vertical.selector.cocktailCard).each(item => { | ||
const itemText = item.text().trim() | ||
expect(itemText).to.contain(cocktails[item.index()].name) | ||
}) | ||
cy.get(homePage.vertical.selector.cocktailCard).eq(5).click() | ||
|
||
cy.wait('@cocktail').then( cocktail => { | ||
const details = cocktail.response.body; | ||
const receipt = details.receipt | ||
const goods = details.goods | ||
const tools = details.tools | ||
|
||
cy.get(cocktailPage.vertical.selector.title).should('contain', details.name) | ||
cy.get(cocktailPage.vertical.selector.recipeItem).each(listItem => { | ||
const itemText = listItem.text() | ||
expect(itemText).to.equal(receipt[listItem.index()]) | ||
}) | ||
cy.get(cocktailPage.vertical.selector.component).find('[data-cy="ingredient"]').each(listItem => { | ||
const itemText = listItem.text() | ||
expect(itemText).contains(goods[listItem.index()].name) | ||
}) | ||
cy.get(cocktailPage.vertical.selector.tools).find('[data-cy="ingredient"]').each(listItem => { | ||
const itemText = listItem.text() | ||
expect(itemText).contains(tools[listItem.index()].name) | ||
}) | ||
}) | ||
|
||
}) | ||
}); | ||
}) | ||
}) | ||
|
||
|
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,55 @@ | ||
import { default as homePage } from '../support/page_objects/homePage'; | ||
|
||
describe("Home screen tests", () => { | ||
const interceptSorting = ( sortingParam ) => { | ||
cy.intercept({ | ||
method: "GET", | ||
url: `/v2/search/cocktails?page=0&${sortingParam}`, | ||
}).as("sortingApplied"); | ||
} | ||
beforeEach("Open home screen", () => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("items should be reordered after sorting applying", () => { | ||
interceptSorting("sort=biggest-rate") | ||
|
||
cy.get(homePage.vertical.selector.sorting.byRate).click(); | ||
cy.get(homePage.vertical.selector.sorting.byRate).click(); | ||
cy.get(homePage.vertical.selector.sorting.byRate).click(); | ||
cy.wait("@sortingApplied").its('response.body').then((body) => { | ||
const cocktails = body.cocktails | ||
cy.get(homePage.vertical.selector.cocktailCard).each(item => { | ||
const itemText = item.text().trim() | ||
expect(itemText).to.contain(cocktails[item.index()].name) | ||
}) | ||
}) | ||
|
||
}); | ||
|
||
it("items should be filteres after applying a low alcohol filter", () => { | ||
interceptSorting("alcohol-volume=1") | ||
|
||
let firstItemName | ||
cy.get(homePage.vertical.selector.cocktailCard).find(".cart__name").first().invoke('text').then((itemTitle) => { | ||
firstItemName = itemTitle | ||
}) | ||
|
||
// applying the low alcohol filter | ||
cy.get(homePage.vertical.selector.filters.lowalcohol).click() | ||
// checking that proper tag is shown | ||
cy.get(homePage.vertical.selector.filters.lowalcoholTag).should('be.visible') | ||
// applying the low alcohol filter again because when it clicked programatically the request is not sent | ||
cy.get(homePage.vertical.selector.filters.lowalcohol).click() | ||
|
||
cy.wait("@sortingApplied").its('response.body').then( (body) => { | ||
const cocktails = body.cocktails | ||
cy.get(homePage.vertical.selector.cocktailCard).each(item => { | ||
const itemText = item.text().trim() | ||
expect(itemText).to.contain(cocktails[item.index()].name) | ||
}) | ||
// checking that the first element name is changed after applying filters | ||
cy.get(homePage.vertical.selector.cocktailCard).find(".cart__name").first().should('not.contain', firstItemName) | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.