libreoffice-online/cypress_test/integration_tests/mobile/calc/searchbar_spec.js
Tamás Zolnai 2aa37cbaf4 cypress: do not run afterAll method in case of failure.
After a test failure, it's common, that the afterAll
method also fails which covers the right error
message and also makes the following tests to be ignored.

Change-Id: I5c1bbc5dd8b1b48dd2a8f1fc20a8ca3b8ecd8462
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-11-13 11:57:23 +01:00

138 lines
3.2 KiB
JavaScript

/* global describe it cy beforeEach require afterEach*/
var helper = require('../../common/helper');
var searchHelper = require('../../common/search_helper');
var mobileHelper = require('../../common/mobile_helper');
describe('Searching via search bar.', function() {
var testFileName = 'search_bar.ods';
beforeEach(function() {
helper.beforeAll(testFileName, 'calc');
mobileHelper.enableEditingMobile();
searchHelper.showSearchBar();
});
afterEach(function() {
helper.afterAll(testFileName, this.currentTest.state);
});
it('Search existing word.', function() {
searchHelper.tpyeIntoSearchField('a');
searchHelper.searchNext();
// First cell should be selected
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
});
it('Search not existing word.', function() {
cy.get('input#addressInput')
.should('have.prop', 'value', 'A2');
searchHelper.tpyeIntoSearchField('q');
// Should be no new selection
cy.get('input#addressInput')
.should('have.prop', 'value', 'A2');
});
it('Search next / prev instance.', function() {
searchHelper.tpyeIntoSearchField('a');
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Search next instance
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'B1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Search prev instance
searchHelper.searchPrev();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
});
it('Search at the document end.', function() {
searchHelper.tpyeIntoSearchField('a');
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Search next instance
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'B1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Search next instance, which is in the beginning of the document.
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
});
it('Cancel search.', function() {
searchHelper.tpyeIntoSearchField('a');
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Cancel search -> selection removed
searchHelper.cancelSearch();
cy.get('input#search-input')
.should('be.visible');
});
it('Close search.', function() {
searchHelper.tpyeIntoSearchField('a');
searchHelper.searchNext();
cy.get('input#addressInput')
.should('have.prop', 'value', 'A1');
cy.get('#copy-paste-container table td')
.should('have.text', 'a');
// Close search -> search bar is closed
searchHelper.closeSearchBar();
});
});