2020-10-19 10:25:08 -05:00
|
|
|
/* global cy */
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Search bar related helper methods for mobile.
|
|
|
|
|
|
|
|
// Make the searchbar visible on the bottom toolbar.
|
2020-10-19 10:25:08 -05:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Type some text into the search field, which will
|
|
|
|
// trigger searching automatically.
|
|
|
|
// Parameters:
|
|
|
|
// text - the text to type in
|
2020-10-19 10:25:08 -05:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Move to the next search result in the document.
|
2020-10-19 10:25:08 -05:00
|
|
|
function searchNext() {
|
|
|
|
cy.get('#tb_searchbar_item_searchnext')
|
|
|
|
.click();
|
|
|
|
}
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Move to the previous search result in the document.
|
2020-10-19 10:25:08 -05:00
|
|
|
function searchPrev() {
|
|
|
|
cy.get('#tb_searchbar_item_searchnext')
|
|
|
|
.click();
|
|
|
|
}
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Cancel search with the specified text.
|
|
|
|
// This will remove the search string from the input field.
|
2020-10-19 10:25:08 -05:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2021-02-26 06:11:39 -06:00
|
|
|
// Hide the searchbar from the bottom toolbar.
|
2020-10-19 10:25:08 -05:00
|
|
|
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;
|