diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2021-03-02 13:08:08 +0100 |
---|---|---|
committer | Tamás Zolnai <zolnaitamas2000@gmail.com> | 2021-03-08 20:07:33 +0100 |
commit | b0692ed3bac4c0945b2d58bf33ca57fa3fe1c5e1 (patch) | |
tree | 92c45bf02afcca47d05d722fad4c0dd8d060f440 /cypress_test | |
parent | cypress: make: fix typo in function name. (diff) | |
download | online-b0692ed3bac4c0945b2d58bf33ca57fa3fe1c5e1.tar.gz online-b0692ed3bac4c0945b2d58bf33ca57fa3fe1c5e1.zip |
cypress: extract typeIntoInputField() method.
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Change-Id: I8dc89dc6abad9106ffae42fc52723e503ddc0cca
(cherry picked from commit 87c6c7d81d3729f21bb87b48326828c6f02b1a34)
Diffstat (limited to 'cypress_test')
9 files changed, 56 insertions, 128 deletions
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index 2c8cc00f51..8f52b0b960 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -1083,6 +1083,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; @@ -1120,3 +1151,4 @@ module.exports.Bounds = Bounds; module.exports.getOverlayItemBounds = getOverlayItemBounds; module.exports.overlayItemHasBounds = overlayItemHasBounds; module.exports.overlayItemHasDifferentBoundsThan = overlayItemHasDifferentBoundsThan; +module.exports.typeIntoInputField = typeIntoInputField; diff --git a/cypress_test/integration_tests/desktop/calc/statusbar_spec.js b/cypress_test/integration_tests/desktop/calc/statusbar_spec.js index 9f98cc2db1..1fe71136dd 100644 --- a/cypress_test/integration_tests/desktop/calc/statusbar_spec.js +++ b/cypress_test/integration_tests/desktop/calc/statusbar_spec.js @@ -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'); diff --git a/cypress_test/integration_tests/mobile/calc/formulabar_spec.js b/cypress_test/integration_tests/mobile/calc/formulabar_spec.js index ae10aa29fe..d7b1d36757 100644 --- a/cypress_test/integration_tests/mobile/calc/formulabar_spec.js +++ b/cypress_test/integration_tests/mobile/calc/formulabar_spec.js @@ -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'); diff --git a/cypress_test/integration_tests/mobile/calc/number_format_spec.js b/cypress_test/integration_tests/mobile/calc/number_format_spec.js index 58088242ed..a3b53d8786 100644 --- a/cypress_test/integration_tests/mobile/calc/number_format_spec.js +++ b/cypress_test/integration_tests/mobile/calc/number_format_spec.js @@ -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(); diff --git a/cypress_test/integration_tests/mobile/calc/overlays_spec.js b/cypress_test/integration_tests/mobile/calc/overlays_spec.js index 90fbdbe51f..ed342a590e 100644 --- a/cypress_test/integration_tests/mobile/calc/overlays_spec.js +++ b/cypress_test/integration_tests/mobile/calc/overlays_spec.js @@ -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); diff --git a/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_shape_spec.js b/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_shape_spec.js index 4389e131c5..290d17008d 100644 --- a/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_shape_spec.js +++ b/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_shape_spec.js @@ -189,12 +189,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(); @@ -209,12 +204,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(); diff --git a/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_text_spec.js b/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_text_spec.js index ddd8fe92eb..c6453e83b7 100644 --- a/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_text_spec.js +++ b/cypress_test/integration_tests/mobile/impress/apply_paragraph_props_text_spec.js @@ -211,12 +211,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(); @@ -233,12 +228,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(); diff --git a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js index 16897b2092..f847607f72 100644 --- a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js +++ b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js @@ -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(); diff --git a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js index 9dbeb85421..6cf425d53c 100644 --- a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js +++ b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js @@ -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(); |