cypress: extract typeIntoInputField() method.
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com> Change-Id: I8dc89dc6abad9106ffae42fc52723e503ddc0cca
This commit is contained in:
parent
45300cc51b
commit
87c6c7d81d
9 changed files with 56 additions and 128 deletions
|
@ -1088,6 +1088,37 @@ function overlayItemHasDifferentBoundsThan(itemDivId, bounds) {
|
|||
});
|
||||
}
|
||||
|
||||
// Type some text into an input DOM item.
|
||||
// Parameters:
|
||||
// selector - selector to find the correct input item in the DOM.
|
||||
// text - string to type in (can contain cypress command strings).
|
||||
// clearBefore - whether clear the existing content or not.
|
||||
// prop - whether the value is set as property or attribute (depends on implementation).
|
||||
function typeIntoInputField(selector, text, clearBefore = true, prop = true)
|
||||
{
|
||||
cy.log('Typing into input field - start.');
|
||||
|
||||
if (clearBefore) {
|
||||
cy.get(selector)
|
||||
.focus()
|
||||
.clear()
|
||||
.type(text + '{enter}');
|
||||
} else {
|
||||
cy.get(selector)
|
||||
.type(text + '{enter}');
|
||||
}
|
||||
|
||||
if (prop) {
|
||||
cy.get(selector)
|
||||
.should('have.prop', 'value', text);
|
||||
} else {
|
||||
cy.get(selector)
|
||||
.should('have.attr', 'value', text);
|
||||
}
|
||||
|
||||
cy.log('Typing into input field - end.');
|
||||
}
|
||||
|
||||
module.exports.loadTestDoc = loadTestDoc;
|
||||
module.exports.assertCursorAndFocus = assertCursorAndFocus;
|
||||
module.exports.assertNoKeyboardInput = assertNoKeyboardInput;
|
||||
|
@ -1125,3 +1156,4 @@ module.exports.Bounds = Bounds;
|
|||
module.exports.getOverlayItemBounds = getOverlayItemBounds;
|
||||
module.exports.overlayItemHasBounds = overlayItemHasBounds;
|
||||
module.exports.overlayItemHasDifferentBoundsThan = overlayItemHasDifferentBoundsThan;
|
||||
module.exports.typeIntoInputField = typeIntoInputField;
|
||||
|
|
|
@ -40,16 +40,12 @@ describe('Statubar tests.', function() {
|
|||
cy.get('#RowColSelCount')
|
||||
.should('have.text', '\u00a0Select multiple cells\u00a0');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1:A2{enter}');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1:A2');
|
||||
|
||||
cy.get('#RowColSelCount')
|
||||
.should('have.text', 'Selected: 2 rows, 1 column');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1{enter}');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1');
|
||||
|
||||
cy.get('#RowColSelCount')
|
||||
.should('have.text', '\u00a0Select multiple cells\u00a0');
|
||||
|
@ -74,16 +70,12 @@ describe('Statubar tests.', function() {
|
|||
cy.get('#StateTableCell')
|
||||
.should('have.text', 'Average: ; Sum: 0');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1:A2{enter}');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1:A2');
|
||||
|
||||
cy.get('#StateTableCell')
|
||||
.should('have.text', 'Average: 15.5; Sum: 31');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1{enter}');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1');
|
||||
|
||||
cy.get('#StateTableCell')
|
||||
.should('have.text', 'Average: 10; Sum: 10');
|
||||
|
|
|
@ -22,22 +22,12 @@ describe('Formula bar tests.', function() {
|
|||
calcHelper.clickOnFirstCell();
|
||||
|
||||
// Select a different cell using address input.
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('B2{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'B2');
|
||||
helper.typeIntoInputField('input#addressInput', 'B2');
|
||||
|
||||
cy.get('.spreadsheet-cell-resize-marker[style=\'visibility: visible; transform: translate3d(-8px, -8px, 0px); z-index: -8;\']')
|
||||
.should('not.exist');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'A1');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1');
|
||||
|
||||
cy.get('.spreadsheet-cell-resize-marker[style=\'visibility: visible; transform: translate3d(-8px, -8px, 0px); z-index: -8;\']')
|
||||
.should('exist');
|
||||
|
@ -48,12 +38,7 @@ describe('Formula bar tests.', function() {
|
|||
calcHelper.clickOnFirstCell();
|
||||
|
||||
// Select a cell range using address input.
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('B2:B3{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'B2:B3');
|
||||
helper.typeIntoInputField('input#addressInput', 'B2:B3');
|
||||
|
||||
cy.get('.spreadsheet-cell-resize-marker[style=\'visibility: visible; transform: translate3d(-8px, -8px, 0px); z-index: -8;\']')
|
||||
.should('not.exist');
|
||||
|
@ -65,12 +50,7 @@ describe('Formula bar tests.', function() {
|
|||
.should('exist');
|
||||
|
||||
// Select a cell range again using address input.
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('B2:B3{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'B2:B3');
|
||||
helper.typeIntoInputField('input#addressInput', 'B2:B3');
|
||||
|
||||
cy.get('.spreadsheet-cell-resize-marker[style=\'visibility: visible; transform: translate3d(-8px, -8px, 0px); z-index: -8;\']')
|
||||
.should('not.exist');
|
||||
|
@ -84,9 +64,7 @@ describe('Formula bar tests.', function() {
|
|||
helper.expectTextForClipboard('long line long line long line');
|
||||
|
||||
// A2 cell is empty
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A2{enter}');
|
||||
helper.typeIntoInputField('input#addressInput', 'A2');
|
||||
|
||||
cy.get('.spreadsheet-cell-autofill-marker')
|
||||
.should('be.visible');
|
||||
|
|
|
@ -326,12 +326,7 @@ describe('Apply number formatting.', function() {
|
|||
.should('have.attr', 'value', '0');
|
||||
|
||||
// Type in a new value
|
||||
cy.get('#decimalplaces input')
|
||||
.clear()
|
||||
.type('2{enter}');
|
||||
|
||||
cy.get('#decimalplaces input')
|
||||
.should('have.attr', 'value', '2');
|
||||
helper.typeIntoInputField('#decimalplaces input', '2', true, false);
|
||||
|
||||
calcHelper.selectEntireSheet();
|
||||
|
||||
|
@ -350,12 +345,7 @@ describe('Apply number formatting.', function() {
|
|||
.should('have.attr', 'value', '1');
|
||||
|
||||
// Type in a new value
|
||||
cy.get('#leadingzeroes input')
|
||||
.clear()
|
||||
.type('6{enter}');
|
||||
|
||||
cy.get('#leadingzeroes input')
|
||||
.should('have.attr', 'value', '6');
|
||||
helper.typeIntoInputField('#leadingzeroes input', '6', true, false);
|
||||
|
||||
calcHelper.selectEntireSheet();
|
||||
|
||||
|
|
|
@ -25,23 +25,13 @@ describe('Overlay bounds.', function () {
|
|||
var cellA1Bounds = new helper.Bounds();
|
||||
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor', cellA1Bounds);
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('C3{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'C3');
|
||||
helper.typeIntoInputField('input#addressInput', 'C3');
|
||||
|
||||
var cellC3Bounds = new helper.Bounds();
|
||||
helper.overlayItemHasDifferentBoundsThan('#test-div-overlay-cell-cursor', cellA1Bounds);
|
||||
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor', cellC3Bounds);
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('B2{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'B2');
|
||||
helper.typeIntoInputField('input#addressInput', 'B2');
|
||||
|
||||
cy.wrap(null).should(function () {
|
||||
cy.log('cellA1Bounds = ' + cellA1Bounds + ', cellC3Bounds = ' + cellC3Bounds);
|
||||
|
@ -65,23 +55,13 @@ describe('Overlay bounds.', function () {
|
|||
var cellA1Bounds = new helper.Bounds();
|
||||
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor', cellA1Bounds);
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('D4{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'D4');
|
||||
helper.typeIntoInputField('input#addressInput', 'D4');
|
||||
|
||||
var cellD4Bounds = new helper.Bounds();
|
||||
helper.overlayItemHasDifferentBoundsThan('#test-div-overlay-cell-cursor', cellA1Bounds);
|
||||
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor', cellD4Bounds);
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.clear()
|
||||
.type('A1:D4{enter}');
|
||||
|
||||
cy.get('input#addressInput')
|
||||
.should('have.prop', 'value', 'A1:D4');
|
||||
helper.typeIntoInputField('input#addressInput', 'A1:D4');
|
||||
|
||||
cy.wrap(null).should(function () {
|
||||
cy.log('cellA1Bounds = ' + cellA1Bounds + ', cellD4Bounds = ' + cellD4Bounds);
|
||||
|
|
|
@ -181,12 +181,7 @@ describe('Apply paragraph properties on selected shape.', function() {
|
|||
|
||||
openParagraphPropertiesPanel();
|
||||
|
||||
cy.get('#aboveparaspacing input')
|
||||
.clear()
|
||||
.type('2{enter}');
|
||||
|
||||
cy.get('#aboveparaspacing input')
|
||||
.should('have.attr', 'value', '2');
|
||||
helper.typeIntoInputField('#aboveparaspacing input', '2', true, false);
|
||||
|
||||
triggerNewSVG();
|
||||
|
||||
|
@ -200,12 +195,7 @@ describe('Apply paragraph properties on selected shape.', function() {
|
|||
|
||||
openParagraphPropertiesPanel();
|
||||
|
||||
cy.get('#belowparaspacing input')
|
||||
.clear()
|
||||
.type('2{enter}');
|
||||
|
||||
cy.get('#belowparaspacing input')
|
||||
.should('have.attr', 'value', '2');
|
||||
helper.typeIntoInputField('#belowparaspacing input', '2', true, false);
|
||||
|
||||
triggerNewSVG();
|
||||
|
||||
|
|
|
@ -203,12 +203,7 @@ describe('Apply paragraph properties on selected text.', function() {
|
|||
|
||||
openParagraphPropertiesPanel();
|
||||
|
||||
cy.get('#aboveparaspacing input')
|
||||
.clear()
|
||||
.type('2{enter}');
|
||||
|
||||
cy.get('#aboveparaspacing input')
|
||||
.should('have.attr', 'value', '2');
|
||||
helper.typeIntoInputField('#aboveparaspacing input', '2', true, false);
|
||||
|
||||
triggerNewSVG();
|
||||
|
||||
|
@ -224,12 +219,7 @@ describe('Apply paragraph properties on selected text.', function() {
|
|||
|
||||
openParagraphPropertiesPanel();
|
||||
|
||||
cy.get('#belowparaspacing input')
|
||||
.clear()
|
||||
.type('2{enter}');
|
||||
|
||||
cy.get('#belowparaspacing input')
|
||||
.should('have.attr', 'value', '2');
|
||||
helper.typeIntoInputField('#belowparaspacing input', '2', true, false);
|
||||
|
||||
triggerNewSVG();
|
||||
|
||||
|
|
|
@ -88,10 +88,7 @@ describe('Change shape properties via mobile wizard.', function() {
|
|||
|
||||
openPosSizePanel();
|
||||
|
||||
cy.get('#selectwidth .spinfield')
|
||||
.clear()
|
||||
.type('4.2')
|
||||
.type('{enter}');
|
||||
helper.typeIntoInputField('#selectwidth .spinfield', '4.2', true, false);
|
||||
|
||||
cy.get('.leaflet-pane.leaflet-overlay-pane svg g svg g g g path')
|
||||
.should('not.have.attr', 'd', defaultGeometry);
|
||||
|
@ -104,10 +101,7 @@ describe('Change shape properties via mobile wizard.', function() {
|
|||
|
||||
openPosSizePanel();
|
||||
|
||||
cy.get('#selectheight .spinfield')
|
||||
.clear()
|
||||
.type('5.2')
|
||||
.type('{enter}');
|
||||
helper.typeIntoInputField('#selectheight .spinfield', '5.2', true, false);
|
||||
|
||||
cy.get('.leaflet-pane.leaflet-overlay-pane svg g svg g g g path')
|
||||
.should('not.have.attr', 'd', defaultGeometry);
|
||||
|
@ -229,13 +223,7 @@ describe('Change shape properties via mobile wizard.', function() {
|
|||
it('Change line transparency', function() {
|
||||
openLinePropertyPanel();
|
||||
|
||||
cy.get('#linetransparency .spinfield')
|
||||
.clear()
|
||||
.type('20')
|
||||
.type('{enter}');
|
||||
|
||||
cy.get('#linetransparency .spinfield')
|
||||
.should('have.attr', 'value', '20');
|
||||
helper.typeIntoInputField('#linetransparency .spinfield', '20', true, false);
|
||||
|
||||
triggerNewSVG();
|
||||
|
||||
|
|
|
@ -234,13 +234,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
|
|||
cy.get('#rowheight .spinfield')
|
||||
.should('have.attr', 'value', '0');
|
||||
|
||||
cy.get('#rowheight .spinfield')
|
||||
.clear()
|
||||
.type('1.4')
|
||||
.type('{enter}');
|
||||
|
||||
cy.get('#rowheight .spinfield')
|
||||
.should('have.attr', 'value', '1.4');
|
||||
helper.typeIntoInputField('#rowheight .spinfield', '1.4', true, false);
|
||||
|
||||
selectFullTable();
|
||||
|
||||
|
@ -254,13 +248,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
|
|||
|
||||
openTablePanel();
|
||||
|
||||
cy.get('#columnwidth .spinfield')
|
||||
.clear()
|
||||
.type('1.6')
|
||||
.type('{enter}');
|
||||
|
||||
cy.get('#columnwidth .spinfield')
|
||||
.should('have.attr', 'value', '1.6');
|
||||
helper.typeIntoInputField('#columnwidth .spinfield', '1.6', true, false);
|
||||
|
||||
selectFullTable();
|
||||
|
||||
|
|
Loading…
Reference in a new issue