redoc/e2e/integration/search.e2e.ts

55 lines
1.6 KiB
TypeScript
Raw Normal View History

describe('Search', () => {
2018-03-19 17:34:37 +03:00
const getSearchInput = () => cy.get('[role="search"] input');
const getSearchResults = () => cy.get('[data-role="search:results"]');
const getResult = i => cy.get('[role=search] [role=menuitem]').eq(i);
beforeEach(() => {
cy.visit('e2e/standalone.html');
});
it('should correctly show and hide search results box', () => {
2018-03-19 17:34:37 +03:00
getSearchResults().should('not.exist');
2018-03-19 17:34:37 +03:00
// should not open for less than 3 symbols
getSearchInput().type('in');
2018-03-19 17:34:37 +03:00
getSearchResults().should('not.exist');
getSearchInput().type('t');
cy.get('[role=search] [role=menuitem]')
.should('have.length', 3)
.first()
.should('contain', 'Introduction');
2018-03-19 17:34:37 +03:00
getSearchInput().type('{esc}');
2018-03-19 17:34:37 +03:00
getSearchResults().should('not.exist');
});
it('should support arrow navigation', () => {
getSearchInput().type('int');
2018-03-19 17:34:37 +03:00
getSearchInput().type('{downarrow}');
2018-03-19 17:34:37 +03:00
getResult(0).should('have.class', 'active');
getSearchInput().type('{downarrow}');
2018-03-19 17:34:37 +03:00
getResult(1).should('have.class', 'active');
getResult(0).should('not.have.class', 'active');
getSearchInput().type('{uparrow}');
2018-03-19 17:34:37 +03:00
getResult(1).should('not.have.class', 'active');
getResult(0).should('have.class', 'active');
getSearchInput().type('{uparrow}');
2018-03-19 17:34:37 +03:00
getResult(0).should('have.class', 'active');
getSearchInput().type('{enter}');
2018-03-19 17:34:37 +03:00
cy.contains('[role=navigation] [role=menuitem]', 'Introduction').should('have.class', 'active');
});
it('should mark search results', () => {
2018-03-19 17:34:37 +03:00
cy.get('[data-markjs]').should('not.exist');
getSearchInput().type('int');
2018-03-19 17:34:37 +03:00
cy.get('[data-markjs]').should('exist');
});
});