cypress_test/Makefile.am | 1 cypress_test/data/mobile/calc/insertion_wizard.ods |binary cypress_test/integration_tests/common/helper.js | 25 ++ cypress_test/integration_tests/mobile/calc/calc_helper.js | 45 ++++ cypress_test/integration_tests/mobile/calc/focus_spec.js | 5 cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js | 83 +++++++ cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js | 3 cypress_test/integration_tests/mobile/writer/spellchecking_spec.js | 2 cypress_test/integration_tests/mobile/writer/writer_helper.js | 109 +++------- 9 files changed, 201 insertions(+), 72 deletions(-)
New commits: commit 79073f6ce147c61612c2cc1b11a5e2edc2a4b30b Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Mon Mar 9 17:49:56 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Mar 10 11:18:04 2020 +0100 cypress: mobile: add first insertion related tests for calc. Change-Id: I57561ef5687119cd53d99ea46e9ca3a269548422 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90237 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index e4616f3dc..84d7c19a6 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -32,6 +32,7 @@ export DISPLAY=$(if $(HEADLESS_BUILD),:$(DISPLAY_NUMBER),$(shell echo $$DISPLAY) if HAVE_LO_PATH MOBILE_TEST_FILES= \ calc/focus_spec.js \ + calc/insertion_wizard_spec.js \ impress/impress_focus_spec.js \ writer/apply_font_spec.js \ writer/apply_paragraph_properties_spec.js \ diff --git a/cypress_test/data/mobile/calc/insertion_wizard.ods b/cypress_test/data/mobile/calc/insertion_wizard.ods new file mode 100644 index 000000000..4c86f1a9d Binary files /dev/null and b/cypress_test/data/mobile/calc/insertion_wizard.ods differ diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index 0e06a7d0e..fddafdf22 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -91,6 +91,31 @@ function detectLOCoreVersion() { } } +function longPressOnDocument(posX, posY) { + cy.get('.leaflet-pane.leaflet-map-pane') + .then(function(items) { + expect(items).have.length(1); + + var eventOptions = { + force: true, + button: 0, + pointerType: 'mouse', + x: posX - items[0].getBoundingClientRect().left, + y: posY - items[0].getBoundingClientRect().top + }; + + cy.get('.leaflet-pane.leaflet-map-pane') + .trigger('pointerdown', eventOptions) + .trigger('pointermove', eventOptions); + + cy.wait(600); + + cy.get('.leaflet-pane.leaflet-map-pane') + .trigger('pointerup', eventOptions); + }); +} + module.exports.loadTestDoc = loadTestDoc; module.exports.afterAll = afterAll; module.exports.beforeAllMobile = beforeAllMobile; +module.exports.longPressOnDocument = longPressOnDocument; diff --git a/cypress_test/integration_tests/mobile/calc/calc_helper.js b/cypress_test/integration_tests/mobile/calc/calc_helper.js index 5839efb01..7bbec9781 100644 --- a/cypress_test/integration_tests/mobile/calc/calc_helper.js +++ b/cypress_test/integration_tests/mobile/calc/calc_helper.js @@ -1,4 +1,6 @@ -/* global cy expect*/ +/* global cy expect require*/ + +var helper = require('../../common/helper'); function clickOnFirstCell() { // Enable editing if it's in read-only mode @@ -21,4 +23,45 @@ function clickOnFirstCell() { }); } +function copyContentToClipboard() { + selectAllMobile(); + + cy.get('.leaflet-tile-container') + .then(function(items) { + expect(items).to.have.lengthOf(1); + var XPos = items[0].getBoundingClientRect().right + 10; + var YPos = items[0].getBoundingClientRect().top + 10; + helper.longPressOnDocument(XPos, YPos); + }); + + // Execute copy + cy.get('.menu-entry-with-icon', {timeout : 10000}) + .contains('Copy') + .click(); + + // Close warning about clipboard operations + cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') + .click(); + + // Wait until it's closed + cy.get('.vex-overlay') + .should('not.exist'); +} + +function selectAllMobile() { + cy.get('body') + .type('{enter}'); + + cy.get('.leaflet-marker-icon') + .should('exist'); + + cy.get('#spreadsheet-header-corner') + .click(); + + cy.get('.leaflet-marker-icon') + .should('exist'); +} + +module.exports.copyContentToClipboard = copyContentToClipboard; +module.exports.selectAllMobile = selectAllMobile; module.exports.clickOnFirstCell = clickOnFirstCell; diff --git a/cypress_test/integration_tests/mobile/calc/focus_spec.js b/cypress_test/integration_tests/mobile/calc/focus_spec.js index 801b423f8..705c513a5 100644 --- a/cypress_test/integration_tests/mobile/calc/focus_spec.js +++ b/cypress_test/integration_tests/mobile/calc/focus_spec.js @@ -26,7 +26,7 @@ describe('Calc focus tests', function() { // One tap on an other cell -> no focus on the document calcHelper.clickOnFirstCell(); - cy.get('.leaflet-marker-icon.spreadsheet-cell-resize-marker') + cy.get('.leaflet-marker-icon') .should('be.visible'); // No focus @@ -62,7 +62,8 @@ describe('Calc focus tests', function() { // One tap on a cell -> no document focus calcHelper.clickOnFirstCell(); - cy.get('.leaflet-marker-icon.spreadsheet-cell-resize-marker'); + cy.get('.leaflet-marker-icon') + .should('be.visible'); // No focus cy.document().its('activeElement.tagName') diff --git a/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js new file mode 100644 index 000000000..4cc14fbc1 --- /dev/null +++ b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js @@ -0,0 +1,83 @@ +/* global describe it cy beforeEach require afterEach*/ + +var helper = require('../../common/helper'); +var calcHelper = require('./calc_helper'); + +describe('Calc insertion wizard.', function() { + beforeEach(function() { + helper.beforeAllMobile('insertion_wizard.ods', 'calc'); + + // Click on edit button + cy.get('#mobile-edit-button').click(); + }); + + afterEach(function() { + helper.afterAll(); + }); + + it('Check existance of image insertion items.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + + cy.get('.menu-entry-with-icon') + .contains('Local Image...'); + + cy.get('.menu-entry-with-icon') + .contains('Image...'); + }); + + it('Insert chart.', function() { + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + + cy.get('.menu-entry-with-icon') + .contains('Chart...') + .click(); + + cy.get('.leaflet-drag-transform-marker') + .should('have.length', 8); + }); + + it('Insert hyperlink.', function() { + calcHelper.clickOnFirstCell(); + + cy.get('.leaflet-marker-icon') + .should('be.visible'); + + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click(); + + cy.get('.menu-entry-with-icon') + .contains('Hyperlink...') + .click(); + + // Dialog is opened + cy.get('.vex-content.hyperlink-dialog') + .should('exist'); + + // Type text and link + cy.get('.vex-content.hyperlink-dialog input[name="text"]') + .clear() + .type('some text'); + cy.get('.vex-content.hyperlink-dialog input[name="link"]') + .type('www.something.com'); + + // Insert + cy.get('.vex-content.hyperlink-dialog .vex-dialog-button-primary') + .click(); + + cy.get('.blinking-cursor') + .should('be.visible'); + + calcHelper.copyContentToClipboard(); + + cy.get('#copy-paste-container table td a') + .contains('some text'); + + cy.get('#copy-paste-container table td a') + .should('have.attr', 'href', 'http://www.something.com'); + }); +}); diff --git a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js index 70ea2ba08..47790dc47 100644 --- a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js +++ b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js @@ -1,7 +1,6 @@ /* global describe it cy beforeEach require afterEach*/ var helper = require('../../common/helper'); -var writerHelper = require('./writer_helper'); describe('Mobile wizard state tests', function() { beforeEach(function() { @@ -103,7 +102,7 @@ describe('Mobile wizard state tests', function() { .should('have.class', 'checked'); // Open context wizard by right click on document - writerHelper.longPressOnDocument(40, 40); + helper.longPressOnDocument(40, 40); cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon') .contains('Paste'); diff --git a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js index a7de2b37f..595dc63bc 100644 --- a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js +++ b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js @@ -39,7 +39,7 @@ describe('Spell checking menu.', function() { var XPos = startPos.right + 10; var YPos = endPos.top - 10; - writerHelper.longPressOnDocument(XPos, YPos); + helper.longPressOnDocument(XPos, YPos); }); cy.get('#mobile-wizard-content') diff --git a/cypress_test/integration_tests/mobile/writer/writer_helper.js b/cypress_test/integration_tests/mobile/writer/writer_helper.js index 28a1fb161..17339efc1 100644 --- a/cypress_test/integration_tests/mobile/writer/writer_helper.js +++ b/cypress_test/integration_tests/mobile/writer/writer_helper.js @@ -1,41 +1,6 @@ -/* global cy expect*/ +/* global cy expect require*/ -function selectAllMobile() { - // Remove selection if exist - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon') - .should('not.exist'); - - // Enable editing if it's in read-only mode - cy.get('#mobile-edit-button') - .then(function(button) { - if (button.css('display') !== 'none') { - cy.get('#mobile-edit-button') - .click(); - } - }); - - // Open hamburger menu - cy.get('#toolbar-hamburger') - .click(); - - // Open edit menu - cy.get('.ui-header.level-0 .menu-entry-with-icon') - .contains('Edit') - .click(); - - cy.get('.ui-header.level-1 .menu-entry-with-icon') - .should('be.visible') - .wait(100); - - // Do the selection - cy.get('.ui-header.level-1 .menu-entry-with-icon') - .contains('Select All') - .click(); - - cy.get('.leaflet-marker-icon') - .should('exist'); -} +var helper = require('../../common/helper'); function copyTextToClipboard() { // Do a new selection @@ -45,9 +10,9 @@ function copyTextToClipboard() { cy.get('.leaflet-marker-icon') .then(function(marker) { expect(marker).to.have.lengthOf(2); - var XPos = (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2; + var XPos = (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2; var YPos = marker[0].getBoundingClientRect().top - 5; - longPressOnDocument(XPos, YPos); + helper.longPressOnDocument(XPos, YPos); }); // Execute copy @@ -82,7 +47,7 @@ function copyTableToClipboard() { var XPos = startPos.right + 10; var YPos = (startPos.top + endPos.top) / 2; - longPressOnDocument(XPos, YPos); + helper.longPressOnDocument(XPos, YPos); }); // Execute copy @@ -99,30 +64,6 @@ function copyTableToClipboard() { .should('not.exist'); } -function longPressOnDocument(posX, posY) { - cy.get('.leaflet-pane.leaflet-map-pane') - .then(function(items) { - expect(items).have.length(1); - - var eventOptions = { - force: true, - button: 0, - pointerType: 'mouse', - x: posX - items[0].getBoundingClientRect().left, - y: posY - items[0].getBoundingClientRect().top - }; - - cy.get('.leaflet-pane.leaflet-map-pane') - .trigger('pointerdown', eventOptions) - .trigger('pointermove', eventOptions); - - cy.wait(600); - - cy.get('.leaflet-pane.leaflet-map-pane') - .trigger('pointerup', eventOptions); - }); -} - // Use this method when a test openes the same mobile // wizard more times during a test. // Recent issue with this scenario is that the mobile @@ -144,8 +85,44 @@ function clearMobileWizardState() { .click(); } -module.exports.selectAllMobile = selectAllMobile; +function selectAllMobile() { + // Remove selection if exist + cy.get('#document-container').click(); + cy.get('.leaflet-marker-icon') + .should('not.exist'); + + // Enable editing if it's in read-only mode + cy.get('#mobile-edit-button') + .then(function(button) { + if (button.css('display') !== 'none') { + cy.get('#mobile-edit-button') + .click(); + } + }); + + // Open hamburger menu + cy.get('#toolbar-hamburger') + .click(); + + // Open edit menu + cy.get('.ui-header.level-0 .menu-entry-with-icon') + .contains('Edit') + .click(); + + cy.get('.ui-header.level-1 .menu-entry-with-icon') + .should('be.visible') + .wait(100); + + // Do the selection + cy.get('.ui-header.level-1 .menu-entry-with-icon') + .contains('Select All') + .click(); + + cy.get('.leaflet-marker-icon') + .should('exist'); +} + module.exports.copyTextToClipboard = copyTextToClipboard; module.exports.copyTableToClipboard = copyTableToClipboard; -module.exports.longPressOnDocument = longPressOnDocument; module.exports.clearMobileWizardState = clearMobileWizardState; +module.exports.selectAllMobile = selectAllMobile; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits