libreoffice-online/cypress_test/integration_tests/common/search_helper.js
Tamás Zolnai e63afd6431 cypress: extract some methods related to search bar.
Change-Id: I3ab9a37c4e34d2504f54c6e50cdadc4ee0433fd1
2020-10-19 18:29:53 +02:00

84 lines
1.8 KiB
JavaScript

/* global cy */
function showSearchBar() {
cy.get('#tb_editbar_item_showsearchbar')
.click();
cy.get('input#search-input')
.should('be.visible');
cy.get('#tb_editbar_item_bold')
.should('not.be.visible');
cy.get('#tb_searchbar_item_searchprev')
.should('have.class', 'disabled');
cy.get('#tb_searchbar_item_searchnext')
.should('have.class', 'disabled');
cy.get('#tb_searchbar_item_cancelsearch')
.should('not.be.visible');
}
function tpyeIntoSearchField(text) {
cy.get('input#search-input')
.clear()
.type(text);
cy.get('input#search-input')
.should('have.prop', 'value', text);
cy.get('#tb_searchbar_item_searchprev')
.should('not.have.class', 'disabled');
cy.get('#tb_searchbar_item_searchnext')
.should('not.have.class', 'disabled');
cy.get('#tb_searchbar_item_cancelsearch')
.should('be.visible');
}
function searchNext() {
cy.get('#tb_searchbar_item_searchnext')
.click();
}
function searchPrev() {
cy.get('#tb_searchbar_item_searchnext')
.click();
}
function cancelSearch() {
cy.get('#tb_searchbar_item_cancelsearch')
.click();
cy.get('input#search-input')
.should('have.prop', 'value', '');
cy.get('#tb_searchbar_item_searchprev')
.should('have.class', 'disabled');
cy.get('#tb_searchbar_item_searchnext')
.should('have.class', 'disabled');
cy.get('#tb_searchbar_item_cancelsearch')
.should('not.be.visible');
}
function closeSearchBar() {
cy.get('#tb_searchbar_item_hidesearchbar')
.click();
cy.get('input#search-input')
.should('not.be.visible');
cy.get('#tb_editbar_item_bold')
.should('be.visible');
}
module.exports.showSearchBar = showSearchBar;
module.exports.tpyeIntoSearchField = tpyeIntoSearchField;
module.exports.searchNext = searchNext;
module.exports.searchPrev = searchPrev;
module.exports.cancelSearch = cancelSearch;
module.exports.closeSearchBar = closeSearchBar;