-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathproduct-searches.spec.js
52 lines (47 loc) · 1.89 KB
/
product-searches.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Search } from '../../../page-objects/hyva/search';
import search from '../../../fixtures/hyva/search.json';
import globalSelectors from '../../../fixtures/globalSelectors.json'
import selectors from '../../../fixtures/hyva/selectors/search.json';
import homepageSelectors from '../../../fixtures/hyva/selectors/homepage.json';
describe('Perform searches', () => {
beforeEach(() => {
cy.visit('/');
});
it('Can perform search with multiple hits', () => {
Search.search(search.productCategory);
cy.get(homepageSelectors.mainHeading).should(
'contain.text',
`Search results for: '${search.productCategory}'`
);
cy.get(selectors.searchResults).should('have.length.gte', 8)
});
it('Can find a single product', () => {
Search.search(search.singleProduct);
cy.get(homepageSelectors.mainHeading).should(
'contain.text',
`Search results for: '${search.singleProduct}'`
);
cy.get(selectors.searchResults).should('have.lengthOf', 1)
});
it('Can perform search with no search results', () => {
Search.search(search.noResults);
cy.get(homepageSelectors.mainHeading)
.should('be.visible')
.should(
'contain.text',
`Search results for: '${search.noResults}'`
);
cy.get(selectors.noResultsMessage)
.should('be.visible')
.should('contain.text', 'Your search returned no results.');
});
it('Can see suggestions when entering search terms', () => {
cy.get(selectors.headerSearchIcon).click();
cy.get(selectors.headerSearchField)
.should('be.visible')
.type(`${search.getHint}`);
cy.get(selectors.searchSuggestions)
.should('be.visible')
.should('contain.text', search.hintResult);
});
});